@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
|
@@ -4974,11 +4974,30 @@ var _client = __webpack_require__(5338);
|
|
|
4974
4974
|
var _CapTooltip = _interopRequireDefault(__webpack_require__(85684));
|
|
4975
4975
|
var _jsxRuntime = __webpack_require__(74848);
|
|
4976
4976
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
4977
|
+
/**
|
|
4978
|
+
* Custom tooltip tool for x6 graph edges
|
|
4979
|
+
* Extends ToolsView.ToolItem to provide tooltip functionality on edge hover
|
|
4980
|
+
*
|
|
4981
|
+
* Note: Uses type assertions for @antv/x6 properties as the library's TypeScript
|
|
4982
|
+
* definitions may not fully expose all ToolItem properties.
|
|
4983
|
+
*/
|
|
4977
4984
|
class TooltipTool extends _x.ToolsView.ToolItem {
|
|
4985
|
+
/** DOM element for tooltip rendering */
|
|
4986
|
+
|
|
4987
|
+
/** Delay in milliseconds before showing/hiding tooltip */
|
|
4988
|
+
|
|
4989
|
+
/** Current tooltip visibility state */
|
|
4990
|
+
|
|
4991
|
+
/** Timer reference for delayed tooltip operations */
|
|
4992
|
+
|
|
4993
|
+
/** React root instance for rendering tooltip */
|
|
4994
|
+
|
|
4978
4995
|
constructor(props) {
|
|
4979
4996
|
super(props);
|
|
4980
4997
|
this.onMouseMove = e => {
|
|
4981
|
-
|
|
4998
|
+
if (this.timer) {
|
|
4999
|
+
window.clearTimeout(this.timer);
|
|
5000
|
+
}
|
|
4982
5001
|
this.updatePosition(e);
|
|
4983
5002
|
this.timer = window.setTimeout(() => {
|
|
4984
5003
|
if (this.tooltipVisible) {
|
|
@@ -4988,24 +5007,31 @@ class TooltipTool extends _x.ToolsView.ToolItem {
|
|
|
4988
5007
|
}, this.delay);
|
|
4989
5008
|
};
|
|
4990
5009
|
this.delay = 100;
|
|
5010
|
+
this.tooltipVisible = false;
|
|
4991
5011
|
}
|
|
4992
5012
|
render() {
|
|
4993
5013
|
super.render();
|
|
4994
5014
|
this.knob = _x.ToolsView.createElement('div', false);
|
|
4995
5015
|
this.knob.style.position = 'absolute';
|
|
4996
|
-
this.container
|
|
5016
|
+
const container = this.container;
|
|
5017
|
+
container.appendChild(this.knob);
|
|
4997
5018
|
this.updatePosition();
|
|
4998
5019
|
document.addEventListener('mousemove', this.onMouseMove);
|
|
4999
5020
|
return this;
|
|
5000
5021
|
}
|
|
5001
5022
|
toggleTooltip(visible) {
|
|
5002
|
-
|
|
5023
|
+
if (!this.root) {
|
|
5024
|
+
this.root = (0, _client.createRoot)(this.knob);
|
|
5025
|
+
}
|
|
5003
5026
|
if (visible) {
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5027
|
+
const tooltipText = this.options.tooltip;
|
|
5028
|
+
this.root.render(/*#__PURE__*/(0, _jsxRuntime.jsx)(_CapTooltip.default, {
|
|
5029
|
+
title: tooltipText,
|
|
5030
|
+
open: true,
|
|
5007
5031
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {})
|
|
5008
5032
|
}));
|
|
5033
|
+
} else {
|
|
5034
|
+
this.root.render(/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {}));
|
|
5009
5035
|
}
|
|
5010
5036
|
this.tooltipVisible = visible;
|
|
5011
5037
|
}
|
|
@@ -5013,8 +5039,9 @@ class TooltipTool extends _x.ToolsView.ToolItem {
|
|
|
5013
5039
|
const {
|
|
5014
5040
|
style
|
|
5015
5041
|
} = this.knob;
|
|
5016
|
-
|
|
5017
|
-
|
|
5042
|
+
const graph = this.graph;
|
|
5043
|
+
if (e && graph) {
|
|
5044
|
+
const p = graph.clientToGraph(e.clientX, e.clientY);
|
|
5018
5045
|
style.display = 'block';
|
|
5019
5046
|
style.left = p.x + "px";
|
|
5020
5047
|
style.top = p.y + "px";
|
|
@@ -5026,18 +5053,36 @@ class TooltipTool extends _x.ToolsView.ToolItem {
|
|
|
5026
5053
|
}
|
|
5027
5054
|
onMouseLeave() {
|
|
5028
5055
|
this.updatePosition();
|
|
5029
|
-
|
|
5030
|
-
|
|
5056
|
+
if (this.timer) {
|
|
5057
|
+
window.clearTimeout(this.timer);
|
|
5058
|
+
}
|
|
5059
|
+
this.timer = window.setTimeout(() => {
|
|
5060
|
+
this.toggleTooltip(false);
|
|
5061
|
+
}, this.delay);
|
|
5031
5062
|
document.removeEventListener('mousemove', this.onMouseMove);
|
|
5032
5063
|
}
|
|
5033
5064
|
delegateEvents() {
|
|
5034
|
-
|
|
5065
|
+
const cellView = this.cellView;
|
|
5066
|
+
cellView.on('cell:mouseleave', this.onMouseLeave, this);
|
|
5035
5067
|
return super.delegateEvents();
|
|
5036
5068
|
}
|
|
5037
5069
|
onRemove() {
|
|
5038
|
-
|
|
5070
|
+
const cellView = this.cellView;
|
|
5071
|
+
cellView.off('cell:mouseleave', this.onMouseLeave);
|
|
5072
|
+
if (this.timer) {
|
|
5073
|
+
window.clearTimeout(this.timer);
|
|
5074
|
+
}
|
|
5075
|
+
if (this.root) {
|
|
5076
|
+
this.root.unmount();
|
|
5077
|
+
}
|
|
5078
|
+
document.removeEventListener('mousemove', this.onMouseMove);
|
|
5039
5079
|
}
|
|
5040
5080
|
}
|
|
5081
|
+
|
|
5082
|
+
/**
|
|
5083
|
+
* Type for TooltipTool config method
|
|
5084
|
+
*/
|
|
5085
|
+
|
|
5041
5086
|
TooltipTool.config({
|
|
5042
5087
|
tagName: 'div',
|
|
5043
5088
|
isSVGElement: false
|
|
@@ -12639,15 +12684,14 @@ var ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ = __webpack_require__(31601);
|
|
|
12639
12684
|
var ___CSS_LOADER_API_IMPORT___ = __webpack_require__(76314);
|
|
12640
12685
|
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);
|
|
12641
12686
|
// Module
|
|
12642
|
-
___CSS_LOADER_EXPORT___.push([module.id, `.cap-level-graph-renderer-v2 .level-graph-pagination-container,.cap-level-graph-renderer-v2 .level-graph-pagination-row,.cap-level-graph-renderer-v2 .level-graph-pagination-left,.cap-level-graph-renderer-v2 .level-graph-pagination-right{display:flex}.cap-level-graph-renderer-v2 .level-graph-pagination-row{justify-content:flex-end;height:1.714rem;margin-bottom:2.571rem}.cap-level-graph-renderer-v2 .level-graph-pagination-row .level-graph-pagination-left{margin-right:1.714rem}.cap-level-graph-renderer-v2 .level-graph-pagination-row .level-graph-pagination-left>span
|
|
12687
|
+
___CSS_LOADER_EXPORT___.push([module.id, `.cap-level-graph-renderer-v2 .level-graph-pagination-container,.cap-level-graph-renderer-v2 .level-graph-pagination-row,.cap-level-graph-renderer-v2 .level-graph-pagination-left,.cap-level-graph-renderer-v2 .level-graph-pagination-right{display:flex}.cap-level-graph-renderer-v2 .level-graph-pagination-row{justify-content:flex-end;height:1.714rem;margin-bottom:2.571rem}.cap-level-graph-renderer-v2 .level-graph-pagination-row .level-graph-pagination-left{margin-right:1.714rem}.cap-level-graph-renderer-v2 .level-graph-pagination-row .level-graph-pagination-left > span + .anticon{margin:0}.cap-level-graph-renderer-v2 .level-graph-pagination-row .level-graph-pagination-left,.cap-level-graph-renderer-v2 .level-graph-pagination-row .level-graph-pagination-right{justify-content:center;align-items:center;min-width:fit-content;height:100%;padding:0}`, ""]);
|
|
12643
12688
|
// Exports
|
|
12644
12689
|
___CSS_LOADER_EXPORT___.locals = {
|
|
12645
12690
|
"cap-level-graph-renderer-v2": `cap-level-graph-renderer-v2`,
|
|
12646
12691
|
"level-graph-pagination-container": `level-graph-pagination-container`,
|
|
12647
12692
|
"level-graph-pagination-row": `level-graph-pagination-row`,
|
|
12648
12693
|
"level-graph-pagination-left": `level-graph-pagination-left`,
|
|
12649
|
-
"level-graph-pagination-right": `level-graph-pagination-right
|
|
12650
|
-
"anticon": `anticon`
|
|
12694
|
+
"level-graph-pagination-right": `level-graph-pagination-right`
|
|
12651
12695
|
};
|
|
12652
12696
|
module.exports = ___CSS_LOADER_EXPORT___;
|
|
12653
12697
|
|
|
@@ -17906,11 +17950,10 @@ var _x = __webpack_require__(28890);
|
|
|
17906
17950
|
__webpack_require__(90460);
|
|
17907
17951
|
var _classnames = _interopRequireDefault(__webpack_require__(46942));
|
|
17908
17952
|
var _get = _interopRequireDefault(__webpack_require__(58156));
|
|
17909
|
-
var _propTypes = _interopRequireDefault(__webpack_require__(43363));
|
|
17910
17953
|
var _react = _interopRequireWildcard(__webpack_require__(9206));
|
|
17911
17954
|
var _CapButton = _interopRequireDefault(__webpack_require__(80739));
|
|
17912
17955
|
var _CapIcon = _interopRequireDefault(__webpack_require__(65124));
|
|
17913
|
-
__webpack_require__(50742);
|
|
17956
|
+
var _styles = _interopRequireDefault(__webpack_require__(50742));
|
|
17914
17957
|
var _Tooltip = _interopRequireDefault(__webpack_require__(30405));
|
|
17915
17958
|
var _jsxRuntime = __webpack_require__(74848);
|
|
17916
17959
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
@@ -17924,62 +17967,73 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
17924
17967
|
* Mock Data
|
|
17925
17968
|
* nodes = [{ id: 'tier1', height: 295 }, { id: 'tier2', height: 500 }]
|
|
17926
17969
|
* connections = [ { sourceId: 'tier2', targetId: 'tier1' }]
|
|
17927
|
-
*/
|
|
17970
|
+
*/ // Type for Edge with addTools/removeTools methods (not in @antv/x6 TypeScript definitions)
|
|
17928
17971
|
const nodePostionObj = {};
|
|
17929
17972
|
const edgeObj = {};
|
|
17930
17973
|
const idSeparator = ' ';
|
|
17931
17974
|
const CapLevelGraphRenderer = _ref => {
|
|
17932
17975
|
let {
|
|
17933
|
-
nodes,
|
|
17976
|
+
nodes = [],
|
|
17934
17977
|
graphId,
|
|
17935
|
-
className,
|
|
17936
|
-
graphWidth,
|
|
17937
|
-
|
|
17938
|
-
|
|
17939
|
-
|
|
17940
|
-
|
|
17941
|
-
offsetHeight,
|
|
17942
|
-
defaultStartX,
|
|
17943
|
-
defaultStartY,
|
|
17944
|
-
scrollerProps,
|
|
17945
|
-
|
|
17946
|
-
|
|
17947
|
-
|
|
17948
|
-
|
|
17949
|
-
|
|
17950
|
-
|
|
17951
|
-
|
|
17952
|
-
|
|
17953
|
-
allowForwardArrowTooltip,
|
|
17954
|
-
allowReverseArrowTooltip
|
|
17978
|
+
className = '',
|
|
17979
|
+
graphWidth = '500px',
|
|
17980
|
+
graphHeight = '500px',
|
|
17981
|
+
showToolTip = false,
|
|
17982
|
+
connections = [],
|
|
17983
|
+
graphStyles = {},
|
|
17984
|
+
offsetHeight = 20,
|
|
17985
|
+
defaultStartX = 0,
|
|
17986
|
+
defaultStartY = 0,
|
|
17987
|
+
scrollerProps = {},
|
|
17988
|
+
scrollClassName = '',
|
|
17989
|
+
containerStyles = {},
|
|
17990
|
+
lineStrokeColor = 'gray',
|
|
17991
|
+
defaultEleWidth = 100,
|
|
17992
|
+
defaultEleDistance = 20,
|
|
17993
|
+
offsetLineDistance = 18,
|
|
17994
|
+
forwardConnProps = {},
|
|
17995
|
+
reverseConnProps = {},
|
|
17996
|
+
allowForwardArrowTooltip = false,
|
|
17997
|
+
allowReverseArrowTooltip = false
|
|
17955
17998
|
} = _ref;
|
|
17956
17999
|
const graphRef = (0, _react.useRef)(null);
|
|
17957
18000
|
const [scrollbarPosition, setScrollbarPosition] = (0, _react.useState)(0);
|
|
17958
|
-
const totalAvailWidth = nodes.length * defaultEleWidth + defaultEleDistance * (nodes.length - 1) - parseInt(graphWidth, 10);
|
|
18001
|
+
const totalAvailWidth = nodes.length * defaultEleWidth + defaultEleDistance * (nodes.length - 1) - parseInt(String(graphWidth), 10);
|
|
17959
18002
|
(0, _react.useEffect)(() => {
|
|
17960
|
-
//
|
|
18003
|
+
// Initialize graph and events
|
|
17961
18004
|
initializeGraph();
|
|
17962
18005
|
initializeEvents();
|
|
17963
18006
|
}, []);
|
|
17964
18007
|
(0, _react.useEffect)(() => {
|
|
17965
|
-
// Draw nodes after graph
|
|
18008
|
+
// Draw nodes after graph initialization
|
|
17966
18009
|
drawNodes();
|
|
17967
18010
|
}, [nodes, connections]);
|
|
17968
18011
|
(0, _react.useEffect)(() => {
|
|
17969
|
-
//
|
|
17970
|
-
graphRef.current
|
|
18012
|
+
// Initialize and set scroll position on pagination change
|
|
18013
|
+
if (graphRef.current) {
|
|
18014
|
+
graphRef.current.setScrollbarPosition(scrollbarPosition);
|
|
18015
|
+
}
|
|
17971
18016
|
}, [nodes, connections, scrollbarPosition]);
|
|
17972
18017
|
|
|
17973
|
-
//
|
|
18018
|
+
// Initialize Graph area
|
|
17974
18019
|
const initializeGraph = (0, _react.useCallback)(() => {
|
|
17975
18020
|
if (showToolTip) {
|
|
17976
18021
|
_x.Graph.registerEdgeTool('tooltip', _Tooltip.default, true);
|
|
17977
18022
|
}
|
|
18023
|
+
const container = document.getElementById(graphId);
|
|
18024
|
+
if (!container) {
|
|
18025
|
+
console.error("[CapLevelGraphRenderer] Container with id \"" + graphId + "\" not found");
|
|
18026
|
+
return;
|
|
18027
|
+
}
|
|
18028
|
+
// Convert string width/height to numbers if needed
|
|
18029
|
+
const width = typeof graphWidth === 'string' ? parseInt(graphWidth, 10) : graphWidth;
|
|
18030
|
+
const height = typeof graphHeight === 'string' ? parseInt(graphHeight, 10) : graphHeight;
|
|
17978
18031
|
graphRef.current = new _x.Graph({
|
|
17979
|
-
container
|
|
18032
|
+
container,
|
|
17980
18033
|
resizing: false,
|
|
17981
|
-
width
|
|
17982
|
-
height
|
|
18034
|
+
width,
|
|
18035
|
+
height,
|
|
18036
|
+
// @ts-expect-error - @antv/x6 Graph options may not have complete TypeScript definitions
|
|
17983
18037
|
fitView: true,
|
|
17984
18038
|
scroller: _extends({
|
|
17985
18039
|
padding: 0,
|
|
@@ -17990,7 +18044,7 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
17990
18044
|
}, scrollerProps),
|
|
17991
18045
|
interacting: false
|
|
17992
18046
|
});
|
|
17993
|
-
}, []);
|
|
18047
|
+
}, [graphId, graphWidth, graphHeight, scrollClassName, scrollerProps, showToolTip]);
|
|
17994
18048
|
const drawNodes = (0, _react.useCallback)(function (eleWidth, distance, offsetY) {
|
|
17995
18049
|
if (eleWidth === void 0) {
|
|
17996
18050
|
eleWidth = defaultEleWidth;
|
|
@@ -18001,13 +18055,15 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18001
18055
|
if (offsetY === void 0) {
|
|
18002
18056
|
offsetY = offsetHeight;
|
|
18003
18057
|
}
|
|
18058
|
+
if (!graphRef.current) return;
|
|
18004
18059
|
let nextX = defaultStartX;
|
|
18005
18060
|
nodes.forEach((_ref2, index) => {
|
|
18061
|
+
var _graphRef$current;
|
|
18006
18062
|
let {
|
|
18007
18063
|
id,
|
|
18008
18064
|
component,
|
|
18009
18065
|
height,
|
|
18010
|
-
props,
|
|
18066
|
+
props = {},
|
|
18011
18067
|
toolTip = ''
|
|
18012
18068
|
} = _ref2;
|
|
18013
18069
|
const Component = component;
|
|
@@ -18015,7 +18071,7 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18015
18071
|
const y = defaultStartY;
|
|
18016
18072
|
const endX = nextX + eleWidth;
|
|
18017
18073
|
// draw the node
|
|
18018
|
-
graphRef.current.addNode({
|
|
18074
|
+
(_graphRef$current = graphRef.current) == null || _graphRef$current.addNode({
|
|
18019
18075
|
id,
|
|
18020
18076
|
x,
|
|
18021
18077
|
y,
|
|
@@ -18026,7 +18082,7 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18026
18082
|
zIndex: 2
|
|
18027
18083
|
});
|
|
18028
18084
|
|
|
18029
|
-
// Adding node
|
|
18085
|
+
// Adding node positions to obj
|
|
18030
18086
|
nodePostionObj[id] = {
|
|
18031
18087
|
x,
|
|
18032
18088
|
y,
|
|
@@ -18041,12 +18097,13 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18041
18097
|
nextX = endX + distance;
|
|
18042
18098
|
// Skip connection for last node
|
|
18043
18099
|
if (nodes[index + 1]) {
|
|
18100
|
+
var _graphRef$current2;
|
|
18044
18101
|
// offsetY - Connection offset height from node point
|
|
18045
18102
|
const forwardEdgeId = "" + id + idSeparator + nodes[index + 1].id;
|
|
18046
18103
|
edgeObj[forwardEdgeId] = {
|
|
18047
18104
|
forward: true
|
|
18048
18105
|
};
|
|
18049
|
-
graphRef.current.addEdge({
|
|
18106
|
+
(_graphRef$current2 = graphRef.current) == null || _graphRef$current2.addEdge({
|
|
18050
18107
|
id: forwardEdgeId,
|
|
18051
18108
|
sourcePoint: {
|
|
18052
18109
|
x: endX,
|
|
@@ -18065,12 +18122,13 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18065
18122
|
}
|
|
18066
18123
|
// Forward connection ends
|
|
18067
18124
|
});
|
|
18068
|
-
calculateAndDrawRevConnections(
|
|
18069
|
-
}, [nodes]);
|
|
18125
|
+
calculateAndDrawRevConnections();
|
|
18126
|
+
}, [nodes, defaultEleWidth, defaultEleDistance, offsetHeight, defaultStartX, defaultStartY, lineStrokeColor, forwardConnProps]);
|
|
18070
18127
|
|
|
18071
18128
|
// Calculate levels / Split connections based on level and Draw reverse connection
|
|
18072
18129
|
const calculateAndDrawRevConnections = (0, _react.useCallback)(() => {
|
|
18073
|
-
|
|
18130
|
+
if (!graphRef.current) return;
|
|
18131
|
+
let connectionListTemp = [...connections];
|
|
18074
18132
|
// maintains in and out list for each node
|
|
18075
18133
|
const connectionObj = {};
|
|
18076
18134
|
// maintains connections by level
|
|
@@ -18093,15 +18151,15 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18093
18151
|
return source.id !== sourceId || target.id !== targetId;
|
|
18094
18152
|
});
|
|
18095
18153
|
// check if two nodes have connection or not
|
|
18096
|
-
const
|
|
18097
|
-
if (
|
|
18154
|
+
const isConnection = filterConnection.length !== connectionListTemp.length;
|
|
18155
|
+
if (isConnection) {
|
|
18098
18156
|
// If connection, connections is assigned with filterList to avoid unwanted iteration
|
|
18099
18157
|
connectionListTemp = filterConnection;
|
|
18100
18158
|
if (!lastTargetIndex && levelIndex !== 1) {
|
|
18101
18159
|
lastTargetIndex = targetIndex;
|
|
18102
18160
|
}
|
|
18103
|
-
// Put in next level when two connection get
|
|
18104
|
-
if (targetIndex <= lastTargetIndex && levelIndex !== 1) {
|
|
18161
|
+
// Put in next level when two connection get interacts
|
|
18162
|
+
if (lastTargetIndex !== undefined && targetIndex <= lastTargetIndex && levelIndex !== 1) {
|
|
18105
18163
|
levels.push({
|
|
18106
18164
|
sourceId: source.id,
|
|
18107
18165
|
targetId: target.id
|
|
@@ -18144,8 +18202,8 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18144
18202
|
drawReverseConnections(nodes, connectionObj, levelList);
|
|
18145
18203
|
}, [connections, nodes]);
|
|
18146
18204
|
|
|
18147
|
-
// Get height
|
|
18148
|
-
// This Avoid connection
|
|
18205
|
+
// Get height between two nodes having connection
|
|
18206
|
+
// This Avoid connection overlaps over node
|
|
18149
18207
|
const getMaxHeight = (nodeList, sourceId, targetId) => {
|
|
18150
18208
|
let maxY1 = 0;
|
|
18151
18209
|
let isStart = false;
|
|
@@ -18153,9 +18211,11 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18153
18211
|
let {
|
|
18154
18212
|
id
|
|
18155
18213
|
} = _ref4;
|
|
18214
|
+
const position = nodePostionObj[id];
|
|
18215
|
+
if (!position) return;
|
|
18156
18216
|
const {
|
|
18157
18217
|
y1
|
|
18158
|
-
} =
|
|
18218
|
+
} = position;
|
|
18159
18219
|
if (id === targetId) {
|
|
18160
18220
|
isStart = true;
|
|
18161
18221
|
}
|
|
@@ -18171,38 +18231,45 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18171
18231
|
|
|
18172
18232
|
// Draw reverse connection
|
|
18173
18233
|
const drawReverseConnections = (nodeList, connectionObj, levelList) => {
|
|
18234
|
+
if (!graphRef.current) return;
|
|
18235
|
+
|
|
18174
18236
|
// Iterate level list by level by level
|
|
18175
18237
|
levelList.forEach((levels, index) => {
|
|
18176
18238
|
// Iterate connection on a each level
|
|
18177
18239
|
levels.forEach((_ref5, levelItemIndex) => {
|
|
18240
|
+
var _graphRef$current3;
|
|
18178
18241
|
let {
|
|
18179
18242
|
sourceId,
|
|
18180
18243
|
targetId
|
|
18181
18244
|
} = _ref5;
|
|
18245
|
+
const sourcePosition = nodePostionObj[sourceId];
|
|
18246
|
+
const targetPosition = nodePostionObj[targetId];
|
|
18247
|
+
if (!sourcePosition || !targetPosition) return;
|
|
18248
|
+
|
|
18182
18249
|
// Get source and target total connection count
|
|
18183
18250
|
const srcConCount = connectionObj[sourceId].in.length + connectionObj[sourceId].out.length + 1;
|
|
18184
18251
|
const targetConCount = connectionObj[targetId].in.length + connectionObj[targetId].out.length + 1;
|
|
18185
18252
|
|
|
18186
18253
|
// split connection based on connection count for a node
|
|
18187
|
-
let x =
|
|
18188
|
-
let x1 =
|
|
18254
|
+
let x = sourcePosition.x + sourcePosition.width / srcConCount;
|
|
18255
|
+
let x1 = targetPosition.x1 - targetPosition.width / targetConCount;
|
|
18189
18256
|
if (connectionObj[sourceId].out.includes(targetId)) {
|
|
18190
18257
|
// set start position of connection, based on connection count and arrangements
|
|
18191
|
-
x =
|
|
18258
|
+
x = sourcePosition.x + sourcePosition.width / srcConCount * ([...connectionObj[sourceId].out, ...connectionObj[sourceId].in].indexOf(targetId) + 1);
|
|
18192
18259
|
}
|
|
18193
18260
|
if (connectionObj[targetId].in.includes(sourceId)) {
|
|
18194
18261
|
// set end position of connection, based on connection count and arrangements
|
|
18195
|
-
x1 =
|
|
18262
|
+
x1 = targetPosition.x1 - targetPosition.width / targetConCount * ([...connectionObj[targetId].in, ...connectionObj[targetId].out].indexOf(sourceId) + 1);
|
|
18196
18263
|
}
|
|
18197
18264
|
|
|
18198
|
-
// Handle connection
|
|
18265
|
+
// Handle connection overlaps over node
|
|
18199
18266
|
const maxHeight = getMaxHeight(nodeList, sourceId, targetId);
|
|
18200
18267
|
const {
|
|
18201
18268
|
y1: y
|
|
18202
|
-
} =
|
|
18269
|
+
} = sourcePosition;
|
|
18203
18270
|
const {
|
|
18204
18271
|
y1
|
|
18205
|
-
} =
|
|
18272
|
+
} = targetPosition;
|
|
18206
18273
|
const v1 = {
|
|
18207
18274
|
x,
|
|
18208
18275
|
y: maxHeight + offsetLineDistance * (index + 1)
|
|
@@ -18215,7 +18282,7 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18215
18282
|
edgeObj[reverseEdgeId] = {
|
|
18216
18283
|
reverse: true
|
|
18217
18284
|
};
|
|
18218
|
-
graphRef.current.addEdge({
|
|
18285
|
+
(_graphRef$current3 = graphRef.current) == null || _graphRef$current3.addEdge({
|
|
18219
18286
|
id: reverseEdgeId,
|
|
18220
18287
|
sourcePoint: [x, y],
|
|
18221
18288
|
target: [x1, y1],
|
|
@@ -18232,8 +18299,9 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18232
18299
|
}, reverseConnProps)
|
|
18233
18300
|
}
|
|
18234
18301
|
}).setConnector('jumpover');
|
|
18235
|
-
// adding
|
|
18302
|
+
// adding empty edge at last level
|
|
18236
18303
|
if (levelList.length - 1 === index && levels.length - 1 === levelItemIndex) {
|
|
18304
|
+
var _graphRef$current4;
|
|
18237
18305
|
const v3 = {
|
|
18238
18306
|
x: v1.x - 8,
|
|
18239
18307
|
y: v1.y + 8
|
|
@@ -18242,7 +18310,7 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18242
18310
|
x: v2.x - 8,
|
|
18243
18311
|
y: v2.y + 8
|
|
18244
18312
|
};
|
|
18245
|
-
graphRef.current.addEdge({
|
|
18313
|
+
(_graphRef$current4 = graphRef.current) == null || _graphRef$current4.addEdge({
|
|
18246
18314
|
id: "" + sourceId + idSeparator + targetId + "-end",
|
|
18247
18315
|
sourcePoint: [x, y],
|
|
18248
18316
|
target: [x1, y1],
|
|
@@ -18264,6 +18332,7 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18264
18332
|
});
|
|
18265
18333
|
};
|
|
18266
18334
|
const initializeEvents = (0, _react.useCallback)(() => {
|
|
18335
|
+
if (!graphRef.current) return;
|
|
18267
18336
|
graphRef.current.on('node:mousedown', data => {
|
|
18268
18337
|
const targetElement = (0, _get.default)(data, 'e.target', {});
|
|
18269
18338
|
if (targetElement.tagName === 'INPUT') {
|
|
@@ -18276,12 +18345,13 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18276
18345
|
edge = {}
|
|
18277
18346
|
} = _ref6;
|
|
18278
18347
|
const edgeId = edge.id;
|
|
18279
|
-
if (edgeObj[edgeId] && (allowForwardArrowTooltip && edgeObj[edgeId].forward || allowReverseArrowTooltip && edgeObj[edgeId].reverse)) {
|
|
18348
|
+
if (edgeId && edgeObj[edgeId] && (allowForwardArrowTooltip && edgeObj[edgeId].forward || allowReverseArrowTooltip && edgeObj[edgeId].reverse)) {
|
|
18280
18349
|
const [sourceId, targetId] = edgeId.split(idSeparator);
|
|
18281
18350
|
const sourceToolTip = (0, _get.default)(nodePostionObj, [sourceId, 'toolTip']);
|
|
18282
18351
|
const targetToolTip = (0, _get.default)(nodePostionObj, [targetId, 'toolTip']);
|
|
18283
18352
|
if (sourceToolTip && targetToolTip) {
|
|
18284
|
-
|
|
18353
|
+
// Type assertion needed because @antv/x6 Edge type may not expose addTools in TypeScript definitions
|
|
18354
|
+
edge.addTools == null || edge.addTools([{
|
|
18285
18355
|
name: 'tooltip',
|
|
18286
18356
|
args: {
|
|
18287
18357
|
tooltip: sourceToolTip + " - " + targetToolTip
|
|
@@ -18294,33 +18364,34 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18294
18364
|
let {
|
|
18295
18365
|
edge
|
|
18296
18366
|
} = _ref7;
|
|
18297
|
-
|
|
18367
|
+
// Type assertion needed because @antv/x6 Edge type may not expose removeTools in TypeScript definitions
|
|
18368
|
+
edge.removeTools == null || edge.removeTools();
|
|
18298
18369
|
});
|
|
18299
18370
|
}
|
|
18300
|
-
});
|
|
18371
|
+
}, [showToolTip, allowForwardArrowTooltip, allowReverseArrowTooltip]);
|
|
18301
18372
|
const onPreviousPageClick = (0, _react.useCallback)(() => {
|
|
18302
|
-
let newScrollValue = parseFloat((scrollbarPosition - (defaultEleWidth + defaultEleDistance)).toFixed(5)
|
|
18373
|
+
let newScrollValue = parseFloat((scrollbarPosition - (defaultEleWidth + defaultEleDistance)).toFixed(5));
|
|
18303
18374
|
if (newScrollValue < 0) {
|
|
18304
18375
|
newScrollValue = 0;
|
|
18305
18376
|
}
|
|
18306
18377
|
if (newScrollValue >= 0) setScrollbarPosition(newScrollValue);
|
|
18307
|
-
}, [scrollbarPosition]);
|
|
18378
|
+
}, [scrollbarPosition, defaultEleWidth, defaultEleDistance]);
|
|
18308
18379
|
const onNextPageClick = (0, _react.useCallback)(() => {
|
|
18309
|
-
let newScrollValue = parseFloat((scrollbarPosition + defaultEleWidth + defaultEleDistance).toFixed(5)
|
|
18380
|
+
let newScrollValue = parseFloat((scrollbarPosition + defaultEleWidth + defaultEleDistance).toFixed(5));
|
|
18310
18381
|
if (newScrollValue > totalAvailWidth) {
|
|
18311
18382
|
newScrollValue = totalAvailWidth;
|
|
18312
18383
|
}
|
|
18313
18384
|
if (newScrollValue <= totalAvailWidth) setScrollbarPosition(newScrollValue);
|
|
18314
|
-
}, [nodes, scrollbarPosition]);
|
|
18385
|
+
}, [nodes, scrollbarPosition, defaultEleWidth, defaultEleDistance, totalAvailWidth]);
|
|
18315
18386
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
18316
|
-
className: (0, _classnames.default)('cap-level-graph-renderer-v2', className),
|
|
18387
|
+
className: (0, _classnames.default)(_styles.default['cap-level-graph-renderer-v2'], className),
|
|
18317
18388
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
18318
|
-
className:
|
|
18389
|
+
className: _styles.default['level-graph-pagination-row'],
|
|
18319
18390
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
18320
|
-
className:
|
|
18391
|
+
className: _styles.default['level-graph-pagination-container'],
|
|
18321
18392
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_CapButton.default, {
|
|
18322
18393
|
type: "flat",
|
|
18323
|
-
className: "pointer-cursor level-graph-pagination-left
|
|
18394
|
+
className: "pointer-cursor " + _styles.default['level-graph-pagination-left'],
|
|
18324
18395
|
disabled: scrollbarPosition <= 0,
|
|
18325
18396
|
onClick: onPreviousPageClick,
|
|
18326
18397
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CapIcon.default, {
|
|
@@ -18328,8 +18399,8 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18328
18399
|
})
|
|
18329
18400
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_CapButton.default, {
|
|
18330
18401
|
type: "flat",
|
|
18331
|
-
className: "pointer-cursor level-graph-pagination-right
|
|
18332
|
-
disabled: parseFloat((scrollbarPosition + defaultEleWidth + defaultEleDistance).toFixed(5)
|
|
18402
|
+
className: "pointer-cursor " + _styles.default['level-graph-pagination-right'],
|
|
18403
|
+
disabled: parseFloat((scrollbarPosition + defaultEleWidth + defaultEleDistance).toFixed(5)) > totalAvailWidth,
|
|
18333
18404
|
onClick: onNextPageClick,
|
|
18334
18405
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CapIcon.default, {
|
|
18335
18406
|
type: "chevron-right"
|
|
@@ -18337,7 +18408,7 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18337
18408
|
})]
|
|
18338
18409
|
})
|
|
18339
18410
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
18340
|
-
className:
|
|
18411
|
+
className: _styles.default['graph-renderer-container'],
|
|
18341
18412
|
style: _extends({}, containerStyles),
|
|
18342
18413
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
18343
18414
|
id: graphId,
|
|
@@ -18346,53 +18417,6 @@ const CapLevelGraphRenderer = _ref => {
|
|
|
18346
18417
|
})]
|
|
18347
18418
|
});
|
|
18348
18419
|
};
|
|
18349
|
-
CapLevelGraphRenderer.propTypes = {
|
|
18350
|
-
nodes: _propTypes.default.array,
|
|
18351
|
-
showToolTip: _propTypes.default.bool,
|
|
18352
|
-
className: _propTypes.default.string,
|
|
18353
|
-
connections: _propTypes.default.array,
|
|
18354
|
-
graphStyles: _propTypes.default.object,
|
|
18355
|
-
offsetHeight: _propTypes.default.number,
|
|
18356
|
-
defaultStartX: _propTypes.default.number,
|
|
18357
|
-
defaultStartY: _propTypes.default.number,
|
|
18358
|
-
scrollerProps: _propTypes.default.object,
|
|
18359
|
-
scrollClassName: _propTypes.default.string,
|
|
18360
|
-
containerStyles: _propTypes.default.object,
|
|
18361
|
-
lineStrokeColor: _propTypes.default.string,
|
|
18362
|
-
defaultEleWidth: _propTypes.default.number,
|
|
18363
|
-
reverseConnProps: _propTypes.default.object,
|
|
18364
|
-
forwardConnProps: _propTypes.default.object,
|
|
18365
|
-
defaultEleDistance: _propTypes.default.number,
|
|
18366
|
-
offsetLineDistance: _propTypes.default.number,
|
|
18367
|
-
graphId: _propTypes.default.string.isRequired,
|
|
18368
|
-
graphWidth: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
18369
|
-
graphHeight: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
18370
|
-
allowForwardArrowTooltip: _propTypes.default.bool,
|
|
18371
|
-
allowReverseArrowTooltip: _propTypes.default.bool
|
|
18372
|
-
};
|
|
18373
|
-
CapLevelGraphRenderer.defaultProps = {
|
|
18374
|
-
nodes: [],
|
|
18375
|
-
className: '',
|
|
18376
|
-
graphStyles: {},
|
|
18377
|
-
connections: [],
|
|
18378
|
-
defaultStartX: 0,
|
|
18379
|
-
defaultStartY: 0,
|
|
18380
|
-
offsetHeight: 20,
|
|
18381
|
-
scrollerProps: {},
|
|
18382
|
-
showToolTip: false,
|
|
18383
|
-
containerStyles: {},
|
|
18384
|
-
graphWidth: '500px',
|
|
18385
|
-
scrollClassName: '',
|
|
18386
|
-
graphHeight: '500px',
|
|
18387
|
-
reverseConnProps: {},
|
|
18388
|
-
forwardConnProps: {},
|
|
18389
|
-
defaultEleWidth: 100,
|
|
18390
|
-
defaultEleDistance: 20,
|
|
18391
|
-
offsetLineDistance: 18,
|
|
18392
|
-
lineStrokeColor: 'gray',
|
|
18393
|
-
allowForwardArrowTooltip: false,
|
|
18394
|
-
allowReverseArrowTooltip: false
|
|
18395
|
-
};
|
|
18396
18420
|
var _default = exports["default"] = CapLevelGraphRenderer;
|
|
18397
18421
|
})();
|
|
18398
18422
|
|