@antv/infographic 0.2.11 → 0.2.12
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/infographic.min.js +1 -1
- package/dist/infographic.min.js.map +1 -1
- package/esm/designs/components/Btn.js +15 -4
- package/esm/designs/components/BtnsGroup.js +1 -1
- package/esm/designs/components/Illus.js +15 -3
- package/esm/designs/components/ItemDesc.js +17 -11
- package/esm/designs/components/ItemIcon.js +17 -18
- package/esm/designs/components/ItemLabel.js +17 -11
- package/esm/designs/components/ItemValue.js +17 -12
- package/esm/designs/components/ItemsGroup.js +1 -1
- package/esm/designs/components/ShapesGroup.js +1 -1
- package/esm/designs/components/Title.js +2 -2
- package/esm/designs/decorations/simple-arrow.js +14 -2
- package/esm/designs/decorations/triangle.js +14 -2
- package/esm/designs/defs/DropShadow.js +13 -2
- package/esm/designs/defs/LinearGradient.js +1 -1
- package/esm/designs/items/BadgeCard.js +2 -2
- package/esm/designs/items/CandyCardLite.js +1 -1
- package/esm/designs/items/CapsuleItem.js +3 -3
- package/esm/designs/items/CircleNode.js +1 -1
- package/esm/designs/items/CircularProgress.js +3 -2
- package/esm/designs/items/CompactCard.js +1 -1
- package/esm/designs/items/DoneList.js +1 -1
- package/esm/designs/items/HorizontalIconArrow.js +2 -2
- package/esm/designs/items/HorizontalIconLine.js +2 -2
- package/esm/designs/items/IconBadge.js +4 -3
- package/esm/designs/items/IndexedCard.js +1 -1
- package/esm/designs/items/LCornerCard.js +1 -1
- package/esm/designs/items/LetterCard.js +4 -3
- package/esm/designs/items/LinedText.js +6 -5
- package/esm/designs/items/PillBadge.js +2 -2
- package/esm/designs/items/PlainText.js +4 -4
- package/esm/designs/items/ProgressCard.js +4 -4
- package/esm/designs/items/QuarterCircular.js +1 -1
- package/esm/designs/items/QuarterSimpleCard.js +1 -1
- package/esm/designs/items/RibbonCard.js +2 -2
- package/esm/designs/items/RoundedRectNode.js +2 -2
- package/esm/designs/items/SimpleCircleNode.js +1 -1
- package/esm/designs/items/SimpleHorizontalArrow.js +2 -2
- package/esm/designs/items/SimpleIllusItem.js +1 -1
- package/esm/designs/items/SimpleItem.js +3 -3
- package/esm/designs/items/SimpleVerticalArrow.js +2 -2
- package/esm/designs/items/UnderlineText.js +1 -1
- package/esm/designs/items/VerticalIconArrow.js +2 -2
- package/esm/designs/layouts/Align.js +22 -15
- package/esm/designs/layouts/Flex.js +23 -16
- package/esm/designs/structures/chart-bar.js +7 -5
- package/esm/designs/structures/chart-column.js +3 -2
- package/esm/designs/structures/chart-line.js +7 -5
- package/esm/designs/structures/chart-pie.js +4 -3
- package/esm/designs/structures/chart-wordcloud.js +5 -14
- package/esm/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.js +1 -1
- package/esm/designs/structures/compare-binary-horizontal/dividers/pros-cons-fold.js +1 -1
- package/esm/designs/structures/compare-binary-horizontal/dividers/types.js +2 -1
- package/esm/designs/structures/compare-hierarchy-left-right.js +6 -5
- package/esm/designs/structures/compare-hierarchy-row.js +3 -2
- package/esm/designs/structures/compare-quadrant.js +2 -3
- package/esm/designs/structures/hierarchy-mindmap.js +19 -19
- package/esm/designs/structures/hierarchy-structure.js +1 -1
- package/esm/designs/structures/hierarchy-tree.js +15 -24
- package/esm/designs/structures/list-sector.js +5 -6
- package/esm/designs/structures/list-zigzag.js +2 -1
- package/esm/designs/structures/relation-dagre-flow.js +30 -35
- package/esm/designs/structures/relation-network.js +2 -2
- package/esm/designs/structures/sequence-funnel.js +1 -1
- package/esm/designs/structures/sequence-mountain.js +4 -4
- package/esm/designs/structures/sequence-pyramid.js +1 -1
- package/esm/designs/structures/sequence-zigzag-steps.js +2 -1
- package/esm/designs/utils/color.js +8 -4
- package/esm/designs/utils/item.js +3 -2
- package/esm/editor/commands/Batch.js +21 -8
- package/esm/editor/commands/UpdateElement.js +25 -22
- package/esm/editor/commands/UpdateOptions.js +23 -10
- package/esm/editor/commands/UpdateText.js +24 -11
- package/esm/editor/interactions/brush-select.js +27 -13
- package/esm/editor/interactions/click-select.js +13 -3
- package/esm/editor/interactions/dblclick-edit-text.js +36 -20
- package/esm/editor/interactions/drag-element.js +23 -9
- package/esm/editor/interactions/hotkey-history.js +17 -7
- package/esm/editor/interactions/select-highlight.js +5 -9
- package/esm/editor/interactions/zoom-wheel.js +2 -1
- package/esm/editor/managers/command.js +45 -27
- package/esm/editor/managers/interaction.js +46 -33
- package/esm/editor/managers/state.js +1 -1
- package/esm/editor/plugins/edit-bar/components/color-picker.js +9 -6
- package/esm/editor/plugins/edit-bar/components/popover.js +15 -12
- package/esm/editor/plugins/edit-bar/components/select.js +10 -8
- package/esm/editor/plugins/edit-bar/edit-bar.js +7 -25
- package/esm/editor/plugins/edit-bar/edit-items/align-elements.js +5 -3
- package/esm/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
- package/esm/editor/plugins/edit-bar/edit-items/font-color.js +2 -2
- package/esm/editor/plugins/edit-bar/edit-items/icon-color.js +2 -2
- package/esm/editor/plugins/resize-element.js +6 -4
- package/esm/editor/utils/click-handler.js +6 -3
- package/esm/editor/utils/coordinate.js +2 -1
- package/esm/editor/utils/element.js +2 -1
- package/esm/editor/utils/event.js +2 -1
- package/esm/editor/utils/extension.js +1 -1
- package/esm/editor/utils/hotkey.js +2 -1
- package/esm/exporter/font.js +106 -90
- package/esm/exporter/png.js +49 -37
- package/esm/exporter/svg.js +55 -38
- package/esm/jsx/components/Ellipse.js +5 -4
- package/esm/jsx/components/Path.js +2 -4
- package/esm/jsx/components/Polygon.js +15 -6
- package/esm/jsx/components/Text.js +21 -41
- package/esm/jsx/renderer.js +15 -7
- package/esm/jsx/utils/bounds.js +18 -16
- package/esm/jsx/utils/children.js +2 -1
- package/esm/jsx/utils/clone.js +13 -2
- package/esm/jsx/utils/element.js +2 -1
- package/esm/options/parser.js +45 -46
- package/esm/renderer/composites/background.js +3 -2
- package/esm/renderer/composites/icon.js +14 -19
- package/esm/renderer/composites/illus.js +17 -22
- package/esm/renderer/composites/shape.js +4 -2
- package/esm/renderer/composites/svg.js +2 -1
- package/esm/renderer/composites/text.js +5 -3
- package/esm/renderer/fonts/loader.js +4 -3
- package/esm/renderer/fonts/registry.js +1 -1
- package/esm/renderer/palettes/utils.js +3 -2
- package/esm/renderer/renderer.js +7 -5
- package/esm/renderer/stylize/gradient.js +3 -2
- package/esm/renderer/stylize/pattern.js +15 -8
- package/esm/renderer/stylize/rough.js +1 -1
- package/esm/resource/load-tracker.js +22 -10
- package/esm/resource/loader.js +80 -67
- package/esm/resource/loaders/image.js +71 -59
- package/esm/resource/loaders/remote.js +26 -15
- package/esm/resource/loaders/search.js +38 -25
- package/esm/resource/utils/parser.js +2 -1
- package/esm/runtime/Infographic.js +26 -13
- package/esm/runtime/utils.js +5 -8
- package/esm/ssr/renderer.js +42 -35
- package/esm/syntax/index.js +19 -6
- package/esm/syntax/mapper.js +2 -2
- package/esm/templates/built-in.js +96 -200
- package/esm/templates/hierarchy-mindmap.js +1 -5
- package/esm/templates/hierarchy-tree.js +1 -5
- package/esm/templates/relation-dagre-flow.js +4 -28
- package/esm/themes/generator.js +8 -14
- package/esm/utils/fetch.js +48 -35
- package/esm/utils/icon.js +1 -4
- package/esm/utils/is-browser.js +2 -2
- package/esm/utils/measure-text.js +2 -1
- package/esm/utils/padding.js +1 -1
- package/esm/utils/recognizer.js +2 -1
- package/esm/utils/text.js +14 -3
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/designs/components/Btn.js +15 -4
- package/lib/designs/components/BtnsGroup.js +1 -1
- package/lib/designs/components/Illus.js +15 -3
- package/lib/designs/components/ItemDesc.js +17 -11
- package/lib/designs/components/ItemIcon.js +17 -18
- package/lib/designs/components/ItemLabel.js +17 -11
- package/lib/designs/components/ItemValue.js +17 -12
- package/lib/designs/components/ItemsGroup.js +1 -1
- package/lib/designs/components/ShapesGroup.js +1 -1
- package/lib/designs/components/Title.js +2 -2
- package/lib/designs/decorations/simple-arrow.js +14 -2
- package/lib/designs/decorations/triangle.js +14 -2
- package/lib/designs/defs/DropShadow.js +13 -2
- package/lib/designs/defs/LinearGradient.js +1 -1
- package/lib/designs/items/BadgeCard.js +2 -2
- package/lib/designs/items/CandyCardLite.js +1 -1
- package/lib/designs/items/CapsuleItem.js +3 -3
- package/lib/designs/items/CircleNode.js +1 -1
- package/lib/designs/items/CircularProgress.js +3 -2
- package/lib/designs/items/CompactCard.js +1 -1
- package/lib/designs/items/DoneList.js +1 -1
- package/lib/designs/items/HorizontalIconArrow.js +2 -2
- package/lib/designs/items/HorizontalIconLine.js +2 -2
- package/lib/designs/items/IconBadge.js +4 -3
- package/lib/designs/items/IndexedCard.js +1 -1
- package/lib/designs/items/LCornerCard.js +1 -1
- package/lib/designs/items/LetterCard.js +4 -3
- package/lib/designs/items/LinedText.js +6 -5
- package/lib/designs/items/PillBadge.js +2 -2
- package/lib/designs/items/PlainText.js +4 -4
- package/lib/designs/items/ProgressCard.js +4 -4
- package/lib/designs/items/QuarterCircular.js +1 -1
- package/lib/designs/items/QuarterSimpleCard.js +1 -1
- package/lib/designs/items/RibbonCard.js +2 -2
- package/lib/designs/items/RoundedRectNode.js +2 -2
- package/lib/designs/items/SimpleCircleNode.js +1 -1
- package/lib/designs/items/SimpleHorizontalArrow.js +2 -2
- package/lib/designs/items/SimpleIllusItem.js +1 -1
- package/lib/designs/items/SimpleItem.js +3 -3
- package/lib/designs/items/SimpleVerticalArrow.js +2 -2
- package/lib/designs/items/UnderlineText.js +1 -1
- package/lib/designs/items/VerticalIconArrow.js +2 -2
- package/lib/designs/layouts/Align.js +22 -15
- package/lib/designs/layouts/Flex.js +23 -16
- package/lib/designs/structures/chart-bar.js +7 -5
- package/lib/designs/structures/chart-column.js +3 -2
- package/lib/designs/structures/chart-line.js +7 -5
- package/lib/designs/structures/chart-pie.js +4 -3
- package/lib/designs/structures/chart-wordcloud.js +5 -14
- package/lib/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.js +1 -1
- package/lib/designs/structures/compare-binary-horizontal/dividers/pros-cons-fold.js +1 -1
- package/lib/designs/structures/compare-binary-horizontal/dividers/types.js +2 -1
- package/lib/designs/structures/compare-hierarchy-left-right.js +6 -5
- package/lib/designs/structures/compare-hierarchy-row.js +3 -2
- package/lib/designs/structures/compare-quadrant.js +2 -3
- package/lib/designs/structures/hierarchy-mindmap.js +19 -19
- package/lib/designs/structures/hierarchy-structure.js +1 -1
- package/lib/designs/structures/hierarchy-tree.js +15 -24
- package/lib/designs/structures/list-sector.js +5 -6
- package/lib/designs/structures/list-zigzag.js +2 -1
- package/lib/designs/structures/relation-dagre-flow.js +30 -35
- package/lib/designs/structures/relation-network.js +2 -2
- package/lib/designs/structures/sequence-funnel.js +1 -1
- package/lib/designs/structures/sequence-mountain.js +4 -4
- package/lib/designs/structures/sequence-pyramid.js +1 -1
- package/lib/designs/structures/sequence-zigzag-steps.js +2 -1
- package/lib/designs/utils/color.js +8 -4
- package/lib/designs/utils/item.js +3 -2
- package/lib/editor/commands/Batch.js +21 -8
- package/lib/editor/commands/UpdateElement.js +25 -22
- package/lib/editor/commands/UpdateOptions.js +23 -10
- package/lib/editor/commands/UpdateText.js +24 -11
- package/lib/editor/interactions/brush-select.js +27 -13
- package/lib/editor/interactions/click-select.js +13 -3
- package/lib/editor/interactions/dblclick-edit-text.js +36 -20
- package/lib/editor/interactions/drag-element.js +23 -9
- package/lib/editor/interactions/hotkey-history.js +17 -7
- package/lib/editor/interactions/select-highlight.js +5 -9
- package/lib/editor/interactions/zoom-wheel.js +2 -1
- package/lib/editor/managers/command.js +43 -25
- package/lib/editor/managers/interaction.js +46 -33
- package/lib/editor/managers/state.js +1 -1
- package/lib/editor/plugins/edit-bar/components/color-picker.js +9 -6
- package/lib/editor/plugins/edit-bar/components/popover.js +15 -12
- package/lib/editor/plugins/edit-bar/components/select.js +10 -8
- package/lib/editor/plugins/edit-bar/edit-bar.js +7 -25
- package/lib/editor/plugins/edit-bar/edit-items/align-elements.js +5 -3
- package/lib/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
- package/lib/editor/plugins/edit-bar/edit-items/font-color.js +2 -2
- package/lib/editor/plugins/edit-bar/edit-items/icon-color.js +2 -2
- package/lib/editor/plugins/resize-element.js +6 -4
- package/lib/editor/utils/click-handler.js +6 -3
- package/lib/editor/utils/coordinate.js +2 -1
- package/lib/editor/utils/element.js +2 -1
- package/lib/editor/utils/event.js +2 -1
- package/lib/editor/utils/extension.js +1 -1
- package/lib/editor/utils/hotkey.js +2 -1
- package/lib/exporter/font.js +106 -90
- package/lib/exporter/png.js +49 -37
- package/lib/exporter/svg.js +55 -38
- package/lib/jsx/components/Ellipse.js +5 -4
- package/lib/jsx/components/Path.js +2 -4
- package/lib/jsx/components/Polygon.js +15 -6
- package/lib/jsx/components/Text.js +21 -41
- package/lib/jsx/renderer.js +15 -7
- package/lib/jsx/utils/bounds.js +18 -16
- package/lib/jsx/utils/children.js +2 -1
- package/lib/jsx/utils/clone.js +13 -2
- package/lib/jsx/utils/element.js +2 -1
- package/lib/options/parser.js +45 -46
- package/lib/renderer/composites/background.js +3 -2
- package/lib/renderer/composites/icon.js +14 -19
- package/lib/renderer/composites/illus.js +17 -22
- package/lib/renderer/composites/shape.js +4 -2
- package/lib/renderer/composites/svg.js +2 -1
- package/lib/renderer/composites/text.js +5 -3
- package/lib/renderer/fonts/loader.js +4 -3
- package/lib/renderer/fonts/registry.js +1 -1
- package/lib/renderer/palettes/utils.js +3 -2
- package/lib/renderer/renderer.js +7 -5
- package/lib/renderer/stylize/gradient.js +3 -2
- package/lib/renderer/stylize/pattern.js +15 -8
- package/lib/renderer/stylize/rough.js +1 -1
- package/lib/resource/load-tracker.js +22 -10
- package/lib/resource/loader.js +80 -67
- package/lib/resource/loaders/image.js +71 -59
- package/lib/resource/loaders/remote.js +26 -15
- package/lib/resource/loaders/search.js +38 -25
- package/lib/resource/utils/parser.js +2 -1
- package/lib/runtime/Infographic.js +26 -13
- package/lib/runtime/utils.js +5 -8
- package/lib/ssr/renderer.js +42 -35
- package/lib/syntax/index.js +19 -6
- package/lib/syntax/mapper.js +2 -2
- package/lib/templates/built-in.js +96 -200
- package/lib/templates/hierarchy-mindmap.js +1 -5
- package/lib/templates/hierarchy-tree.js +1 -5
- package/lib/templates/relation-dagre-flow.js +4 -28
- package/lib/themes/generator.js +8 -14
- package/lib/utils/fetch.js +48 -35
- package/lib/utils/icon.js +1 -4
- package/lib/utils/is-browser.js +2 -2
- package/lib/utils/measure-text.js +2 -1
- package/lib/utils/padding.js +1 -1
- package/lib/utils/recognizer.js +2 -1
- package/lib/utils/text.js +14 -3
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/version.ts +1 -1
|
@@ -17,21 +17,19 @@ const DEFAULT_EDGE_WIDTH = 2;
|
|
|
17
17
|
const DEFAULT_COLOR_MODE = 'node';
|
|
18
18
|
const DEFAULT_EDGE_COLOR_MODE = 'solid';
|
|
19
19
|
const annotateTree = (node, parentIndexes = [], index = 0) => {
|
|
20
|
+
var _a, _b;
|
|
20
21
|
const indexes = [...parentIndexes, index];
|
|
21
|
-
return {
|
|
22
|
-
...node,
|
|
23
|
-
_indexes: indexes,
|
|
24
|
-
children: node.children?.map((child, childIndex) => annotateTree(child, indexes, childIndex)) ?? [],
|
|
25
|
-
};
|
|
22
|
+
return Object.assign(Object.assign({}, node), { _indexes: indexes, children: (_b = (_a = node.children) === null || _a === void 0 ? void 0 : _a.map((child, childIndex) => annotateTree(child, indexes, childIndex))) !== null && _b !== void 0 ? _b : [] });
|
|
26
23
|
};
|
|
27
24
|
const collectNodes = (node, nodes, links, parent) => {
|
|
28
25
|
var _a;
|
|
26
|
+
var _b;
|
|
29
27
|
nodes.push(node);
|
|
30
|
-
(_a = node.data)._flatIndex
|
|
28
|
+
(_a = (_b = node.data)._flatIndex) !== null && _a !== void 0 ? _a : (_b._flatIndex = nodes.length - 1);
|
|
31
29
|
if (parent)
|
|
32
30
|
links.push({ parent, child: node });
|
|
33
31
|
const children = node.children;
|
|
34
|
-
children
|
|
32
|
+
children === null || children === void 0 ? void 0 : children.forEach((child) => collectNodes(child, nodes, links, node));
|
|
35
33
|
};
|
|
36
34
|
const createCurvePath = (sx, sy, tx, ty) => {
|
|
37
35
|
const offsetX = Math.abs(tx - sx) / 2;
|
|
@@ -70,6 +68,7 @@ const getEdgeAnchors = (parentLayout, childLayout, childSide, align = DEFAULT_ED
|
|
|
70
68
|
};
|
|
71
69
|
};
|
|
72
70
|
const HierarchyMindmap = (props) => {
|
|
71
|
+
var _a, _b;
|
|
73
72
|
const { Title, Items, data, levelGap = DEFAULT_LEVEL_GAP, nodeGap = DEFAULT_NODE_GAP, edgeAlign = DEFAULT_EDGE_ALIGN, colorMode = DEFAULT_COLOR_MODE, edgeColorMode = DEFAULT_EDGE_COLOR_MODE, edgeType = DEFAULT_EDGE_TYPE, edgeWidth = DEFAULT_EDGE_WIDTH, options, } = props;
|
|
74
73
|
const { title, desc, items = [] } = data;
|
|
75
74
|
const titleContent = Title ? (0, jsx_runtime_1.jsx)(Title, { title: title, desc: desc }) : null;
|
|
@@ -77,7 +76,7 @@ const HierarchyMindmap = (props) => {
|
|
|
77
76
|
const btnBounds = (0, jsx_1.getElementBounds)((0, jsx_runtime_1.jsx)(components_1.BtnAdd, { indexes: [0] }));
|
|
78
77
|
const groupColorIndexMap = new Map();
|
|
79
78
|
let nextGroupColorIndex = 0;
|
|
80
|
-
if (!items.length || !Items
|
|
79
|
+
if (!items.length || !(Items === null || Items === void 0 ? void 0 : Items.length)) {
|
|
81
80
|
return ((0, jsx_runtime_1.jsxs)(layouts_1.FlexLayout, { id: "infographic-container", flexDirection: "column", justifyContent: "center", alignItems: "center", children: [titleContent, (0, jsx_runtime_1.jsx)(jsx_1.Group, { children: (0, jsx_runtime_1.jsx)(components_1.BtnAdd, { indexes: [0], x: 0, y: 0 }) })] }));
|
|
82
81
|
}
|
|
83
82
|
const root = annotateTree(items[0]);
|
|
@@ -85,8 +84,9 @@ const HierarchyMindmap = (props) => {
|
|
|
85
84
|
const colorCache = new WeakMap();
|
|
86
85
|
const themeCache = new WeakMap();
|
|
87
86
|
const getNodeColorIndexes = (datum, depth) => {
|
|
87
|
+
var _a;
|
|
88
88
|
if (colorMode === 'group') {
|
|
89
|
-
const groupKey = String(datum.group
|
|
89
|
+
const groupKey = String((_a = datum.group) !== null && _a !== void 0 ? _a : '');
|
|
90
90
|
let groupIndex = groupColorIndexMap.get(groupKey);
|
|
91
91
|
if (groupIndex == null) {
|
|
92
92
|
groupIndex = nextGroupColorIndex;
|
|
@@ -149,10 +149,11 @@ const HierarchyMindmap = (props) => {
|
|
|
149
149
|
const btnElements = [];
|
|
150
150
|
const layoutStore = new WeakMap();
|
|
151
151
|
layoutNodes.forEach((node) => {
|
|
152
|
+
var _a, _b;
|
|
152
153
|
const datum = node.data;
|
|
153
154
|
const measured = measureNode(datum);
|
|
154
|
-
const displayX = node.x + shiftX + (node.hgap
|
|
155
|
-
const displayY = node.y + shiftY + (node.vgap
|
|
155
|
+
const displayX = node.x + shiftX + ((_a = node.hgap) !== null && _a !== void 0 ? _a : 0);
|
|
156
|
+
const displayY = node.y + shiftY + ((_b = node.vgap) !== null && _b !== void 0 ? _b : 0);
|
|
156
157
|
const Component = (0, utils_1.getItemComponent)(Items, node.depth);
|
|
157
158
|
const positionH = node.depth === 0 ? 'center' : node.side === 'left' ? 'flipped' : 'normal';
|
|
158
159
|
const themeColors = getNodeThemeColors(datum, node.depth);
|
|
@@ -167,6 +168,7 @@ const HierarchyMindmap = (props) => {
|
|
|
167
168
|
});
|
|
168
169
|
});
|
|
169
170
|
nodeLinks.forEach((link) => {
|
|
171
|
+
var _a, _b, _c, _d;
|
|
170
172
|
const { parent, child } = link;
|
|
171
173
|
const childLayout = layoutStore.get(child);
|
|
172
174
|
const parentLayout = layoutStore.get(parent);
|
|
@@ -175,21 +177,19 @@ const HierarchyMindmap = (props) => {
|
|
|
175
177
|
}
|
|
176
178
|
const childDatum = child.data;
|
|
177
179
|
const { sx, sy, tx, ty } = getEdgeAnchors(parentLayout, childLayout, child.side, edgeAlign);
|
|
178
|
-
const childColor = colorCache.get(childDatum)
|
|
179
|
-
|
|
180
|
-
const parentColor = colorCache.get(parent.data) ??
|
|
181
|
-
(0, utils_1.getPaletteColor)(options, getNodeColorIndexes(parent.data, parent.depth));
|
|
180
|
+
const childColor = (_a = colorCache.get(childDatum)) !== null && _a !== void 0 ? _a : (0, utils_1.getPaletteColor)(options, getNodeColorIndexes(childDatum, child.depth));
|
|
181
|
+
const parentColor = (_b = colorCache.get(parent.data)) !== null && _b !== void 0 ? _b : (0, utils_1.getPaletteColor)(options, getNodeColorIndexes(parent.data, parent.depth));
|
|
182
182
|
const pathD = edgeType === 'straight'
|
|
183
183
|
? createStraightPath(sx, sy, tx, ty)
|
|
184
184
|
: createCurvePath(sx, sy, tx, ty);
|
|
185
185
|
const gradientId = `edge-gradient-${childDatum._indexes.join('-')}`;
|
|
186
186
|
decorElements.push((0, jsx_runtime_1.jsx)(jsx_1.Path, { d: pathD, stroke: edgeColorMode === 'gradient'
|
|
187
187
|
? `url(#${gradientId})`
|
|
188
|
-
: (childColor
|
|
188
|
+
: (childColor !== null && childColor !== void 0 ? childColor : colorPrimary), strokeWidth: edgeWidth, fill: "none" }));
|
|
189
189
|
if (edgeColorMode === 'gradient') {
|
|
190
|
-
defsElements.push((0, jsx_runtime_1.jsxs)("linearGradient", { id: gradientId, gradientUnits: "userSpaceOnUse", x1: sx, y1: sy, x2: tx, y2: ty, children: [(0, jsx_runtime_1.jsx)("stop", { offset: "0%", stopColor: parentColor
|
|
190
|
+
defsElements.push((0, jsx_runtime_1.jsxs)("linearGradient", { id: gradientId, gradientUnits: "userSpaceOnUse", x1: sx, y1: sy, x2: tx, y2: ty, children: [(0, jsx_runtime_1.jsx)("stop", { offset: "0%", stopColor: parentColor !== null && parentColor !== void 0 ? parentColor : colorPrimary }), (0, jsx_runtime_1.jsx)("stop", { offset: "100%", stopColor: childColor !== null && childColor !== void 0 ? childColor : colorPrimary })] }));
|
|
191
191
|
}
|
|
192
|
-
const appendIndex = childDatum.children
|
|
192
|
+
const appendIndex = (_d = (_c = childDatum.children) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0;
|
|
193
193
|
const addIndexes = [...childDatum._indexes, appendIndex];
|
|
194
194
|
const btnX = childLayout.x + (childLayout.width - btnBounds.width) / 2;
|
|
195
195
|
const removeY = childLayout.y + childLayout.height + 8;
|
|
@@ -202,7 +202,7 @@ const HierarchyMindmap = (props) => {
|
|
|
202
202
|
const rootLayout = layoutStore.get(mindmapRoot);
|
|
203
203
|
if (rootLayout) {
|
|
204
204
|
const rootDatum = mindmapRoot.data;
|
|
205
|
-
const appendIndex = rootDatum.children
|
|
205
|
+
const appendIndex = (_b = (_a = rootDatum.children) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
206
206
|
const addIndexes = [...rootDatum._indexes, appendIndex];
|
|
207
207
|
const btnX = rootLayout.x + (rootLayout.width - btnBounds.width) / 2;
|
|
208
208
|
const addY = rootLayout.y + rootLayout.height + 8 + btnBounds.height + 6;
|
|
@@ -59,7 +59,7 @@ const HierarchyStructure = (props) => {
|
|
|
59
59
|
const labelWidth = labelBounds.width + labelPaddingX * 2;
|
|
60
60
|
const labelHeight = labelBounds.height + labelPaddingY * 2;
|
|
61
61
|
const children = layer.children || [];
|
|
62
|
-
const hasGroups = children.some((child) => (child.children
|
|
62
|
+
const hasGroups = children.some((child) => { var _a; return (((_a = child.children) === null || _a === void 0 ? void 0 : _a.length) || 0) > 0; });
|
|
63
63
|
if (hasGroups) {
|
|
64
64
|
const pillLabels = [];
|
|
65
65
|
children.forEach((child) => {
|
|
@@ -67,9 +67,10 @@ const HierarchyTree = (props) => {
|
|
|
67
67
|
let nextGroupColorIndex = 0;
|
|
68
68
|
// 内置工具方法:数据预处理
|
|
69
69
|
const normalizeItems = (items) => {
|
|
70
|
+
var _a;
|
|
70
71
|
const list = [...items];
|
|
71
|
-
if (!list[0]
|
|
72
|
-
list[0] = {
|
|
72
|
+
if (!((_a = list[0]) === null || _a === void 0 ? void 0 : _a.children)) {
|
|
73
|
+
list[0] = Object.assign(Object.assign({}, list[0]), { children: list.slice(1) });
|
|
73
74
|
list.splice(1);
|
|
74
75
|
}
|
|
75
76
|
return list;
|
|
@@ -123,34 +124,22 @@ const HierarchyTree = (props) => {
|
|
|
123
124
|
};
|
|
124
125
|
// 内置工具方法:构建层级数据
|
|
125
126
|
const buildHierarchyData = (list) => {
|
|
127
|
+
var _a;
|
|
126
128
|
if (!list.length)
|
|
127
129
|
return null;
|
|
128
130
|
const rootItem = list[0];
|
|
129
131
|
const buildNode = (node, parentIndexes = [], idx = 0) => {
|
|
132
|
+
var _a, _b;
|
|
130
133
|
const indexes = [...parentIndexes, idx];
|
|
131
|
-
return {
|
|
132
|
-
...node,
|
|
133
|
-
_originalIndex: indexes,
|
|
134
|
-
_depth: indexes.length - 1,
|
|
135
|
-
children: node.children?.map((c, i) => buildNode(c, indexes, i)) ??
|
|
136
|
-
[],
|
|
137
|
-
};
|
|
134
|
+
return Object.assign(Object.assign({}, node), { _originalIndex: indexes, _depth: indexes.length - 1, children: (_b = (_a = node.children) === null || _a === void 0 ? void 0 : _a.map((c, i) => buildNode(c, indexes, i))) !== null && _b !== void 0 ? _b : [] });
|
|
138
135
|
};
|
|
139
|
-
return rootItem.children
|
|
136
|
+
return ((_a = rootItem.children) === null || _a === void 0 ? void 0 : _a.length)
|
|
140
137
|
? buildNode(rootItem)
|
|
141
|
-
: {
|
|
142
|
-
...rootItem,
|
|
143
|
-
_originalIndex: [0],
|
|
144
|
-
_depth: 0,
|
|
145
|
-
children: list.slice(1).map((child, i) => ({
|
|
146
|
-
...child,
|
|
147
|
-
_originalIndex: [i + 1],
|
|
148
|
-
_depth: 1,
|
|
149
|
-
})),
|
|
150
|
-
};
|
|
138
|
+
: Object.assign(Object.assign({}, rootItem), { _originalIndex: [0], _depth: 0, children: list.slice(1).map((child, i) => (Object.assign(Object.assign({}, child), { _originalIndex: [i + 1], _depth: 1 }))) });
|
|
151
139
|
};
|
|
152
140
|
// 内置工具方法:计算各层节点边界
|
|
153
141
|
const computeLevelBounds = (rootNode) => {
|
|
142
|
+
var _a, _b;
|
|
154
143
|
let maxWidth = 0, maxHeight = 0;
|
|
155
144
|
const levelBounds = new Map();
|
|
156
145
|
const sampleDatumByLevel = new Map();
|
|
@@ -162,8 +151,8 @@ const HierarchyTree = (props) => {
|
|
|
162
151
|
});
|
|
163
152
|
for (let level = 0; level < rootNode.height + 1; level++) {
|
|
164
153
|
const ItemComponent = (0, utils_1.getItemComponent)(Items, level);
|
|
165
|
-
const sampleDatum = sampleDatumByLevel.get(level)
|
|
166
|
-
const indexes = sampleDatum._originalIndex
|
|
154
|
+
const sampleDatum = (_a = sampleDatumByLevel.get(level)) !== null && _a !== void 0 ? _a : {};
|
|
155
|
+
const indexes = (_b = sampleDatum._originalIndex) !== null && _b !== void 0 ? _b : Array(level + 1).fill(0);
|
|
167
156
|
const bounds = (0, jsx_1.getElementBounds)((0, jsx_runtime_1.jsx)(ItemComponent, { indexes: indexes, data: data, datum: sampleDatum, positionH: "center" }));
|
|
168
157
|
levelBounds.set(level, bounds);
|
|
169
158
|
maxWidth = Math.max(maxWidth, bounds.width);
|
|
@@ -172,8 +161,9 @@ const HierarchyTree = (props) => {
|
|
|
172
161
|
return { levelBounds, maxWidth, maxHeight };
|
|
173
162
|
};
|
|
174
163
|
const getNodeColorIndexes = (nodeData, depth) => {
|
|
164
|
+
var _a;
|
|
175
165
|
if (colorMode === 'group') {
|
|
176
|
-
const groupKey = String(nodeData
|
|
166
|
+
const groupKey = String((_a = nodeData === null || nodeData === void 0 ? void 0 : nodeData.group) !== null && _a !== void 0 ? _a : '');
|
|
177
167
|
let groupIndex = groupColorIndexMap.get(groupKey);
|
|
178
168
|
if (groupIndex == null) {
|
|
179
169
|
groupIndex = nextGroupColorIndex;
|
|
@@ -380,10 +370,11 @@ const HierarchyTree = (props) => {
|
|
|
380
370
|
const renderSiblingBtns = (nodes, btnBounds, offsets) => {
|
|
381
371
|
const nodesByParent = new Map();
|
|
382
372
|
nodes.forEach((node) => {
|
|
373
|
+
var _a;
|
|
383
374
|
const key = node.parent
|
|
384
375
|
? node.parent.data._originalIndex.join('-')
|
|
385
376
|
: 'root';
|
|
386
|
-
(nodesByParent.get(key)
|
|
377
|
+
((_a = nodesByParent.get(key)) !== null && _a !== void 0 ? _a : nodesByParent.set(key, []).get(key)).push(node);
|
|
387
378
|
});
|
|
388
379
|
const btns = [];
|
|
389
380
|
nodesByParent.forEach((siblings) => {
|
|
@@ -25,6 +25,7 @@ const ListSector = (props) => {
|
|
|
25
25
|
const totalUsableAngle = totalAngle - totalGapAngle;
|
|
26
26
|
const anglePerSector = items.length > 0 ? totalUsableAngle / items.length : 0;
|
|
27
27
|
items.forEach((item, index) => {
|
|
28
|
+
var _a;
|
|
28
29
|
const indexes = [index];
|
|
29
30
|
const currentStartAngle = startAngle + (anglePerSector + gapAngle) * index;
|
|
30
31
|
const currentEndAngle = currentStartAngle + anglePerSector;
|
|
@@ -68,12 +69,10 @@ const ListSector = (props) => {
|
|
|
68
69
|
const itemBounds = (0, jsx_1.getElementBounds)((0, jsx_runtime_1.jsx)(Item, { indexes: [0], data: data, datum: items[0], positionH: "center", width: maxWidth, height: maxHeight }));
|
|
69
70
|
const itemX = centerX + midRadius * Math.cos(midAngleRad) - itemBounds.width / 2;
|
|
70
71
|
const itemY = centerY + midRadius * Math.sin(midAngleRad) - itemBounds.height / 2;
|
|
71
|
-
itemElements.push((0, jsx_runtime_1.jsx)(Item, { indexes: indexes, datum: item, data: data, x: itemX, y: itemY, positionH: "center", width: maxWidth, height: maxHeight, themeColors: {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}),
|
|
76
|
-
} }));
|
|
72
|
+
itemElements.push((0, jsx_runtime_1.jsx)(Item, { indexes: indexes, datum: item, data: data, x: itemX, y: itemY, positionH: "center", width: maxWidth, height: maxHeight, themeColors: Object.assign({}, (0, utils_1.getThemeColors)({
|
|
73
|
+
colorBg: (0, utils_1.getPaletteColor)(options, indexes),
|
|
74
|
+
colorPrimary: ((_a = options.themeConfig) === null || _a === void 0 ? void 0 : _a.colorBg) || 'white',
|
|
75
|
+
})) }));
|
|
77
76
|
const btnRemoveRadius = outerRadius + 10;
|
|
78
77
|
const btnRemoveX = centerX + btnRemoveRadius * Math.cos(midAngleRad) - btnBounds.width / 2;
|
|
79
78
|
const btnRemoveY = centerY + btnRemoveRadius * Math.sin(midAngleRad) - btnBounds.height / 2;
|
|
@@ -141,6 +141,7 @@ const getUnitVector = (from, to) => {
|
|
|
141
141
|
const createListZigzag = (config) => {
|
|
142
142
|
const { presetRatios, arrowHeight, Arrow } = config;
|
|
143
143
|
const ListZigzag = (props) => {
|
|
144
|
+
var _a;
|
|
144
145
|
const { Title, Item, data, options, itemGap = 24 } = props;
|
|
145
146
|
const { title, desc, items = [] } = data;
|
|
146
147
|
const layoutCount = Math.min(items.length, MAX_ITEMS);
|
|
@@ -151,7 +152,7 @@ const createListZigzag = (config) => {
|
|
|
151
152
|
const colorShadow = themeColors.colorTextSecondary || '#737373';
|
|
152
153
|
const btnBounds = (0, jsx_1.getElementBounds)((0, jsx_runtime_1.jsx)(components_1.BtnAdd, { indexes: [0] }));
|
|
153
154
|
if (items.length === 0) {
|
|
154
|
-
const anchor = getPresetPoints(1, presetRatios, arrowHeight)
|
|
155
|
+
const anchor = (_a = getPresetPoints(1, presetRatios, arrowHeight)) === null || _a === void 0 ? void 0 : _a[0];
|
|
155
156
|
if (!anchor) {
|
|
156
157
|
return ((0, jsx_runtime_1.jsxs)(layouts_1.FlexLayout, { id: "infographic-container", flexDirection: "column", justifyContent: "center", alignItems: "center", children: [titleContent, (0, jsx_runtime_1.jsx)(jsx_1.Group, { children: (0, jsx_runtime_1.jsx)(Arrow, { colorPrimary: colorPrimary, colorShadow: colorShadow }) })] }));
|
|
157
158
|
}
|
|
@@ -14,13 +14,14 @@ const DEFAULT_EDGE_SEP = 10;
|
|
|
14
14
|
const DEFAULT_EDGE_WIDTH = 2;
|
|
15
15
|
const DEFAULT_PADDING = 30;
|
|
16
16
|
const checkUndirectedCycle = (nodeIds, edges) => {
|
|
17
|
+
var _a, _b;
|
|
17
18
|
const adj = new Map();
|
|
18
19
|
nodeIds.forEach((id) => adj.set(id, []));
|
|
19
20
|
for (const edge of edges) {
|
|
20
21
|
if (edge.source === edge.target)
|
|
21
22
|
return true;
|
|
22
|
-
adj.get(edge.source)
|
|
23
|
-
adj.get(edge.target)
|
|
23
|
+
(_a = adj.get(edge.source)) === null || _a === void 0 ? void 0 : _a.push({ target: edge.target, edgeId: edge.id });
|
|
24
|
+
(_b = adj.get(edge.target)) === null || _b === void 0 ? void 0 : _b.push({ target: edge.source, edgeId: edge.id });
|
|
24
25
|
}
|
|
25
26
|
const visited = new Set();
|
|
26
27
|
const dfs = (u, parentEdgeId) => {
|
|
@@ -45,6 +46,7 @@ const checkUndirectedCycle = (nodeIds, edges) => {
|
|
|
45
46
|
return false;
|
|
46
47
|
};
|
|
47
48
|
const RelationDagreFlow = (props) => {
|
|
49
|
+
var _a, _b;
|
|
48
50
|
const { Title, Item, data, rankdir = 'TB', nodesep = DEFAULT_NODE_SEP, ranksep = DEFAULT_RANK_SEP, edgesep = DEFAULT_EDGE_SEP, edgeWidth = DEFAULT_EDGE_WIDTH, showConnections = true, edgeColorMode = 'gradient', edgeStyle = 'solid', edgeDashPattern = '5,5', edgeCornerRadius = 12, edgeRouting = 'orth', showArrow = true, arrowType = 'triangle', padding = DEFAULT_PADDING, edgeAnimation = 'none', edgeAnimationSpeed = 1, options, } = props;
|
|
49
51
|
const { title, desc, items = [], relations = [] } = data;
|
|
50
52
|
const titleContent = Title ? (0, jsx_runtime_1.jsx)(Title, { title: title, desc: desc }) : null;
|
|
@@ -59,11 +61,12 @@ const RelationDagreFlow = (props) => {
|
|
|
59
61
|
const colorGroupIndexMap = new Map();
|
|
60
62
|
let nextColorGroupIndex = 0;
|
|
61
63
|
const nodes = items.map((item, index) => {
|
|
64
|
+
var _a, _b;
|
|
62
65
|
const datum = item;
|
|
63
|
-
const id = String(datum.id
|
|
66
|
+
const id = String((_a = datum.id) !== null && _a !== void 0 ? _a : index);
|
|
64
67
|
const indexes = [index];
|
|
65
68
|
let primary;
|
|
66
|
-
const groupKey = String(datum.group
|
|
69
|
+
const groupKey = String((_b = datum.group) !== null && _b !== void 0 ? _b : '');
|
|
67
70
|
if (groupKey) {
|
|
68
71
|
let groupIndex = colorGroupIndexMap.get(groupKey);
|
|
69
72
|
if (groupIndex == null) {
|
|
@@ -126,7 +129,8 @@ const RelationDagreFlow = (props) => {
|
|
|
126
129
|
edgesep,
|
|
127
130
|
controlPoints: true,
|
|
128
131
|
nodeSize: (node) => {
|
|
129
|
-
|
|
132
|
+
var _a;
|
|
133
|
+
const id = String((_a = node.id) !== null && _a !== void 0 ? _a : '');
|
|
130
134
|
const bounds = nodeSizeMap.get(id);
|
|
131
135
|
return bounds ? [bounds.width, bounds.height] : [0, 0];
|
|
132
136
|
},
|
|
@@ -134,24 +138,20 @@ const RelationDagreFlow = (props) => {
|
|
|
134
138
|
layout.execute({ nodes, edges });
|
|
135
139
|
const nodeLayouts = [];
|
|
136
140
|
layout.forEachNode((node) => {
|
|
141
|
+
var _a, _b, _c, _d;
|
|
137
142
|
const id = String(node.id);
|
|
138
143
|
const meta = nodeMetaMap.get(id);
|
|
139
144
|
if (!meta)
|
|
140
145
|
return;
|
|
141
146
|
const bounds = nodeSizeMap.get(id);
|
|
142
|
-
const width = bounds
|
|
143
|
-
const height = bounds
|
|
144
|
-
const x = (node.x
|
|
145
|
-
const y = (node.y
|
|
146
|
-
nodeLayouts.push({
|
|
147
|
-
...meta,
|
|
148
|
-
x,
|
|
147
|
+
const width = (_a = bounds === null || bounds === void 0 ? void 0 : bounds.width) !== null && _a !== void 0 ? _a : 0;
|
|
148
|
+
const height = (_b = bounds === null || bounds === void 0 ? void 0 : bounds.height) !== null && _b !== void 0 ? _b : 0;
|
|
149
|
+
const x = ((_c = node.x) !== null && _c !== void 0 ? _c : 0) - width / 2;
|
|
150
|
+
const y = ((_d = node.y) !== null && _d !== void 0 ? _d : 0) - height / 2;
|
|
151
|
+
nodeLayouts.push(Object.assign(Object.assign({}, meta), { x,
|
|
149
152
|
y,
|
|
150
153
|
width,
|
|
151
|
-
height,
|
|
152
|
-
centerX: x + width / 2,
|
|
153
|
-
centerY: y + height / 2,
|
|
154
|
-
});
|
|
154
|
+
height, centerX: x + width / 2, centerY: y + height / 2 }));
|
|
155
155
|
});
|
|
156
156
|
if (nodeLayouts.length === 0) {
|
|
157
157
|
return ((0, jsx_runtime_1.jsxs)(layouts_1.FlexLayout, { id: "infographic-container", flexDirection: "column", justifyContent: "center", alignItems: "center", children: [titleContent, (0, jsx_runtime_1.jsx)(jsx_1.Group, { children: (0, jsx_runtime_1.jsx)(components_1.BtnAdd, { indexes: [0], x: 0, y: 0 }) })] }));
|
|
@@ -168,21 +168,15 @@ const RelationDagreFlow = (props) => {
|
|
|
168
168
|
const positionH = rankdir === 'LR' ? 'normal' : rankdir === 'RL' ? 'flipped' : 'center';
|
|
169
169
|
const positionV = rankdir === 'TB' ? 'normal' : rankdir === 'BT' ? 'flipped' : 'middle';
|
|
170
170
|
itemElements.push((0, jsx_runtime_1.jsx)(Item, { indexes: node.indexes, datum: node.datum, data: data, x: displayX, y: displayY, positionH: positionH, positionV: positionV, themeColors: node.themeColors }));
|
|
171
|
-
nodeLayoutById.set(node.id, {
|
|
172
|
-
...node,
|
|
173
|
-
x: displayX,
|
|
174
|
-
y: displayY,
|
|
175
|
-
centerX: displayX + node.width / 2,
|
|
176
|
-
centerY: displayY + node.height / 2,
|
|
177
|
-
});
|
|
171
|
+
nodeLayoutById.set(node.id, Object.assign(Object.assign({}, node), { x: displayX, y: displayY, centerX: displayX + node.width / 2, centerY: displayY + node.height / 2 }));
|
|
178
172
|
});
|
|
179
173
|
const defsElements = [];
|
|
180
174
|
const decorElements = [];
|
|
181
175
|
if (showConnections) {
|
|
182
176
|
const defaultStroke = (0, utils_1.getColorPrimary)(options);
|
|
183
177
|
const themeColors = (0, utils_1.getThemeColors)(options.themeConfig, options);
|
|
184
|
-
const labelBackground = themeColors
|
|
185
|
-
const labelTextColor = themeColors
|
|
178
|
+
const labelBackground = (_a = themeColors === null || themeColors === void 0 ? void 0 : themeColors.colorBg) !== null && _a !== void 0 ? _a : '#ffffff';
|
|
179
|
+
const labelTextColor = (_b = themeColors === null || themeColors === void 0 ? void 0 : themeColors.colorText) !== null && _b !== void 0 ? _b : defaultStroke;
|
|
186
180
|
const arrowSize = Math.max(10, edgeWidth * 4);
|
|
187
181
|
const isVertical = rankdir === 'TB' || rankdir === 'BT';
|
|
188
182
|
const enableAnimation = edgeAnimation === 'ant-line';
|
|
@@ -384,6 +378,7 @@ const RelationDagreFlow = (props) => {
|
|
|
384
378
|
};
|
|
385
379
|
};
|
|
386
380
|
layout.forEachEdge((edge) => {
|
|
381
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
387
382
|
const normalizePoints = (rawPoints) => {
|
|
388
383
|
if (!Array.isArray(rawPoints))
|
|
389
384
|
return [];
|
|
@@ -414,7 +409,7 @@ const RelationDagreFlow = (props) => {
|
|
|
414
409
|
: null;
|
|
415
410
|
const normalized = useOrthRouting ? [] : normalizePoints(edge.points);
|
|
416
411
|
const points = useOrthRouting
|
|
417
|
-
? (orthEdge
|
|
412
|
+
? ((_a = orthEdge === null || orthEdge === void 0 ? void 0 : orthEdge.points) !== null && _a !== void 0 ? _a : [])
|
|
418
413
|
: normalized.length
|
|
419
414
|
? normalized
|
|
420
415
|
: fallbackPoints();
|
|
@@ -423,14 +418,14 @@ const RelationDagreFlow = (props) => {
|
|
|
423
418
|
const pointsOffsetX = useOrthRouting ? 0 : offsetX;
|
|
424
419
|
const pointsOffsetY = useOrthRouting ? 0 : offsetY;
|
|
425
420
|
const startPoint = useOrthRouting
|
|
426
|
-
? (orthEdge
|
|
421
|
+
? ((_b = orthEdge === null || orthEdge === void 0 ? void 0 : orthEdge.start) !== null && _b !== void 0 ? _b : points[0])
|
|
427
422
|
: points[0];
|
|
428
423
|
const endPoint = useOrthRouting
|
|
429
|
-
? (orthEdge
|
|
424
|
+
? ((_c = orthEdge === null || orthEdge === void 0 ? void 0 : orthEdge.end) !== null && _c !== void 0 ? _c : points[points.length - 1])
|
|
430
425
|
: points[points.length - 1];
|
|
431
|
-
const relation = edge._original
|
|
432
|
-
const sourceColor = nodeColorMap.get(String(edge.source))
|
|
433
|
-
const targetColor = nodeColorMap.get(String(edge.target))
|
|
426
|
+
const relation = (_d = edge._original) === null || _d === void 0 ? void 0 : _d.relation;
|
|
427
|
+
const sourceColor = (_e = nodeColorMap.get(String(edge.source))) !== null && _e !== void 0 ? _e : defaultStroke;
|
|
428
|
+
const targetColor = (_f = nodeColorMap.get(String(edge.target))) !== null && _f !== void 0 ? _f : defaultStroke;
|
|
434
429
|
const gradientKey = `edge-gradient-${String(sourceColor)}-${String(targetColor)}`.replace(/[^a-zA-Z0-9_-]/g, '');
|
|
435
430
|
const edgeStroke = edgeColorMode === 'gradient' ? `url(#${gradientKey})` : defaultStroke;
|
|
436
431
|
let pathD = '';
|
|
@@ -449,7 +444,7 @@ const RelationDagreFlow = (props) => {
|
|
|
449
444
|
const end = endPoint;
|
|
450
445
|
defsElements.push((0, jsx_runtime_1.jsxs)("linearGradient", { id: gradientKey, gradientUnits: "userSpaceOnUse", x1: start[0] + pointsOffsetX, y1: start[1] + pointsOffsetY, x2: end[0] + pointsOffsetX, y2: end[1] + pointsOffsetY, children: [(0, jsx_runtime_1.jsx)("stop", { offset: "0%", stopColor: sourceColor }), (0, jsx_runtime_1.jsx)("stop", { offset: "100%", stopColor: targetColor })] }));
|
|
451
446
|
}
|
|
452
|
-
if (relation
|
|
447
|
+
if (relation === null || relation === void 0 ? void 0 : relation.label) {
|
|
453
448
|
let labelPoint = null;
|
|
454
449
|
const midPoint = getMidPoint(points);
|
|
455
450
|
if (midPoint) {
|
|
@@ -466,9 +461,9 @@ const RelationDagreFlow = (props) => {
|
|
|
466
461
|
decorElements.push((0, jsx_runtime_1.jsx)(jsx_1.Text, { x: labelX, y: labelY, width: labelBounds.width, height: labelBounds.height, fontSize: 14, fontWeight: "normal", alignHorizontal: "center", alignVertical: "middle", fill: labelTextColor, backgroundColor: labelBackground, children: labelText }));
|
|
467
462
|
}
|
|
468
463
|
}
|
|
469
|
-
const effectiveShowArrow = relation
|
|
470
|
-
const direction = relation
|
|
471
|
-
const edgeArrowType = relation
|
|
464
|
+
const effectiveShowArrow = (_g = relation === null || relation === void 0 ? void 0 : relation.showArrow) !== null && _g !== void 0 ? _g : showArrow;
|
|
465
|
+
const direction = (_h = relation === null || relation === void 0 ? void 0 : relation.direction) !== null && _h !== void 0 ? _h : 'forward';
|
|
466
|
+
const edgeArrowType = (_j = relation === null || relation === void 0 ? void 0 : relation.arrowType) !== null && _j !== void 0 ? _j : arrowType;
|
|
472
467
|
const lastIndex = points.length - 1;
|
|
473
468
|
if (effectiveShowArrow && points.length > 1) {
|
|
474
469
|
if (direction === 'forward' || direction === 'both') {
|
|
@@ -78,8 +78,8 @@ const RelationNetwork = (props) => {
|
|
|
78
78
|
}
|
|
79
79
|
const { nodes, links } = runForceLayout();
|
|
80
80
|
/** --- 偏移 --- */
|
|
81
|
-
const minX = Math.min(...nodes.map((d) => d.x
|
|
82
|
-
const minY = Math.min(...nodes.map((d) => d.y
|
|
81
|
+
const minX = Math.min(...nodes.map((d) => { var _a; return (_a = d.x) !== null && _a !== void 0 ? _a : 0; }));
|
|
82
|
+
const minY = Math.min(...nodes.map((d) => { var _a; return (_a = d.y) !== null && _a !== void 0 ? _a : 0; }));
|
|
83
83
|
const offsetX = Math.max(0, -minX + itemBounds.width / 2);
|
|
84
84
|
const offsetY = Math.max(0, -minY + itemBounds.height / 2);
|
|
85
85
|
const positionBy = (x, y) => ({
|
|
@@ -67,7 +67,7 @@ const SequenceFunnel = (props) => {
|
|
|
67
67
|
}
|
|
68
68
|
const themeColors = (0, utils_1.getThemeColors)(options.themeConfig);
|
|
69
69
|
// 计算各区域尺寸
|
|
70
|
-
const actualFunnelWidth = funnelWidth
|
|
70
|
+
const actualFunnelWidth = funnelWidth !== null && funnelWidth !== void 0 ? funnelWidth : width * 0.55; // 稍微调窄一点漏斗,给右侧留更多空间
|
|
71
71
|
const itemAreaWidth = width - actualFunnelWidth;
|
|
72
72
|
// 漏斗层高度
|
|
73
73
|
const funnelLayerHeight = itemHeight * FUNNEL_LAYER_HEIGHT_RATIO;
|
|
@@ -102,7 +102,7 @@ function Mountain(props) {
|
|
|
102
102
|
centerBottom,
|
|
103
103
|
];
|
|
104
104
|
const toPointsString = (points) => points.map((p) => `${p.x},${p.y}`).join(' ');
|
|
105
|
-
return ((0, jsx_runtime_1.jsxs)(components_1.ShapesGroup, {
|
|
105
|
+
return ((0, jsx_runtime_1.jsxs)(components_1.ShapesGroup, Object.assign({}, props, { children: [(0, jsx_runtime_1.jsx)("polygon", { points: toPointsString(leftTopShape), fill: leftTopColor }), (0, jsx_runtime_1.jsx)("polygon", { points: toPointsString(rightTopShape), fill: rightTopColor }), (0, jsx_runtime_1.jsx)("polygon", { points: toPointsString(leftBottomShape), fill: leftBottomColor }), (0, jsx_runtime_1.jsx)("polygon", { points: toPointsString(rightBottomShape), fill: rightBottomColor })] })));
|
|
106
106
|
}
|
|
107
107
|
function Tree(size) {
|
|
108
108
|
const heightMap = {
|
|
@@ -141,13 +141,13 @@ function Sun(props) {
|
|
|
141
141
|
const angle = (360 / rayCount) * i;
|
|
142
142
|
return ((0, jsx_runtime_1.jsx)("rect", { x: rayX, y: rayY, width: rayWidth, height: rayHeight, rx: cornerRadius, ry: cornerRadius, fill: "#FFCB0E", transform: `rotate(${angle}, ${centerX}, ${centerY})` }));
|
|
143
143
|
});
|
|
144
|
-
return ((0, jsx_runtime_1.jsxs)(components_1.ShapesGroup, {
|
|
144
|
+
return ((0, jsx_runtime_1.jsxs)(components_1.ShapesGroup, Object.assign({}, props, { children: [(0, jsx_runtime_1.jsx)("circle", { cx: centerX, cy: centerY, r: radius, fill: "#FFCB0E" }), ...rays] })));
|
|
145
145
|
}
|
|
146
146
|
function Cloud(props) {
|
|
147
147
|
if (props.type === 'single') {
|
|
148
|
-
return ((0, jsx_runtime_1.jsx)(components_1.ShapesGroup, {
|
|
148
|
+
return ((0, jsx_runtime_1.jsx)(components_1.ShapesGroup, Object.assign({}, props, { width: 54, height: 36, children: (0, jsx_runtime_1.jsx)("path", { d: "M10.2635 13.3806C11.0019 9.99045 12.7381 6.91002 15.2405 4.55004C17.743 2.19007 20.8929 0.662716 24.2701 0.171643C27.6473 -0.31943 31.0914 0.24912 34.143 1.80148C37.1946 3.35385 39.7087 5.81625 41.3501 8.86031C44.8835 9.0468 48.1994 10.6544 50.5684 13.3294C52.9373 16.0044 54.1653 19.5277 53.9821 23.1242C53.7989 26.7207 52.2195 30.0959 49.5914 32.5071C46.9634 34.9184 43.5019 36.1683 39.9684 35.9818H11.1517C4.93436 35.9818 0 30.9593 0 24.6309C0.0598447 21.8016 1.13799 19.093 3.02989 17.0192C4.9218 14.9454 7.49584 13.6506 10.2635 13.3806Z", fill: "#70CAF8" }) })));
|
|
149
149
|
}
|
|
150
|
-
return ((0, jsx_runtime_1.jsxs)(components_1.ShapesGroup, {
|
|
150
|
+
return ((0, jsx_runtime_1.jsxs)(components_1.ShapesGroup, Object.assign({}, props, { width: 73, height: 40, children: [(0, jsx_runtime_1.jsx)("path", { d: "M61.6461 14.9716C60.8681 11.1875 58.9581 7.73823 56.1763 5.09315C53.3944 2.44806 49.8758 0.735682 46.0992 0.189041C42.3226 -0.357601 38.4714 0.288046 35.0699 2.03812C31.6683 3.7882 28.8815 6.5577 27.0889 9.96971C23.161 10.1687 19.4719 11.9405 16.8333 14.8953C14.1947 17.8502 12.8227 21.746 13.0191 25.7258C13.2155 29.7055 14.9642 33.4433 17.8806 36.1167C20.7969 38.7901 24.642 40.1802 28.5699 39.9812H60.6588C67.5702 39.9812 73.0006 34.4791 73.0006 27.4764C73.0006 20.9739 67.8664 15.4718 61.6461 14.9716Z", fill: "#70CAF8" }), (0, jsx_runtime_1.jsx)("path", { d: "M21.9691 6.47136e-09C25.9369 6.47136e-09 29.5264 1.62125 32.0003 4.21094C30.0604 5.7917 28.4423 7.75571 27.2581 10C23.3149 10.1989 19.6111 11.9702 16.9622 14.9238C14.3136 17.8774 12.936 21.772 13.1331 25.75C13.2057 27.2131 13.4902 28.6432 13.9652 30H10.7689C7.96116 29.8907 5.29664 28.7203 3.30402 26.7217C1.31144 24.7231 0.135825 22.0419 0.0110544 19.21C-0.113702 16.378 0.821178 13.6017 2.63019 11.4326C4.43921 9.26356 6.99065 7.8602 9.77766 7.5C11.9582 3.00012 16.6168 8.76701e-05 21.9691 6.47136e-09Z", fill: "#5BA2C6" })] })));
|
|
151
151
|
}
|
|
152
152
|
const SequenceMountain = (props) => {
|
|
153
153
|
const { Title, Item, data, gap = 20, minHeight = 100, maxHeight = 200, minWidth = 260, maxWidth = 300, options, } = props;
|
|
@@ -60,7 +60,7 @@ const SequencePyramid = (props) => {
|
|
|
60
60
|
const backgroundElements = [];
|
|
61
61
|
const iconElements = [];
|
|
62
62
|
// Calculate dimensions
|
|
63
|
-
const actualPyramidWidth = pyramidWidth
|
|
63
|
+
const actualPyramidWidth = pyramidWidth !== null && pyramidWidth !== void 0 ? pyramidWidth : width * 0.6;
|
|
64
64
|
const itemAreaWidth = width - actualPyramidWidth;
|
|
65
65
|
// Pyramid layer height should be greater than itemHeight
|
|
66
66
|
const pyramidLayerHeight = itemHeight * 1.2; // Magic number: 20% larger than itemHeight
|
|
@@ -26,6 +26,7 @@ const DECO_OFFSET_Y = 40 + W_PATH_W / 2;
|
|
|
26
26
|
// 滤镜定义
|
|
27
27
|
const GlowFilter = ((0, jsx_runtime_1.jsx)("filter", { id: "sequence-zigzag-glow-filter", x: "-50%", y: "-50%", width: "200%", height: "200%", children: (0, jsx_runtime_1.jsx)("feGaussianBlur", { in: "SourceGraphic", stdDeviation: "15", result: "blur" }) }));
|
|
28
28
|
const SequenceZigzagSteps = (props) => {
|
|
29
|
+
var _a;
|
|
29
30
|
const { Title, Item, data, options, dx = DX, dy = DY, iconSize = 30 } = props;
|
|
30
31
|
const { title, desc, items = [] } = data;
|
|
31
32
|
const titleContent = Title ? (0, jsx_runtime_1.jsx)(Title, { title: title, desc: desc }) : null;
|
|
@@ -118,7 +119,7 @@ const SequenceZigzagSteps = (props) => {
|
|
|
118
119
|
}
|
|
119
120
|
});
|
|
120
121
|
if (pathD) {
|
|
121
|
-
const finalX = (pathPoints[pathPoints.length - 1]
|
|
122
|
+
const finalX = (((_a = pathPoints[pathPoints.length - 1]) === null || _a === void 0 ? void 0 : _a.x) || 0) + offsetX;
|
|
122
123
|
pathElements.push((0, jsx_runtime_1.jsx)(jsx_1.Path, { d: pathD, stroke: "#f3f2f1", strokeWidth: W_PATH_W, fill: "none", width: finalX, height: maxItemY - Math.min(minPathY + offsetY, 0) }));
|
|
123
124
|
}
|
|
124
125
|
return ((0, jsx_runtime_1.jsxs)(layouts_1.FlexLayout, { id: "infographic-container", flexDirection: "column", justifyContent: "center", alignItems: "center", gap: 30, children: [(0, jsx_runtime_1.jsx)(jsx_1.Defs, { children: GlowFilter }), titleContent, (0, jsx_runtime_1.jsxs)(jsx_1.Group, { x: 0, y: 0, children: [(0, jsx_runtime_1.jsx)(jsx_1.Group, { children: [...pathElements, ...decoElements, ...iconElements] }), (0, jsx_runtime_1.jsx)(components_1.ItemsGroup, { children: itemElements }), (0, jsx_runtime_1.jsx)(components_1.BtnsGroup, { children: btnElements })] })] }));
|
|
@@ -9,21 +9,25 @@ const themes_1 = require("../../themes");
|
|
|
9
9
|
const utils_1 = require("../../utils");
|
|
10
10
|
const DEFAULT_COLOR = '#FF356A';
|
|
11
11
|
function getColorPrimary(options) {
|
|
12
|
-
|
|
12
|
+
var _a;
|
|
13
|
+
return ((_a = options === null || options === void 0 ? void 0 : options.themeConfig) === null || _a === void 0 ? void 0 : _a.colorPrimary) || DEFAULT_COLOR;
|
|
13
14
|
}
|
|
14
15
|
function getPaletteColors(options) {
|
|
16
|
+
var _a;
|
|
15
17
|
const { themeConfig = {}, data } = options;
|
|
16
18
|
const { colorPrimary, palette } = themeConfig;
|
|
17
19
|
if (!palette || palette.length === 0) {
|
|
18
|
-
return Array(data
|
|
20
|
+
return Array(((_a = data === null || data === void 0 ? void 0 : data.items) === null || _a === void 0 ? void 0 : _a.length) || 1).fill(colorPrimary || DEFAULT_COLOR);
|
|
19
21
|
}
|
|
20
22
|
return data.items.map((_, i) => (0, renderer_1.getPaletteColor)(palette, [i], data.items.length) || DEFAULT_COLOR);
|
|
21
23
|
}
|
|
22
24
|
function getPaletteColor(options, indexes) {
|
|
23
|
-
|
|
25
|
+
var _a, _b, _c;
|
|
26
|
+
return (0, renderer_1.getPaletteColor)((_a = options === null || options === void 0 ? void 0 : options.themeConfig) === null || _a === void 0 ? void 0 : _a.palette, indexes, (_c = (_b = options.data) === null || _b === void 0 ? void 0 : _b.items) === null || _c === void 0 ? void 0 : _c.length);
|
|
24
27
|
}
|
|
25
28
|
function getThemeColors(colors, options) {
|
|
26
|
-
|
|
29
|
+
var _a;
|
|
30
|
+
const { colorBg = ((_a = options === null || options === void 0 ? void 0 : options.themeConfig) === null || _a === void 0 ? void 0 : _a.colorBg) || 'white', colorPrimary = options ? getColorPrimary(options) : 'black', } = colors;
|
|
27
31
|
return (0, themes_1.generateThemeColors)({
|
|
28
32
|
colorPrimary: colorPrimary,
|
|
29
33
|
isDarkMode: (0, utils_1.isDarkColor)(colorBg),
|
|
@@ -9,7 +9,7 @@ exports.getItemComponent = getItemComponent;
|
|
|
9
9
|
* @returns
|
|
10
10
|
*/
|
|
11
11
|
function getItemProps(props, extKeys = []) {
|
|
12
|
-
const restProps = {
|
|
12
|
+
const restProps = Object.assign({}, props);
|
|
13
13
|
const extProps = {};
|
|
14
14
|
const keys = [
|
|
15
15
|
'indexes',
|
|
@@ -39,9 +39,10 @@ function getItemProps(props, extKeys = []) {
|
|
|
39
39
|
* 针对层级结构,获取当前层级对应的组件
|
|
40
40
|
*/
|
|
41
41
|
function getItemComponent(Items, level) {
|
|
42
|
+
var _a;
|
|
42
43
|
if (Items.length === 0)
|
|
43
44
|
return () => null;
|
|
44
45
|
if (level === undefined)
|
|
45
46
|
return Items[0];
|
|
46
|
-
return Items[level]
|
|
47
|
+
return (_a = Items[level]) !== null && _a !== void 0 ? _a : Items[0];
|
|
47
48
|
}
|
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.BatchCommand = void 0;
|
|
4
13
|
class BatchCommand {
|
|
5
14
|
constructor(commands) {
|
|
6
15
|
this.commands = commands;
|
|
7
16
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
17
|
+
apply(state) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
for (const command of this.commands) {
|
|
20
|
+
yield command.apply(state);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
12
23
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
24
|
+
undo(state) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
for (let i = this.commands.length - 1; i >= 0; i--) {
|
|
27
|
+
yield this.commands[i].undo(state);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
17
30
|
}
|
|
18
31
|
serialize() {
|
|
19
32
|
return {
|