@app-studio/web 0.9.34 → 0.9.36
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/dist/components/Calendar/Calendar/Calendar.style.d.ts +4 -0
- package/dist/components/OKR/OKR/OKR.props.d.ts +72 -0
- package/dist/components/OKR/OKR/OKR.style.d.ts +19 -0
- package/dist/components/OKR/OKR/OKR.view.d.ts +4 -0
- package/dist/components/OKR/OKR.d.ts +4 -0
- package/dist/components/index.d.ts +4 -3
- package/dist/pages/okr.page.d.ts +3 -0
- package/dist/web.cjs.development.js +595 -760
- package/dist/web.cjs.development.js.map +1 -1
- package/dist/web.cjs.production.min.js +1 -1
- package/dist/web.cjs.production.min.js.map +1 -1
- package/dist/web.esm.js +595 -760
- package/dist/web.esm.js.map +1 -1
- package/dist/web.umd.development.js +598 -762
- package/dist/web.umd.development.js.map +1 -1
- package/dist/web.umd.production.min.js +1 -1
- package/dist/web.umd.production.min.js.map +1 -1
- package/docs/README.md +2 -1
- package/docs/components/Calendar.mdx +22 -110
- package/docs/components/Flow.mdx +1 -0
- package/docs/components/KanbanBoard.mdx +156 -0
- package/docs/components/OKR.mdx +475 -0
- package/docs/components/Title.mdx +1 -0
- package/docs/components/Tree.mdx +1 -0
- package/docs/components.md +178 -0
- package/package.json +1 -1
- package/dist/components/CalendarWeek/CalendarWeek/CalendarWeek.props.d.ts +0 -51
- package/dist/components/CalendarWeek/CalendarWeek/CalendarWeek.style.d.ts +0 -90
- package/dist/components/CalendarWeek/CalendarWeek/CalendarWeek.utils.d.ts +0 -51
- package/dist/components/CalendarWeek/CalendarWeek/CalendarWeek.view.d.ts +0 -3
- package/dist/components/CalendarWeek/CalendarWeek.d.ts +0 -1
- package/docs/api-reference/README.md +0 -103
- package/docs/api-reference/data-display/flow.md +0 -220
- package/docs/api-reference/data-display/tree.md +0 -210
- package/docs/api-reference/form/chat-input.md +0 -206
- package/docs/api-reference/utility/button.md +0 -145
- package/docs/api-reference/utility/title.md +0 -301
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { ViewProps } from 'app-studio';
|
|
2
|
-
export interface CalendarWeekEvent {
|
|
3
|
-
/** Unique identifier for the event */
|
|
4
|
-
id: string;
|
|
5
|
-
/** Event title/label */
|
|
6
|
-
title: string;
|
|
7
|
-
/** Start date in ISO format (YYYY-MM-DD) */
|
|
8
|
-
start: string;
|
|
9
|
-
/** End date in ISO format (YYYY-MM-DD) */
|
|
10
|
-
end: string;
|
|
11
|
-
/** Color variant for the event */
|
|
12
|
-
color?: 'blue' | 'red' | 'green' | 'purple' | 'orange';
|
|
13
|
-
}
|
|
14
|
-
export interface CalendarWeekViews {
|
|
15
|
-
/** Style overrides for the main container */
|
|
16
|
-
container?: ViewProps;
|
|
17
|
-
/** Style overrides for the week grid */
|
|
18
|
-
weekGrid?: ViewProps;
|
|
19
|
-
/** Style overrides for individual day columns */
|
|
20
|
-
dayColumn?: ViewProps;
|
|
21
|
-
/** Style overrides for day column headers */
|
|
22
|
-
dayHeader?: ViewProps;
|
|
23
|
-
/** Style overrides for day names (e.g., "Mon", "Tue") */
|
|
24
|
-
dayName?: ViewProps;
|
|
25
|
-
/** Style overrides for day dates (the circular number) */
|
|
26
|
-
dayDate?: ViewProps;
|
|
27
|
-
/** Style overrides for the events area */
|
|
28
|
-
eventsArea?: ViewProps;
|
|
29
|
-
/** Style overrides for individual events */
|
|
30
|
-
event?: ViewProps;
|
|
31
|
-
}
|
|
32
|
-
export interface CalendarWeekProps {
|
|
33
|
-
/** Start date of the week in ISO format (YYYY-MM-DD) */
|
|
34
|
-
startDate: string;
|
|
35
|
-
/** Array of events to display */
|
|
36
|
-
events?: CalendarWeekEvent[];
|
|
37
|
-
/** Today's date in ISO format (defaults to current date) */
|
|
38
|
-
today?: string;
|
|
39
|
-
/** Callback when an event is dragged to a new position */
|
|
40
|
-
onEventDrop?: (event: CalendarWeekEvent) => void;
|
|
41
|
-
/** Callback when an event is resized */
|
|
42
|
-
onEventResize?: (event: CalendarWeekEvent) => void;
|
|
43
|
-
/** Callback when a date is clicked */
|
|
44
|
-
onDateClick?: (date: string) => void;
|
|
45
|
-
/** Style overrides for various parts of the component */
|
|
46
|
-
views?: CalendarWeekViews;
|
|
47
|
-
/** Width of the calendar (default: '100%') */
|
|
48
|
-
width?: number | string;
|
|
49
|
-
/** Maximum width of the calendar (default: 1200) */
|
|
50
|
-
maxWidth?: number | string;
|
|
51
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { ViewProps } from 'app-studio';
|
|
3
|
-
/**
|
|
4
|
-
* Event color configurations
|
|
5
|
-
*/
|
|
6
|
-
export declare const EVENT_COLORS: {
|
|
7
|
-
readonly blue: {
|
|
8
|
-
readonly background: "color.blue.50";
|
|
9
|
-
readonly border: "color.blue.500";
|
|
10
|
-
readonly text: "color.blue.700";
|
|
11
|
-
};
|
|
12
|
-
readonly red: {
|
|
13
|
-
readonly background: "color.red.50";
|
|
14
|
-
readonly border: "color.red.500";
|
|
15
|
-
readonly text: "color.red.700";
|
|
16
|
-
};
|
|
17
|
-
readonly green: {
|
|
18
|
-
readonly background: "color.green.50";
|
|
19
|
-
readonly border: "color.green.500";
|
|
20
|
-
readonly text: "color.green.700";
|
|
21
|
-
};
|
|
22
|
-
readonly purple: {
|
|
23
|
-
readonly background: "color.purple.50";
|
|
24
|
-
readonly border: "color.purple.500";
|
|
25
|
-
readonly text: "color.purple.700";
|
|
26
|
-
};
|
|
27
|
-
readonly orange: {
|
|
28
|
-
readonly background: "color.orange.50";
|
|
29
|
-
readonly border: "color.orange.500";
|
|
30
|
-
readonly text: "color.orange.700";
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Base styles for the calendar container
|
|
35
|
-
*/
|
|
36
|
-
export declare const containerStyles: ViewProps;
|
|
37
|
-
/**
|
|
38
|
-
* Week grid styles (7 columns)
|
|
39
|
-
*/
|
|
40
|
-
export declare const weekGridStyles: ViewProps;
|
|
41
|
-
/**
|
|
42
|
-
* Individual day column styles
|
|
43
|
-
*/
|
|
44
|
-
export declare const dayColumnStyles: ViewProps;
|
|
45
|
-
/**
|
|
46
|
-
* Day header styles
|
|
47
|
-
*/
|
|
48
|
-
export declare const dayHeaderStyles: ViewProps;
|
|
49
|
-
/**
|
|
50
|
-
* Day name styles (e.g., "Mon", "Tue")
|
|
51
|
-
*/
|
|
52
|
-
export declare const dayNameStyles: ViewProps;
|
|
53
|
-
/**
|
|
54
|
-
* Day date styles (the circular number)
|
|
55
|
-
*/
|
|
56
|
-
export declare const dayDateStyles: ViewProps;
|
|
57
|
-
/**
|
|
58
|
-
* Today date styles
|
|
59
|
-
*/
|
|
60
|
-
export declare const todayDateStyles: ViewProps;
|
|
61
|
-
/**
|
|
62
|
-
* Selected date styles
|
|
63
|
-
*/
|
|
64
|
-
export declare const selectedDateStyles: ViewProps;
|
|
65
|
-
/**
|
|
66
|
-
* Events area styles
|
|
67
|
-
*/
|
|
68
|
-
export declare const eventsAreaStyles: ViewProps;
|
|
69
|
-
/**
|
|
70
|
-
* Events layer styles (absolute positioned over the grid)
|
|
71
|
-
*/
|
|
72
|
-
export declare const eventsLayerStyles: ViewProps;
|
|
73
|
-
/**
|
|
74
|
-
* Base event styles
|
|
75
|
-
*/
|
|
76
|
-
export declare const eventStyles: ViewProps;
|
|
77
|
-
/**
|
|
78
|
-
* Drop target indicator styles
|
|
79
|
-
*/
|
|
80
|
-
export declare const dropTargetStyles: ViewProps;
|
|
81
|
-
/**
|
|
82
|
-
* Calculate event position styles
|
|
83
|
-
*/
|
|
84
|
-
export declare const getEventPositionStyles: (startDay: number, duration: number, row: number) => React.CSSProperties;
|
|
85
|
-
/**
|
|
86
|
-
* Resize handle styles
|
|
87
|
-
*/
|
|
88
|
-
export declare const resizeHandleStyles: React.CSSProperties;
|
|
89
|
-
export declare const leftResizeHandleStyles: React.CSSProperties;
|
|
90
|
-
export declare const rightResizeHandleStyles: React.CSSProperties;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { CalendarWeekEvent } from './CalendarWeek.props';
|
|
2
|
-
export interface PositionedEvent extends CalendarWeekEvent {
|
|
3
|
-
/** Starting day index (0-6) within the week */
|
|
4
|
-
startDay: number;
|
|
5
|
-
/** Ending day index (0-6) within the week */
|
|
6
|
-
endDay: number;
|
|
7
|
-
/** Number of days the event spans */
|
|
8
|
-
duration: number;
|
|
9
|
-
/** Row index for vertical positioning (to avoid overlaps) */
|
|
10
|
-
row: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Convert an ISO date string to a UTC Date object
|
|
14
|
-
*/
|
|
15
|
-
export declare const dateUTC: (iso: string) => Date;
|
|
16
|
-
/**
|
|
17
|
-
* Calculate the number of days between two ISO date strings
|
|
18
|
-
*/
|
|
19
|
-
export declare const daysBetweenUTC: (a: string, b: string) => number;
|
|
20
|
-
/**
|
|
21
|
-
* Add a number of days to an ISO date string
|
|
22
|
-
*/
|
|
23
|
-
export declare const addDateDays: (dateISO: string, days: number) => string;
|
|
24
|
-
/**
|
|
25
|
-
* Get the day of the week (0-6) from an ISO date string
|
|
26
|
-
*/
|
|
27
|
-
export declare const getDayOfWeek: (dateISO: string) => number;
|
|
28
|
-
/**
|
|
29
|
-
* Get the date number (1-31) from an ISO date string
|
|
30
|
-
*/
|
|
31
|
-
export declare const getDateNumber: (dateISO: string) => number;
|
|
32
|
-
/**
|
|
33
|
-
* Layout events with proper positioning to avoid overlaps
|
|
34
|
-
* Returns positioned events and the total number of rows needed
|
|
35
|
-
*/
|
|
36
|
-
export declare const layoutEvents: (events: CalendarWeekEvent[], weekStart: string) => {
|
|
37
|
-
items: PositionedEvent[];
|
|
38
|
-
rowCount: number;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Day names array (Sunday to Saturday)
|
|
42
|
-
*/
|
|
43
|
-
export declare const DAY_NAMES: string[];
|
|
44
|
-
/**
|
|
45
|
-
* Get the date ISO string for a specific day in the week
|
|
46
|
-
*/
|
|
47
|
-
export declare const getDateForDay: (weekStart: string, dayIndex: number) => string;
|
|
48
|
-
/**
|
|
49
|
-
* Get the day index (0-6) from a clientX position within a week grid element
|
|
50
|
-
*/
|
|
51
|
-
export declare const getDayFromX: (x: number, weekGridRect: DOMRect) => number;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { CalendarWeek } from './CalendarWeek/CalendarWeek.view';
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
# API Reference
|
|
2
|
-
|
|
3
|
-
This section provides detailed API documentation for all components in the App Studio Web Component Library.
|
|
4
|
-
|
|
5
|
-
## Component Categories
|
|
6
|
-
|
|
7
|
-
- [Layout Components](#layout-components)
|
|
8
|
-
- [Form Components](#form-components)
|
|
9
|
-
- [Navigation Components](#navigation-components)
|
|
10
|
-
- [Feedback Components](#feedback-components)
|
|
11
|
-
- [Data Display Components](#data-display-components)
|
|
12
|
-
- [Utility Components](#utility-components)
|
|
13
|
-
- [Interactive Components](#interactive-components)
|
|
14
|
-
|
|
15
|
-
## Layout Components
|
|
16
|
-
|
|
17
|
-
- [View](./layout/view.md) - Base container component
|
|
18
|
-
- [Horizontal](./layout/horizontal.md) - Horizontal flex container
|
|
19
|
-
- [Vertical](./layout/vertical.md) - Vertical flex container
|
|
20
|
-
- [Center](./layout/center.md) - Centered flex container
|
|
21
|
-
- [AspectRatio](./layout/aspect-ratio.md) - Container with fixed aspect ratio
|
|
22
|
-
- [Separator](./layout/separator.md) - Visual or semantic separator
|
|
23
|
-
- [Resizable](./layout/resizable.md) - Resizable container
|
|
24
|
-
|
|
25
|
-
## Form Components
|
|
26
|
-
|
|
27
|
-
- [Checkbox](./form/checkbox.md) - Checkbox input
|
|
28
|
-
- [ChatInput](./form/chat-input.md) - Chat input with file uploads and prompt examples
|
|
29
|
-
- [Radio](./form/radio.md) - Radio input
|
|
30
|
-
- [Select](./form/select.md) - Select dropdown
|
|
31
|
-
- [Switch](./form/switch.md) - Toggle switch
|
|
32
|
-
- [TextArea](./form/text-area.md) - Multi-line text input
|
|
33
|
-
- [TextField](./form/text-field.md) - Single-line text input
|
|
34
|
-
- [OTPInput](./form/otp-input.md) - One-time password input
|
|
35
|
-
|
|
36
|
-
## Navigation Components
|
|
37
|
-
|
|
38
|
-
- [Accordion](./navigation/accordion.md) - Expandable content sections
|
|
39
|
-
- [Menubar](./navigation/menubar.md) - Horizontal menu
|
|
40
|
-
- [NavigationMenu](./navigation/navigation-menu.md) - Navigation menu
|
|
41
|
-
- [Pagination](./navigation/pagination.md) - Page navigation
|
|
42
|
-
- [Sidebar](./navigation/sidebar.md) - Side navigation
|
|
43
|
-
- [Tabs](./navigation/tabs.md) - Tabbed interface
|
|
44
|
-
|
|
45
|
-
## Feedback Components
|
|
46
|
-
|
|
47
|
-
- [Alert](./feedback/alert.md) - Informational message
|
|
48
|
-
- [Modal](./feedback/modal.md) - Dialog box
|
|
49
|
-
- [Toast](./feedback/toast.md) - Temporary notification
|
|
50
|
-
- [Tooltip](./feedback/tooltip.md) - Contextual information
|
|
51
|
-
|
|
52
|
-
## Data Display Components
|
|
53
|
-
|
|
54
|
-
- [Avatar](./data-display/avatar.md) - User or entity representation
|
|
55
|
-
- [Badge](./data-display/badge.md) - Small count or status indicator
|
|
56
|
-
- [Card](./data-display/card.md) - Content container
|
|
57
|
-
- [Table](./data-display/table.md) - Tabular data
|
|
58
|
-
- [Chart](./data-display/chart.md) - Data visualization
|
|
59
|
-
- [Flow](./data-display/flow.md) - Interactive workflow diagrams and flowcharts
|
|
60
|
-
- [Tree](./data-display/tree.md) - Hierarchical tree structure
|
|
61
|
-
|
|
62
|
-
## Utility Components
|
|
63
|
-
|
|
64
|
-
- [Button](./utility/button.md) - Interactive button
|
|
65
|
-
- [Gradient](./utility/gradient.md) - Gradient background
|
|
66
|
-
- [Loader](./utility/loader.md) - Loading indicator
|
|
67
|
-
- [Text](./utility/text.md) - Text display
|
|
68
|
-
|
|
69
|
-
## Interactive Components
|
|
70
|
-
|
|
71
|
-
- [Carousel](./interactive/carousel.md) - Slideshow
|
|
72
|
-
- [ContextMenu](./interactive/context-menu.md) - Right-click menu
|
|
73
|
-
- [DropdownMenu](./interactive/dropdown-menu.md) - Dropdown menu
|
|
74
|
-
- [HoverCard](./interactive/hover-card.md) - Card that appears on hover
|
|
75
|
-
- [Slider](./interactive/slider.md) - Range input
|
|
76
|
-
- [Toggle](./interactive/toggle.md) - Toggle button
|
|
77
|
-
- [ToggleGroup](./interactive/toggle-group.md) - Group of toggle buttons
|
|
78
|
-
|
|
79
|
-
## Component API Structure
|
|
80
|
-
|
|
81
|
-
Each component's API documentation follows a consistent structure:
|
|
82
|
-
|
|
83
|
-
1. **Import** - How to import the component
|
|
84
|
-
2. **Props** - Detailed list of props with types and descriptions
|
|
85
|
-
3. **Examples** - Basic usage examples
|
|
86
|
-
4. **Variants** - Available variants and their usage
|
|
87
|
-
5. **Compound Components** - Sub-components (if applicable)
|
|
88
|
-
6. **Accessibility** - Accessibility features and considerations
|
|
89
|
-
7. **Best Practices** - Recommended usage patterns
|
|
90
|
-
|
|
91
|
-
## Generating API Documentation
|
|
92
|
-
|
|
93
|
-
Component API documentation is automatically generated using the `bot-doc` tool. To regenerate documentation for a component:
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
npm run bot-doc -- ComponentName src/components/ComponentName
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
To regenerate documentation for all components:
|
|
100
|
-
|
|
101
|
-
```bash
|
|
102
|
-
npm run create-docs
|
|
103
|
-
```
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
# Flow
|
|
2
|
-
|
|
3
|
-
The Flow component is used to create interactive workflow diagrams and flowcharts with support for node connections, drag-and-drop functionality, and viewport controls.
|
|
4
|
-
|
|
5
|
-
## Import
|
|
6
|
-
|
|
7
|
-
```jsx
|
|
8
|
-
import { Flow } from '@app-studio/web';
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Props
|
|
12
|
-
|
|
13
|
-
| Prop | Type | Default | Description |
|
|
14
|
-
| ---- | ---- | ------- | ----------- |
|
|
15
|
-
| nodes | FlowNode[] | [] | Array of nodes in the flow |
|
|
16
|
-
| edges | NodeConnection[] | [] | Array of edges/connections between nodes |
|
|
17
|
-
| size | 'sm' \| 'md' \| 'lg' | 'md' | Size of the flow nodes |
|
|
18
|
-
| variant | 'default' \| 'outline' \| 'filled' | 'default' | Visual variant of the flow nodes |
|
|
19
|
-
| direction | 'horizontal' \| 'vertical' | 'vertical' | Direction of the flow layout |
|
|
20
|
-
| showControls | boolean | true | Whether to show viewport controls (zoom in/out, reset) |
|
|
21
|
-
| allowAddingNodes | boolean | true | Whether to allow adding new nodes |
|
|
22
|
-
| allowDraggingNodes | boolean | true | Whether to allow dragging nodes |
|
|
23
|
-
| selectedNodeId | string | undefined | ID of the currently selected node |
|
|
24
|
-
| onNodeSelect | (nodeId: string \| null) => void | undefined | Callback when a node is selected |
|
|
25
|
-
| onNodesChange | (nodes: FlowNode[]) => void | undefined | Callback when nodes change |
|
|
26
|
-
| onEdgesChange | (edges: NodeConnection[]) => void | undefined | Callback when edges change |
|
|
27
|
-
| onNodeAdd | (node: FlowNode) => void | undefined | Callback when a node is added |
|
|
28
|
-
| onNodeDragStart | (nodeId: string) => void | undefined | Callback when node dragging starts |
|
|
29
|
-
| onNodeDrag | (nodeId: string, position: NodePosition) => void | undefined | Callback during node dragging |
|
|
30
|
-
| onNodeDragEnd | (nodeId: string, position: NodePosition) => void | undefined | Callback when node dragging ends |
|
|
31
|
-
| viewport | FlowViewport | { zoom: 1, x: 0, y: 0 } | Current viewport state (zoom level and position) |
|
|
32
|
-
| onViewportChange | (viewport: FlowViewport) => void | undefined | Callback when viewport changes |
|
|
33
|
-
| views | object | {} | Custom styling for different parts of the component |
|
|
34
|
-
|
|
35
|
-
## Node Structure
|
|
36
|
-
|
|
37
|
-
The `FlowNode` interface defines the structure of nodes in the Flow component:
|
|
38
|
-
|
|
39
|
-
```tsx
|
|
40
|
-
interface FlowNode {
|
|
41
|
-
id: string;
|
|
42
|
-
type?: 'default' | 'start' | 'end' | 'decision' | 'process' | string;
|
|
43
|
-
position: { x: number; y: number };
|
|
44
|
-
data?: {
|
|
45
|
-
label?: string;
|
|
46
|
-
subtitle?: string;
|
|
47
|
-
icon?: React.ReactNode;
|
|
48
|
-
number?: number;
|
|
49
|
-
[key: string]: any;
|
|
50
|
-
};
|
|
51
|
-
selected?: boolean;
|
|
52
|
-
isDragging?: boolean;
|
|
53
|
-
draggable?: boolean;
|
|
54
|
-
style?: ViewProps;
|
|
55
|
-
}
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## Edge Structure
|
|
59
|
-
|
|
60
|
-
The `NodeConnection` interface defines the structure of edges in the Flow component:
|
|
61
|
-
|
|
62
|
-
```tsx
|
|
63
|
-
interface NodeConnection {
|
|
64
|
-
id: string;
|
|
65
|
-
source: string;
|
|
66
|
-
target: string;
|
|
67
|
-
label?: string;
|
|
68
|
-
style?: ViewProps;
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## Examples
|
|
73
|
-
|
|
74
|
-
### Basic Usage
|
|
75
|
-
|
|
76
|
-
```jsx
|
|
77
|
-
import React, { useState } from 'react';
|
|
78
|
-
import { Flow } from '@app-studio/web';
|
|
79
|
-
import { View } from 'app-studio';
|
|
80
|
-
|
|
81
|
-
export const BasicFlow = () => {
|
|
82
|
-
// Initial nodes and edges
|
|
83
|
-
const [nodes, setNodes] = useState([
|
|
84
|
-
{
|
|
85
|
-
id: 'node-1',
|
|
86
|
-
position: { x: 50, y: 50 },
|
|
87
|
-
data: {
|
|
88
|
-
label: 'Start Node',
|
|
89
|
-
subtitle: 'Begin here'
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
id: 'node-2',
|
|
94
|
-
position: { x: 50, y: 200 },
|
|
95
|
-
data: {
|
|
96
|
-
label: 'Process Node',
|
|
97
|
-
subtitle: 'Do something'
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
]);
|
|
101
|
-
|
|
102
|
-
const [edges, setEdges] = useState([
|
|
103
|
-
{ id: 'edge-1-2', source: 'node-1', target: 'node-2' },
|
|
104
|
-
]);
|
|
105
|
-
|
|
106
|
-
return (
|
|
107
|
-
<View height="400px" border="1px solid" borderColor="color.gray.200" borderRadius={8}>
|
|
108
|
-
<Flow
|
|
109
|
-
nodes={nodes}
|
|
110
|
-
edges={edges}
|
|
111
|
-
onNodesChange={setNodes}
|
|
112
|
-
onEdgesChange={setEdges}
|
|
113
|
-
/>
|
|
114
|
-
</View>
|
|
115
|
-
);
|
|
116
|
-
};
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### With Node Addition
|
|
120
|
-
|
|
121
|
-
```jsx
|
|
122
|
-
import React, { useState } from 'react';
|
|
123
|
-
import { Flow } from '@app-studio/web';
|
|
124
|
-
import { View } from 'app-studio';
|
|
125
|
-
|
|
126
|
-
export const FlowWithNodeAddition = () => {
|
|
127
|
-
const [nodes, setNodes] = useState([
|
|
128
|
-
{
|
|
129
|
-
id: 'node-1',
|
|
130
|
-
position: { x: 50, y: 50 },
|
|
131
|
-
data: { label: 'Start', subtitle: 'Begin workflow' },
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
id: 'node-2',
|
|
135
|
-
position: { x: 50, y: 200 },
|
|
136
|
-
data: { label: 'Process', subtitle: 'Do something' },
|
|
137
|
-
},
|
|
138
|
-
]);
|
|
139
|
-
|
|
140
|
-
const [edges, setEdges] = useState([
|
|
141
|
-
{ id: 'edge-1-2', source: 'node-1', target: 'node-2' },
|
|
142
|
-
]);
|
|
143
|
-
|
|
144
|
-
const [selectedNodeId, setSelectedNodeId] = useState(null);
|
|
145
|
-
|
|
146
|
-
return (
|
|
147
|
-
<View height="400px" border="1px solid" borderColor="color.gray.200" borderRadius={8}>
|
|
148
|
-
<Flow
|
|
149
|
-
nodes={nodes}
|
|
150
|
-
edges={edges}
|
|
151
|
-
onNodesChange={setNodes}
|
|
152
|
-
onEdgesChange={setEdges}
|
|
153
|
-
selectedNodeId={selectedNodeId}
|
|
154
|
-
onNodeSelect={setSelectedNodeId}
|
|
155
|
-
allowAddingNodes={true}
|
|
156
|
-
onNodeAdd={(newNode) => {
|
|
157
|
-
setNodes((prevNodes) => [...prevNodes, newNode]);
|
|
158
|
-
}}
|
|
159
|
-
/>
|
|
160
|
-
</View>
|
|
161
|
-
);
|
|
162
|
-
};
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
## Compound Components
|
|
166
|
-
|
|
167
|
-
The Flow component uses a compound component pattern with the following sub-components:
|
|
168
|
-
|
|
169
|
-
```jsx
|
|
170
|
-
// These are primarily for potential direct use or a more componentized future version
|
|
171
|
-
Flow.Node // Renders a single node
|
|
172
|
-
Flow.Edge // Renders a connection between nodes
|
|
173
|
-
Flow.Controls // Renders viewport controls
|
|
174
|
-
Flow.AddNodeButton // Renders a button to add a new node
|
|
175
|
-
```
|
|
176
|
-
|
|
177
|
-
## Customization
|
|
178
|
-
|
|
179
|
-
The Flow component can be customized using the `views` prop:
|
|
180
|
-
|
|
181
|
-
```jsx
|
|
182
|
-
<Flow
|
|
183
|
-
// ...other props
|
|
184
|
-
views={{
|
|
185
|
-
container: { /* styles for the main flow container */ },
|
|
186
|
-
node: {
|
|
187
|
-
container: { /* styles for the node's root View */ },
|
|
188
|
-
content: { /* styles for the content wrapper inside the node */ },
|
|
189
|
-
icon: { /* styles for the node's icon View */ },
|
|
190
|
-
},
|
|
191
|
-
edge: {
|
|
192
|
-
path: { /* styles for the SVG path */ },
|
|
193
|
-
label: { /* styles for the edge label */ },
|
|
194
|
-
},
|
|
195
|
-
controls: {
|
|
196
|
-
container: { /* styles for the controls container */ },
|
|
197
|
-
button: { /* styles for individual control buttons */ },
|
|
198
|
-
},
|
|
199
|
-
addNodeButton: { /* styles for the add node button */ },
|
|
200
|
-
}}
|
|
201
|
-
/>
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
## Accessibility
|
|
205
|
-
|
|
206
|
-
The Flow component implements the following accessibility features:
|
|
207
|
-
|
|
208
|
-
- Keyboard navigation for selecting nodes
|
|
209
|
-
- ARIA attributes for interactive elements
|
|
210
|
-
- Focus management for controls and nodes
|
|
211
|
-
- Proper contrast for node and edge colors
|
|
212
|
-
|
|
213
|
-
## Best Practices
|
|
214
|
-
|
|
215
|
-
- Provide clear labels and subtitles for nodes to improve understanding
|
|
216
|
-
- Use consistent node types and styling for similar functionality
|
|
217
|
-
- Implement proper error handling for node and edge operations
|
|
218
|
-
- Consider viewport size when determining initial node positions
|
|
219
|
-
- Use the `onNodeAdd` callback to validate new node positions
|
|
220
|
-
- Implement undo/redo functionality for node operations when needed
|