@capillarytech/blaze-ui 5.2.2 → 5.2.4
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/.npmrc +2 -0
- package/CapCollapsibleNavbar/index.js +55 -3
- package/CapCollapsibleNavbar/index.js.map +1 -1
- package/CapCondition/index.js +55 -3
- package/CapCondition/index.js.map +1 -1
- package/CapDatePicker/index.js +55 -3
- package/CapDatePicker/index.js.map +1 -1
- package/CapDateTimePicker/README.md +136 -0
- package/CapDateTimePicker/index.d.ts +13 -0
- package/CapDateTimePicker/index.d.ts.map +1 -0
- package/CapDateTimePicker/index.js +166 -106
- package/CapDateTimePicker/index.js.map +1 -1
- package/CapDateTimePicker/messages.d.ts +17 -0
- package/CapDateTimePicker/messages.d.ts.map +1 -0
- package/CapDateTimePicker/types.d.ts +93 -0
- package/CapDateTimePicker/types.d.ts.map +1 -0
- package/CapDateTimeRangePicker/index.js +55 -3
- package/CapDateTimeRangePicker/index.js.map +1 -1
- package/CapEventCalendar/index.js +55 -3
- package/CapEventCalendar/index.js.map +1 -1
- package/CapLanguageProvider/index.js +55 -3
- package/CapLanguageProvider/index.js.map +1 -1
- package/CapLevelGraphRenderer/CapLevelGraphRenderer-test-cases.md +50 -0
- package/CapLevelGraphRenderer/MIGRATION_ANALYSIS.md +138 -0
- package/CapLevelGraphRenderer/README.md +123 -0
- package/CapLevelGraphRenderer/STORYBOOK_ANALYSIS.md +96 -0
- package/CapLevelGraphRenderer/Tooltip.d.ts +31 -0
- package/CapLevelGraphRenderer/Tooltip.d.ts.map +1 -0
- package/CapLevelGraphRenderer/Tooltip_MIGRATION_ANALYSIS.md +120 -0
- package/CapLevelGraphRenderer/index.d.ts +16 -0
- package/CapLevelGraphRenderer/index.d.ts.map +1 -0
- package/CapLevelGraphRenderer/index.js +159 -135
- package/CapLevelGraphRenderer/index.js.map +1 -1
- package/CapLevelGraphRenderer/tests/TEST_COVERAGE.md +119 -0
- package/CapLevelGraphRenderer/types.d.ts +139 -0
- package/CapLevelGraphRenderer/types.d.ts.map +1 -0
- package/CapNotificationDropdown/index.js +55 -3
- package/CapNotificationDropdown/index.js.map +1 -1
- package/CapTimePicker/index.js +55 -3
- package/CapTimePicker/index.js.map +1 -1
- package/index.d.ts +4 -0
- package/index.d.ts.map +1 -1
- package/index.js +1053 -4
- package/index.js.map +1 -1
- package/package.json +4 -2
- package/utils/dayjs.d.ts +21 -0
- package/utils/dayjs.d.ts.map +1 -1
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Test Cases: CapLevelGraphRenderer (Antd v3→v6)
|
|
2
|
+
|
|
3
|
+
## Component Analysis
|
|
4
|
+
- **Component**: CapLevelGraphRenderer
|
|
5
|
+
- **Complexity**: medium
|
|
6
|
+
- **Source**: blaze-ui/components/CapLevelGraphRenderer/
|
|
7
|
+
- **Dependencies**: @antv/x6, React, CapButton, CapIcon
|
|
8
|
+
- **Key Features**: Graph rendering with nodes, forward/reverse connections, pagination, tooltips
|
|
9
|
+
|
|
10
|
+
## Test Cases (≤20 for medium complexity)
|
|
11
|
+
|
|
12
|
+
| ID | Use Case | Props/Config | Expected Visual/Behavior | Priority | Storybook Story | Notes |
|
|
13
|
+
|---|---|---|---|---|---|---|
|
|
14
|
+
| UC-001 | Basic rendering with nodes and connections | `nodes=[{id: 'tier1', height: 295, component: MockComponent}, {id: 'tier2', height: 500, component: MockComponent}]`, `connections=[{sourceId: 'tier2', targetId: 'tier1'}]`, `graphId="test-graph"` | Graph renders with 2 nodes, forward connection between nodes, reverse connection visible, pagination controls visible | P0 | BasicRendering | Core functionality - must render graph |
|
|
15
|
+
| UC-002 | Empty state - no nodes | `nodes=[]`, `connections=[]`, `graphId="test-graph"` | Graph container renders, no nodes visible, pagination buttons disabled, no errors | P1 | EmptyState | Edge case - empty data |
|
|
16
|
+
| UC-003 | Single node without connections | `nodes=[{id: 'tier1', height: 295, component: MockComponent}]`, `connections=[]`, `graphId="test-graph"` | Single node renders, no connections drawn, pagination buttons disabled | P1 | SingleNode | Minimal valid state |
|
|
17
|
+
| UC-004 | Multiple nodes with forward connections only | `nodes=[{id: 'tier1', height: 200}, {id: 'tier2', height: 300}, {id: 'tier3', height: 250}]`, `connections=[]`, `graphId="test-graph"` | 3 nodes render in sequence, forward connections between adjacent nodes visible, no reverse connections | P0 | ForwardConnections | Default forward connection behavior |
|
|
18
|
+
| UC-005 | Reverse connections - level by level | `nodes=[{id: 'tier1', height: 200}, {id: 'tier2', height: 300}, {id: 'tier3', height: 250}]`, `connections=[{sourceId: 'tier3', targetId: 'tier1'}, {sourceId: 'tier2', targetId: 'tier1'}]`, `graphId="test-graph"` | Reverse connections render at different levels, avoid overlapping nodes, connections properly routed | P0 | ReverseConnections | Core reverse connection algorithm |
|
|
19
|
+
| UC-006 | All styling props | `className="custom-class"`, `graphStyles={{border: '1px solid red'}}`, `containerStyles={{padding: '10px'}}`, `scrollClassName="custom-scroll"`, `graphId="test-graph"` | Custom classes and styles applied to respective containers, visual styling visible | P1 | StylingProps | Grouped all style-related props |
|
|
20
|
+
| UC-007 | All layout/dimension props | `graphWidth="800px"`, `graphHeight="600px"`, `defaultStartX=50`, `defaultStartY=50`, `offsetHeight=30`, `defaultEleWidth=150`, `defaultEleDistance=40`, `offsetLineDistance=25`, `graphId="test-graph"` | Graph renders at specified dimensions, nodes positioned correctly, spacing matches props | P1 | LayoutProps | Grouped all layout configuration |
|
|
21
|
+
| UC-008 | Connection styling props | `lineStrokeColor="#ff0000"`, `forwardConnProps={{strokeWidth: 3}}`, `reverseConnProps={{strokeDasharray: '5,5'}}`, `graphId="test-graph"` | Forward connections use red color and thicker stroke, reverse connections use dashed style | P1 | ConnectionStyling | Grouped connection appearance props |
|
|
22
|
+
| UC-009 | Tooltip functionality - forward arrows | `showToolTip=true`, `allowForwardArrowTooltip=true`, `nodes=[{id: 'tier1', height: 200, toolTip: 'Tier 1'}, {id: 'tier2', height: 300, toolTip: 'Tier 2'}]`, `connections=[]`, `graphId="test-graph"` | Hovering forward connection shows tooltip with "Tier 1 - Tier 2" format | P1 | ForwardArrowTooltip | Tooltip on forward connections |
|
|
23
|
+
| UC-010 | Tooltip functionality - reverse arrows | `showToolTip=true`, `allowReverseArrowTooltip=true`, `nodes=[{id: 'tier1', height: 200, toolTip: 'Tier 1'}, {id: 'tier2', height: 300, toolTip: 'Tier 2'}]`, `connections=[{sourceId: 'tier2', targetId: 'tier1'}]`, `graphId="test-graph"` | Hovering reverse connection shows tooltip with combined tooltip text | P1 | ReverseArrowTooltip | Tooltip on reverse connections |
|
|
24
|
+
| UC-011 | Tooltip disabled | `showToolTip=false`, `nodes=[{id: 'tier1', height: 200, toolTip: 'Tier 1'}]`, `graphId="test-graph"` | No tooltip appears on hover, tooltip tool not registered | P2 | TooltipDisabled | Tooltip feature toggle |
|
|
25
|
+
| UC-012 | Pagination - previous button interaction | `nodes=[5 nodes with width 100, distance 20]`, `graphWidth="300px"`, `graphId="test-graph"` | Click previous button scrolls graph left, button disabled at start, scroll position updates | P0 | PaginationPrevious | Pagination navigation |
|
|
26
|
+
| UC-013 | Pagination - next button interaction | `nodes=[5 nodes with width 100, distance 20]`, `graphWidth="300px"`, `graphId="test-graph"` | Click next button scrolls graph right, button disabled at end, scroll position updates | P0 | PaginationNext | Pagination navigation |
|
|
27
|
+
| UC-014 | Pagination button states | `nodes=[3 nodes]`, `graphWidth="500px"` (fits all), `graphId="test-graph"` | Both buttons disabled when all nodes visible, buttons enabled when content exceeds viewport | P1 | PaginationStates | Button disabled logic |
|
|
28
|
+
| UC-015 | Scroller props customization | `scrollerProps={{padding: 10, pannable: true}}`, `graphId="test-graph"` | Scroller applies custom padding and panning behavior, graph respects scroller config | P2 | ScrollerProps | Advanced scroller configuration |
|
|
29
|
+
| UC-016 | Node props - component rendering | `nodes=[{id: 'tier1', height: 200, component: CustomComponent, props: {label: 'Test'}}]`, `graphId="test-graph"` | Custom React component renders inside node with passed props, component visible in graph | P0 | NodeComponent | Node content rendering |
|
|
30
|
+
| UC-017 | Complex connection scenarios | `nodes=[4 nodes]`, `connections=[multiple overlapping reverse connections]`, `graphId="test-graph"` | Multiple reverse connections render at different levels, no overlaps, proper routing around nodes | P0 | ComplexConnections | Edge case - complex graph topology |
|
|
31
|
+
| UC-018 | Missing graphId (required prop) | `nodes=[{id: 'tier1', height: 200}]` (no graphId) | Component throws error or handles gracefully, PropTypes validation catches missing prop | P0 | MissingGraphId | Required prop validation |
|
|
32
|
+
| UC-019 | Invalid connections | `nodes=[{id: 'tier1'}, {id: 'tier2'}]`, `connections=[{sourceId: 'invalid', targetId: 'tier1'}]`, `graphId="test-graph"` | Component handles invalid connection gracefully, only valid connections render, no errors | P1 | InvalidConnections | Edge case - invalid data |
|
|
33
|
+
| UC-020 | Migration - antv/x6 Graph API | Standard props with nodes and connections | Graph initializes correctly, nodes and edges added via x6 API, React components render in nodes, events work | P0 | MigrationX6API | Verify @antv/x6 integration works in v6 context |
|
|
34
|
+
|
|
35
|
+
## Grouping Rationale
|
|
36
|
+
|
|
37
|
+
- **UC-006**: Grouped all style props (className, graphStyles, containerStyles, scrollClassName) into single test
|
|
38
|
+
- **UC-007**: Grouped all layout/dimension props (graphWidth, graphHeight, positioning, spacing) into single test
|
|
39
|
+
- **UC-008**: Grouped connection styling props (lineStrokeColor, forwardConnProps, reverseConnProps) into single test
|
|
40
|
+
- **UC-009-011**: Tooltip tests grouped by feature (forward, reverse, disabled)
|
|
41
|
+
- **UC-012-014**: Pagination tests grouped by interaction type (previous, next, states)
|
|
42
|
+
|
|
43
|
+
## Notes
|
|
44
|
+
|
|
45
|
+
- Component uses @antv/x6 Graph library - verify compatibility with Antd v6
|
|
46
|
+
- Tooltip uses custom TooltipTool class extending ToolsView.ToolItem
|
|
47
|
+
- Pagination uses CapButton and CapIcon components
|
|
48
|
+
- Node components render via react-shape in x6
|
|
49
|
+
- Reverse connections use level-based algorithm to avoid overlaps
|
|
50
|
+
- Component requires DOM element with graphId for initialization
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Migration Analysis Report: CapLevelGraphRenderer
|
|
2
|
+
|
|
3
|
+
## STAGE 1: Pre-Analysis
|
|
4
|
+
|
|
5
|
+
### Analysis Report for CapLevelGraphRenderer
|
|
6
|
+
|
|
7
|
+
#### 1. Antd Style Overrides Found
|
|
8
|
+
|
|
9
|
+
| Line # | Old Override | Can Tokenize? | Token Path | Token Value | Override Reason |
|
|
10
|
+
|--------|-------------|---------------|------------|-------------|-----------------|
|
|
11
|
+
| 18 | `.anticon { margin: 0 }` | ❌ No | N/A | N/A | Specific icon spacing override - no token available for nested icon margin within button |
|
|
12
|
+
|
|
13
|
+
**Tokenizable overrides**: 0
|
|
14
|
+
**Non-tokenizable overrides**: 1
|
|
15
|
+
**If all tokenizable**: N/A
|
|
16
|
+
**If none found**: N/A
|
|
17
|
+
**Status**: One non-tokenizable override found - will use `:global` with `// OVERRIDE:` comment
|
|
18
|
+
|
|
19
|
+
#### 2. API Breaking Changes
|
|
20
|
+
|
|
21
|
+
| Old API | New API | Affected Props |
|
|
22
|
+
|---------|---------|----------------|
|
|
23
|
+
| N/A | N/A | N/A |
|
|
24
|
+
|
|
25
|
+
**Note**: This component does not use Ant Design components directly (uses @antv/x6 Graph library). No Antd API breaking changes apply.
|
|
26
|
+
|
|
27
|
+
#### 3. Backward Compatibility Plan
|
|
28
|
+
|
|
29
|
+
| Deprecated Prop | Fallback Logic |
|
|
30
|
+
|----------------|----------------|
|
|
31
|
+
| N/A | N/A |
|
|
32
|
+
|
|
33
|
+
**Note**: No deprecated props identified. Component uses @antv/x6 Graph library, not Ant Design components.
|
|
34
|
+
|
|
35
|
+
#### 4. Type Definitions Needed
|
|
36
|
+
|
|
37
|
+
- **Props interface**: Main component props with all current PropTypes converted to TypeScript
|
|
38
|
+
- **Node interface**: Type for nodes array items (`{ id: string, component: React.ComponentType, height: number, props?: Record<string, unknown>, toolTip?: string }`)
|
|
39
|
+
- **Connection interface**: Type for connections array items (`{ sourceId: string, targetId: string }`)
|
|
40
|
+
- **GraphRef type**: Type for graph reference (`React.MutableRefObject<Graph | null>`)
|
|
41
|
+
- **NodePosition interface**: Type for node position tracking object
|
|
42
|
+
- **EdgeObj interface**: Type for edge tracking object
|
|
43
|
+
|
|
44
|
+
#### 5. PropTypes Removal
|
|
45
|
+
|
|
46
|
+
- [x] Component uses PropTypes: **YES**
|
|
47
|
+
- [x] PropTypes file exists: **NO** (PropTypes defined inline in index.tsx)
|
|
48
|
+
- [x] PropTypes imports found: **YES** (`import PropTypes from 'prop-types'` on line 16)
|
|
49
|
+
- [x] Component.propTypes assignments found: **YES** (lines 431-454)
|
|
50
|
+
- **Action Required**: Must remove all PropTypes and replace with TypeScript types from types.ts
|
|
51
|
+
|
|
52
|
+
**PropTypes to Remove**:
|
|
53
|
+
- `import PropTypes from 'prop-types'` (line 16)
|
|
54
|
+
- `CapLevelGraphRenderer.propTypes = { ... }` (lines 431-454)
|
|
55
|
+
|
|
56
|
+
#### 6. DefaultProps Removal
|
|
57
|
+
|
|
58
|
+
- [x] Component uses defaultProps: **YES**
|
|
59
|
+
- [x] Component.defaultProps assignments found: **YES** (lines 456-478)
|
|
60
|
+
- [x] Old function syntax with props parameter: **NO** (already uses destructuring)
|
|
61
|
+
- [x] Default values assigned inside function body: **NO** (uses defaultProps)
|
|
62
|
+
- **Action Required**: Must remove defaultProps and convert to destructuring with default values in function arguments
|
|
63
|
+
|
|
64
|
+
**DefaultProps to Remove**:
|
|
65
|
+
- `CapLevelGraphRenderer.defaultProps = { ... }` (lines 456-478)
|
|
66
|
+
|
|
67
|
+
**Default Values to Convert**:
|
|
68
|
+
- `nodes: []`
|
|
69
|
+
- `className: ''`
|
|
70
|
+
- `graphStyles: {}`
|
|
71
|
+
- `connections: []`
|
|
72
|
+
- `defaultStartX: 0`
|
|
73
|
+
- `defaultStartY: 0`
|
|
74
|
+
- `offsetHeight: 20`
|
|
75
|
+
- `scrollerProps: {}`
|
|
76
|
+
- `showToolTip: false`
|
|
77
|
+
- `containerStyles: {}`
|
|
78
|
+
- `graphWidth: '500px'`
|
|
79
|
+
- `scrollClassName: ''`
|
|
80
|
+
- `graphHeight: '500px'`
|
|
81
|
+
- `reverseConnProps: {}`
|
|
82
|
+
- `forwardConnProps: {}`
|
|
83
|
+
- `defaultEleWidth: 100`
|
|
84
|
+
- `defaultEleDistance: 20`
|
|
85
|
+
- `offsetLineDistance: 18`
|
|
86
|
+
- `lineStrokeColor: 'gray'`
|
|
87
|
+
- `allowForwardArrowTooltip: false`
|
|
88
|
+
- `allowReverseArrowTooltip: false`
|
|
89
|
+
|
|
90
|
+
#### 7. External Package Dependencies
|
|
91
|
+
|
|
92
|
+
**External packages found**:
|
|
93
|
+
- `@antv/x6` - Graph library (used in index.tsx line 12, Tooltip.tsx line 1)
|
|
94
|
+
- `@antv/x6-react-shape` - React shape plugin for x6 (used in index.tsx line 13)
|
|
95
|
+
|
|
96
|
+
**Package status**:
|
|
97
|
+
- `@antv/x6`: Not found in package.json dependencies (needs to be added)
|
|
98
|
+
- `@antv/x6-react-shape`: Not found in package.json dependencies (needs to be added)
|
|
99
|
+
|
|
100
|
+
**Version reference**: Found version `1.12.4` in `tools/visual-testing/antd-current-version-consumer/package-lock.json`
|
|
101
|
+
|
|
102
|
+
**Action Required**: Add both packages to `blaze-ui/package.json` dependencies:
|
|
103
|
+
- `"@antv/x6": "^1.12.4"`
|
|
104
|
+
- `"@antv/x6-react-shape": "^1.2.3"`
|
|
105
|
+
|
|
106
|
+
#### 8. Component-Specific Notes
|
|
107
|
+
|
|
108
|
+
- Component uses `@antv/x6` Graph library (not Ant Design components)
|
|
109
|
+
- Uses React refs for graph instance management
|
|
110
|
+
- Has complex connection calculation logic for reverse connections
|
|
111
|
+
- Uses custom TooltipTool class extending ToolsView.ToolItem
|
|
112
|
+
- Pagination controls use CapButton and CapIcon components
|
|
113
|
+
- Component requires DOM element with `graphId` for initialization
|
|
114
|
+
- Uses module-level objects (`nodePostionObj`, `edgeObj`) for state tracking
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## STAGE 2: Theme Config Update
|
|
119
|
+
|
|
120
|
+
**Status**: No theme config changes required
|
|
121
|
+
|
|
122
|
+
**Reason**: No tokenizable Antd style overrides found. The component uses `@antv/x6` Graph library (not Ant Design components), and the only style override (`.anticon` margin) is non-tokenizable and documented with `// OVERRIDE:` comment in `styles.scss`.
|
|
123
|
+
|
|
124
|
+
**Validation**: Cross-referenced with Stage 1 analysis - confirmed no tokenizable overrides exist.
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## STAGE 3: Implementation Complete
|
|
129
|
+
|
|
130
|
+
All files have been created/updated:
|
|
131
|
+
- ✅ `types.ts` - TypeScript interfaces created
|
|
132
|
+
- ✅ `styles.scss` - Updated with `// OVERRIDE:` comment for `.anticon`
|
|
133
|
+
- ✅ `index.tsx` - PropTypes removed, defaultProps removed, TypeScript types used, CSS Modules implemented
|
|
134
|
+
- ✅ `README.md` - Migration documentation created
|
|
135
|
+
- ✅ `package.json` - Added `@antv/x6` and `@antv/x6-react-shape` dependencies
|
|
136
|
+
- ✅ `components/index.ts` - Export added
|
|
137
|
+
|
|
138
|
+
**Migration Status**: ✅ COMPLETE
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# CapLevelGraphRenderer
|
|
2
|
+
|
|
3
|
+
Graph renderer component that displays nodes with custom React components and draws level-by-level backward edges using the @antv/x6 Graph library.
|
|
4
|
+
|
|
5
|
+
## Migration (Antd v3 → v6)
|
|
6
|
+
|
|
7
|
+
- **Antd usage**: This component does **not** use any Ant Design components directly. It uses the `@antv/x6` Graph library for rendering. The component uses Cap UI components (`CapButton`, `CapIcon`) for pagination controls. No Antd theme config or API changes apply.
|
|
8
|
+
- **PropTypes removed**: All runtime PropTypes were removed and replaced with TypeScript types from `types.ts`.
|
|
9
|
+
- **defaultProps removed**: All `defaultProps` were removed and converted to destructuring with default values in the function signature.
|
|
10
|
+
- **Styles**: `styles.scss` uses CSS Modules with one `:global` override for Ant Design icon spacing (with mandatory `// OVERRIDE:` comment).
|
|
11
|
+
|
|
12
|
+
## Props
|
|
13
|
+
|
|
14
|
+
See `types.ts` for full interfaces. Main props:
|
|
15
|
+
|
|
16
|
+
| Prop | Type | Description |
|
|
17
|
+
|------|------|-------------|
|
|
18
|
+
| `nodes` | `GraphNode[]` | Array of nodes to render. Each node requires `id`, `component`, `height`, and optionally `props` and `toolTip`. Default: `[]` |
|
|
19
|
+
| `graphId` | `string` | **Required.** Unique identifier for the graph container DOM element. |
|
|
20
|
+
| `connections` | `GraphConnection[]` | Array of connections between nodes. Each connection has `sourceId` and `targetId`. Default: `[]` |
|
|
21
|
+
| `graphWidth` | `number \| string` | Width of the graph container. Default: `'500px'` |
|
|
22
|
+
| `graphHeight` | `number \| string` | Height of the graph container. Default: `'500px'` |
|
|
23
|
+
| `showToolTip` | `boolean` | Whether to show tooltips on edges. Default: `false` |
|
|
24
|
+
| `allowForwardArrowTooltip` | `boolean` | Whether to allow tooltips on forward arrows. Default: `false` |
|
|
25
|
+
| `allowReverseArrowTooltip` | `boolean` | Whether to allow tooltips on reverse arrows. Default: `false` |
|
|
26
|
+
| `defaultEleWidth` | `number` | Default width for each node element. Default: `100` |
|
|
27
|
+
| `defaultEleDistance` | `number` | Default distance between node elements. Default: `20` |
|
|
28
|
+
| `offsetHeight` | `number` | Offset height for connection lines from node top. Default: `20` |
|
|
29
|
+
| `offsetLineDistance` | `number` | Offset distance for reverse connection lines. Default: `18` |
|
|
30
|
+
| `defaultStartX` | `number` | Default starting X coordinate. Default: `0` |
|
|
31
|
+
| `defaultStartY` | `number` | Default starting Y coordinate. Default: `0` |
|
|
32
|
+
| `lineStrokeColor` | `string` | Color for connection lines. Default: `'gray'` |
|
|
33
|
+
| `forwardConnProps` | `Record<string, unknown>` | Props to apply to forward connections. Default: `{}` |
|
|
34
|
+
| `reverseConnProps` | `Record<string, unknown>` | Props to apply to reverse connections. Default: `{}` |
|
|
35
|
+
| `scrollerProps` | `Record<string, unknown>` | Props to pass to the x6 scroller. Default: `{}` |
|
|
36
|
+
| `scrollClassName` | `string` | CSS class name for the scroller. Default: `''` |
|
|
37
|
+
| `graphStyles` | `React.CSSProperties` | Inline styles for the graph container. Default: `{}` |
|
|
38
|
+
| `containerStyles` | `React.CSSProperties` | Inline styles for the container wrapper. Default: `{}` |
|
|
39
|
+
| `className` | `string` | Additional CSS class name. Default: `''` |
|
|
40
|
+
|
|
41
|
+
## Usage
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import CapLevelGraphRenderer from '@capillarytech/blaze-ui/components/CapLevelGraphRenderer';
|
|
45
|
+
import type { GraphNode, GraphConnection } from '@capillarytech/blaze-ui/components/CapLevelGraphRenderer/types';
|
|
46
|
+
|
|
47
|
+
const MyComponent = () => {
|
|
48
|
+
const nodes: GraphNode[] = [
|
|
49
|
+
{
|
|
50
|
+
id: 'tier1',
|
|
51
|
+
component: MyCustomComponent,
|
|
52
|
+
height: 295,
|
|
53
|
+
props: { label: 'Tier 1' },
|
|
54
|
+
toolTip: 'First Tier',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'tier2',
|
|
58
|
+
component: MyCustomComponent,
|
|
59
|
+
height: 500,
|
|
60
|
+
props: { label: 'Tier 2' },
|
|
61
|
+
toolTip: 'Second Tier',
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
const connections: GraphConnection[] = [
|
|
66
|
+
{ sourceId: 'tier2', targetId: 'tier1' },
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<CapLevelGraphRenderer
|
|
71
|
+
graphId="my-graph"
|
|
72
|
+
nodes={nodes}
|
|
73
|
+
connections={connections}
|
|
74
|
+
graphWidth="800px"
|
|
75
|
+
graphHeight="600px"
|
|
76
|
+
showToolTip={true}
|
|
77
|
+
allowForwardArrowTooltip={true}
|
|
78
|
+
allowReverseArrowTooltip={true}
|
|
79
|
+
/>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Features
|
|
85
|
+
|
|
86
|
+
- **Custom Node Components**: Each node can render a custom React component
|
|
87
|
+
- **Forward Connections**: Automatically draws forward connections between adjacent nodes
|
|
88
|
+
- **Reverse Connections**: Calculates and draws reverse connections level-by-level to avoid overlaps
|
|
89
|
+
- **Pagination**: Built-in pagination controls for horizontal scrolling
|
|
90
|
+
- **Tooltips**: Optional tooltips on edges (forward and reverse arrows)
|
|
91
|
+
- **Customizable Styling**: Supports custom styles for graph container, connections, and scroller
|
|
92
|
+
|
|
93
|
+
## Breaking Changes
|
|
94
|
+
|
|
95
|
+
None. This component did not use Ant Design components or deprecated APIs.
|
|
96
|
+
|
|
97
|
+
## Dependencies
|
|
98
|
+
|
|
99
|
+
- `@antv/x6`: Graph rendering library (version: ^1.12.4)
|
|
100
|
+
- `@antv/x6-react-shape`: React shape plugin for x6 (version: ^1.2.3)
|
|
101
|
+
- `classnames`, `lodash` (already in blaze-ui dependencies)
|
|
102
|
+
|
|
103
|
+
## Style Overrides
|
|
104
|
+
|
|
105
|
+
The component uses one `:global` override for Ant Design icon spacing:
|
|
106
|
+
|
|
107
|
+
```scss
|
|
108
|
+
// OVERRIDE: Specific icon spacing override - no token available for nested icon margin within button
|
|
109
|
+
:global {
|
|
110
|
+
& > span + .anticon {
|
|
111
|
+
margin: 0;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
This override is necessary because there's no design token available for nested icon margin within button components.
|
|
117
|
+
|
|
118
|
+
## Notes
|
|
119
|
+
|
|
120
|
+
- The component requires a DOM element with the specified `graphId` to exist before rendering
|
|
121
|
+
- The component uses module-level objects (`nodePostionObj`, `edgeObj`) for state tracking
|
|
122
|
+
- Reverse connections are calculated using a level-based algorithm to prevent overlaps
|
|
123
|
+
- The graph instance is managed via React refs
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Storybook Story Creation Analysis: CapLevelGraphRenderer
|
|
2
|
+
|
|
3
|
+
## STAGE 0: Analysis
|
|
4
|
+
|
|
5
|
+
### 1. Story File Status
|
|
6
|
+
- [x] Story exists: **NO** → Created new story file at `blaze-ui/stories/CapLevelGraphRenderer.stories.tsx`
|
|
7
|
+
|
|
8
|
+
### 2. Component Props (from types.ts)
|
|
9
|
+
|
|
10
|
+
| Prop | Type | Required | Control Type | Notes |
|
|
11
|
+
|------|------|----------|--------------|-------|
|
|
12
|
+
| `graphId` | `string` | Yes | text | Required prop - unique DOM element ID |
|
|
13
|
+
| `nodes` | `GraphNode[]` | No | object | Array of nodes with component, height, props, toolTip |
|
|
14
|
+
| `connections` | `GraphConnection[]` | No | object | Array of connections with sourceId, targetId |
|
|
15
|
+
| `className` | `string` | No | text | Additional CSS class |
|
|
16
|
+
| `graphWidth` | `number \| string` | No | text | Width of graph container |
|
|
17
|
+
| `graphHeight` | `number \| string` | No | text | Height of graph container |
|
|
18
|
+
| `showToolTip` | `boolean` | No | boolean | Enable tooltips on edges |
|
|
19
|
+
| `allowForwardArrowTooltip` | `boolean` | No | boolean | Enable tooltips on forward arrows |
|
|
20
|
+
| `allowReverseArrowTooltip` | `boolean` | No | boolean | Enable tooltips on reverse arrows |
|
|
21
|
+
| `offsetHeight` | `number` | No | number | Connection line offset from node top |
|
|
22
|
+
| `defaultStartX` | `number` | No | number | Starting X coordinate |
|
|
23
|
+
| `defaultStartY` | `number` | No | number | Starting Y coordinate |
|
|
24
|
+
| `defaultEleWidth` | `number` | No | number | Default node element width |
|
|
25
|
+
| `defaultEleDistance` | `number` | No | number | Distance between node elements |
|
|
26
|
+
| `offsetLineDistance` | `number` | No | number | Offset for reverse connection lines |
|
|
27
|
+
| `lineStrokeColor` | `string` | No | color | Color for connection lines |
|
|
28
|
+
| `graphStyles` | `React.CSSProperties` | No | object | Inline styles for graph container |
|
|
29
|
+
| `containerStyles` | `React.CSSProperties` | No | object | Inline styles for container wrapper |
|
|
30
|
+
| `scrollerProps` | `Record<string, unknown>` | No | object | Props for x6 scroller |
|
|
31
|
+
| `scrollClassName` | `string` | No | text | CSS class for scroller |
|
|
32
|
+
| `forwardConnProps` | `Record<string, unknown>` | No | object | Props for forward connections |
|
|
33
|
+
| `reverseConnProps` | `Record<string, unknown>` | No | object | Props for reverse connections |
|
|
34
|
+
|
|
35
|
+
### 3. Error Story Decision
|
|
36
|
+
- [x] Component has error props/states: **NO**
|
|
37
|
+
- [x] Error story needed: **NO**
|
|
38
|
+
- **Decision**: Will create only Default + Custom (2 stories)
|
|
39
|
+
|
|
40
|
+
**Reasoning**: Component doesn't have error handling props or error states. It's a graph renderer that requires valid data (nodes, connections) but doesn't expose error states to consumers.
|
|
41
|
+
|
|
42
|
+
### 4. State Requirements
|
|
43
|
+
- [x] Needs state management: **NO**
|
|
44
|
+
- [x] State type: N/A
|
|
45
|
+
|
|
46
|
+
**Reasoning**: Component is primarily presentational. It renders nodes and connections based on props. No internal state management needed in stories since the component manages its own graph state internally.
|
|
47
|
+
|
|
48
|
+
### 5. Special Considerations
|
|
49
|
+
|
|
50
|
+
**Mock Components**: Created `MockNodeComponent` to render inside graph nodes since nodes require React components.
|
|
51
|
+
|
|
52
|
+
**Unique graphId**: Each story render generates a unique `graphId` to avoid DOM conflicts when multiple stories render simultaneously.
|
|
53
|
+
|
|
54
|
+
**Complex Props**: Some props like `nodes` and `connections` are complex objects that require mock data. Provided default arrays for Default story and comprehensive examples for Custom story.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## STAGE 1: Implementation Complete
|
|
59
|
+
|
|
60
|
+
✅ **File Created**: `blaze-ui/stories/CapLevelGraphRenderer.stories.tsx`
|
|
61
|
+
|
|
62
|
+
✅ **Story Count**: 2 stories (Default, Custom)
|
|
63
|
+
|
|
64
|
+
✅ **Story Names**: Default, Custom
|
|
65
|
+
|
|
66
|
+
✅ **CSF 3.0 Format**: Uses `Meta<typeof CapLevelGraphRenderer>` and `StoryObj<typeof CapLevelGraphRenderer>`
|
|
67
|
+
|
|
68
|
+
✅ **All Props in argTypes**: All 20 props configured with appropriate controls and descriptions
|
|
69
|
+
|
|
70
|
+
✅ **Default Story**: Minimal args with basic nodes and connections
|
|
71
|
+
|
|
72
|
+
✅ **Custom Story**: All props with realistic values, includes state indicator showing configuration
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Validation Checklist
|
|
77
|
+
|
|
78
|
+
### Critical (Auto-Reject if Failed)
|
|
79
|
+
- [x] File: `blaze-ui/stories/CapLevelGraphRenderer.stories.tsx` (exact path)
|
|
80
|
+
- [x] Story count: 2 (matches Stage 0 decision)
|
|
81
|
+
- [x] Story names: Default, Custom
|
|
82
|
+
- [x] Format: CSF 3.0 with `Meta<typeof>` and `StoryObj<typeof>`
|
|
83
|
+
- [x] No other files modified
|
|
84
|
+
|
|
85
|
+
### Quality
|
|
86
|
+
- [x] Stage 0 analysis completed
|
|
87
|
+
- [x] All props from Stage 0 in argTypes
|
|
88
|
+
- [x] Default: Minimal args with basic functionality
|
|
89
|
+
- [x] Custom: ALL props with state indicator
|
|
90
|
+
- [x] Mock components created for node rendering
|
|
91
|
+
- [x] Unique graphId generation to avoid conflicts
|
|
92
|
+
- [x] TypeScript compiles with no errors
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
**Status**: ✅ COMPLETE
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ToolsView } from '@antv/x6';
|
|
2
|
+
import { Root } from 'react-dom/client';
|
|
3
|
+
/**
|
|
4
|
+
* Custom tooltip tool for x6 graph edges
|
|
5
|
+
* Extends ToolsView.ToolItem to provide tooltip functionality on edge hover
|
|
6
|
+
*
|
|
7
|
+
* Note: Uses type assertions for @antv/x6 properties as the library's TypeScript
|
|
8
|
+
* definitions may not fully expose all ToolItem properties.
|
|
9
|
+
*/
|
|
10
|
+
declare class TooltipTool extends ToolsView.ToolItem {
|
|
11
|
+
/** DOM element for tooltip rendering */
|
|
12
|
+
knob: HTMLElement;
|
|
13
|
+
/** Delay in milliseconds before showing/hiding tooltip */
|
|
14
|
+
delay: number;
|
|
15
|
+
/** Current tooltip visibility state */
|
|
16
|
+
tooltipVisible: boolean;
|
|
17
|
+
/** Timer reference for delayed tooltip operations */
|
|
18
|
+
timer?: number;
|
|
19
|
+
/** React root instance for rendering tooltip */
|
|
20
|
+
root?: Root;
|
|
21
|
+
constructor(props: Record<string, unknown>);
|
|
22
|
+
render(): this;
|
|
23
|
+
toggleTooltip(visible: boolean): void;
|
|
24
|
+
updatePosition(e?: MouseEvent): void;
|
|
25
|
+
onMouseLeave(): void;
|
|
26
|
+
onMouseMove: (e: MouseEvent) => void;
|
|
27
|
+
delegateEvents(): this;
|
|
28
|
+
onRemove(): void;
|
|
29
|
+
}
|
|
30
|
+
export default TooltipTool;
|
|
31
|
+
//# sourceMappingURL=Tooltip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../components/CapLevelGraphRenderer/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAc,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAMpD;;;;;;GAMG;AACH,cAAM,WAAY,SAAQ,SAAS,CAAC,QAAQ;IAC1C,wCAAwC;IACxC,IAAI,EAAG,WAAW,CAAC;IAEnB,0DAA0D;IAC1D,KAAK,EAAE,MAAM,CAAC;IAEd,uCAAuC;IACvC,cAAc,EAAE,OAAO,CAAC;IAExB,qDAAqD;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,gDAAgD;IAChD,IAAI,CAAC,EAAE,IAAI,CAAC;gBAEA,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAM1C,MAAM,IAAI,IAAI;IAWd,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAkBrC,cAAc,CAAC,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI;IAepC,YAAY,IAAI,IAAI;IAWpB,WAAW,GAAI,GAAG,UAAU,KAAG,IAAI,CAWjC;IAEF,cAAc,IAAI,IAAI;IAMtB,QAAQ,IAAI,IAAI;CAWjB;AAcD,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Migration Analysis Report: Tooltip.tsx
|
|
2
|
+
|
|
3
|
+
## STAGE 1: Pre-Analysis
|
|
4
|
+
|
|
5
|
+
### Analysis Report for Tooltip.tsx
|
|
6
|
+
|
|
7
|
+
#### 1. Antd Style Overrides Found
|
|
8
|
+
|
|
9
|
+
| Line # | Old Override | Can Tokenize? | Token Path | Token Value | Override Reason |
|
|
10
|
+
|--------|-------------|---------------|------------|-------------|-----------------|
|
|
11
|
+
| N/A | None | N/A | N/A | N/A | No Antd style overrides found |
|
|
12
|
+
|
|
13
|
+
**Tokenizable overrides**: 0
|
|
14
|
+
**Non-tokenizable overrides**: 0
|
|
15
|
+
**Status**: No Antd style overrides found - will skip theme config update
|
|
16
|
+
|
|
17
|
+
#### 2. API Breaking Changes
|
|
18
|
+
|
|
19
|
+
| Old API | New API | Affected Props |
|
|
20
|
+
|---------|---------|----------------|
|
|
21
|
+
| `visible` (CapTooltip) | `open` (CapTooltip) | Line 27: `visible` prop used |
|
|
22
|
+
|
|
23
|
+
**Note**: The file uses deprecated `visible` prop on CapTooltip component. Should use `open` instead.
|
|
24
|
+
|
|
25
|
+
#### 3. Backward Compatibility Plan
|
|
26
|
+
|
|
27
|
+
| Deprecated Prop | Fallback Logic |
|
|
28
|
+
|----------------|----------------|
|
|
29
|
+
| `visible` (CapTooltip) | Use `open` prop instead (CapTooltip handles backward compatibility internally) |
|
|
30
|
+
|
|
31
|
+
#### 4. Type Definitions Needed
|
|
32
|
+
|
|
33
|
+
- **TooltipToolOptions interface**: Type for constructor props/options
|
|
34
|
+
- `tooltip?: string` - Tooltip text content
|
|
35
|
+
- **Class property types**:
|
|
36
|
+
- `knob: HTMLElement` - DOM element for tooltip rendering
|
|
37
|
+
- `delay: number` - Delay in milliseconds
|
|
38
|
+
- `tooltipVisible: boolean` - Current tooltip visibility state
|
|
39
|
+
- `timer: ReturnType<typeof setTimeout>` - Timer reference
|
|
40
|
+
- **Method parameter types**:
|
|
41
|
+
- `toggleTooltip(visible: boolean): void`
|
|
42
|
+
- `updatePosition(e?: MouseEvent): void`
|
|
43
|
+
- `onMouseMove(e: MouseEvent): void`
|
|
44
|
+
|
|
45
|
+
#### 5. PropTypes Removal
|
|
46
|
+
|
|
47
|
+
- [x] Component uses PropTypes: **NO**
|
|
48
|
+
- [x] PropTypes file exists: **NO**
|
|
49
|
+
- [x] PropTypes imports found: **NO**
|
|
50
|
+
- [x] Component.propTypes assignments found: **NO**
|
|
51
|
+
- **Action Required**: None - no PropTypes found
|
|
52
|
+
|
|
53
|
+
#### 6. DefaultProps Removal
|
|
54
|
+
|
|
55
|
+
- [x] Component uses defaultProps: **NO**
|
|
56
|
+
- [x] Component.defaultProps assignments found: **NO**
|
|
57
|
+
- [x] Old function syntax with props parameter: **NO** (class-based component)
|
|
58
|
+
- [x] Default values assigned inside function body: **YES** (line 10: `this.delay = 100`)
|
|
59
|
+
- **Action Required**: None - defaultProps not used, default value assignment is acceptable for class properties
|
|
60
|
+
|
|
61
|
+
#### 7. External Package Dependencies
|
|
62
|
+
|
|
63
|
+
**External packages found**:
|
|
64
|
+
- `@antv/x6` - Already in package.json (added in main component migration)
|
|
65
|
+
- `react-dom/client` - Already available (React dependency)
|
|
66
|
+
|
|
67
|
+
**Package status**:
|
|
68
|
+
- All dependencies already present
|
|
69
|
+
|
|
70
|
+
#### 8. Component-Specific Notes
|
|
71
|
+
|
|
72
|
+
- Class-based component extending `ToolsView.ToolItem` from @antv/x6
|
|
73
|
+
- Uses React 18 `createRoot` API (already migrated)
|
|
74
|
+
- Uses deprecated `visible` prop on CapTooltip - needs update to `open`
|
|
75
|
+
- Missing TypeScript types for class properties and method parameters
|
|
76
|
+
- Uses DOM manipulation directly (acceptable for x6 tool implementation)
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## STAGE 2: Theme Config Update
|
|
81
|
+
|
|
82
|
+
**Status**: No theme config changes required
|
|
83
|
+
|
|
84
|
+
**Reason**: No Antd style overrides found. Component uses @antv/x6 ToolsView.ToolItem and CapTooltip component.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## STAGE 3: Implementation Required
|
|
89
|
+
|
|
90
|
+
1. **Add TypeScript types**:
|
|
91
|
+
- Define interface for TooltipToolOptions
|
|
92
|
+
- Add type annotations for class properties
|
|
93
|
+
- Add type annotations for method parameters
|
|
94
|
+
|
|
95
|
+
2. **Fix deprecated prop usage**:
|
|
96
|
+
- Change `visible` to `open` on CapTooltip (line 27)
|
|
97
|
+
|
|
98
|
+
3. **Improve type safety**:
|
|
99
|
+
- Add proper types for DOM elements and event handlers
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## STAGE 3: Implementation Complete
|
|
104
|
+
|
|
105
|
+
All changes have been implemented:
|
|
106
|
+
- ✅ **TypeScript types added**: Created interfaces for TooltipToolOptions, GraphInstance, and CellViewInstance
|
|
107
|
+
- ✅ **Class property types**: Added proper types for knob, delay, tooltipVisible, timer, and root
|
|
108
|
+
- ✅ **Method parameter types**: Added types for toggleTooltip, updatePosition, onMouseMove, onMouseLeave
|
|
109
|
+
- ✅ **Deprecated prop fixed**: Changed `visible` to `open` on CapTooltip (line 84)
|
|
110
|
+
- ✅ **Type safety improved**: Used type assertions for @antv/x6 properties that aren't fully typed
|
|
111
|
+
- ✅ **Cleanup added**: Added proper cleanup in onRemove method (unmount React root, clear timer)
|
|
112
|
+
|
|
113
|
+
**Key Changes**:
|
|
114
|
+
1. Fixed deprecated `visible` prop → `open` prop on CapTooltip
|
|
115
|
+
2. Added TypeScript interfaces for options and x6 instance types
|
|
116
|
+
3. Added proper type annotations for all class properties and methods
|
|
117
|
+
4. Improved cleanup with React root unmounting
|
|
118
|
+
5. Used type assertions for @antv/x6 properties that aren't fully exposed in TypeScript definitions
|
|
119
|
+
|
|
120
|
+
**Migration Status**: ✅ COMPLETE
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* CapLevelGraphRenderer
|
|
4
|
+
*
|
|
5
|
+
* It render graph with custom node and draw level by level backward edge
|
|
6
|
+
*
|
|
7
|
+
* Mock Data
|
|
8
|
+
* nodes = [{ id: 'tier1', height: 295 }, { id: 'tier2', height: 500 }]
|
|
9
|
+
* connections = [ { sourceId: 'tier2', targetId: 'tier1' }]
|
|
10
|
+
*/
|
|
11
|
+
import '@antv/x6-react-shape';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import type { CapLevelGraphRendererProps } from './types';
|
|
14
|
+
declare const CapLevelGraphRenderer: React.FC<CapLevelGraphRendererProps>;
|
|
15
|
+
export default CapLevelGraphRenderer;
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../components/CapLevelGraphRenderer/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,sBAAsB,CAAC;AAG9B,OAAO,KAAmD,MAAM,OAAO,CAAC;AAOxE,OAAO,KAAK,EACV,0BAA0B,EAK3B,MAAM,SAAS,CAAC;AAYjB,QAAA,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CA0b/D,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|