@antv/infographic 0.0.1-beta.1 → 0.0.1-beta.2
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/esm/designs/items/BadgeCard.js +11 -6
- package/esm/designs/items/CircularProgress.js +3 -2
- package/esm/designs/items/DoneList.js +4 -4
- package/esm/designs/structures/list-column.js +1 -1
- package/esm/resource/types/resource.d.ts +1 -1
- package/lib/designs/items/BadgeCard.js +10 -5
- package/lib/designs/items/CircularProgress.js +2 -1
- package/lib/designs/items/DoneList.js +3 -3
- package/lib/designs/structures/list-column.js +1 -1
- package/lib/resource/types/resource.d.ts +1 -1
- package/package.json +1 -1
- package/src/designs/items/BadgeCard.tsx +29 -20
- package/src/designs/items/CircularProgress.tsx +6 -9
- package/src/designs/items/DoneList.tsx +10 -9
- package/src/designs/structures/list-column.tsx +1 -1
- package/src/options/parser.ts +1 -0
- package/src/resource/types/resource.ts +3 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "@antv/infographic-jsx/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@antv/infographic-jsx/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @antv/infographic-jsx */
|
|
3
3
|
import { Defs, Ellipse, Group, Rect, } from '@antv/infographic-jsx';
|
|
4
4
|
import tinycolor from 'tinycolor2';
|
|
@@ -9,13 +9,18 @@ import { registerItem } from './registry';
|
|
|
9
9
|
export const BadgeCard = (props) => {
|
|
10
10
|
const [{ datum, indexes, width = 200, height = 80, iconSize = 24, badgeSize = 32, gap = 8, positionH = 'normal', themeColors, valueFormatter, }, restProps,] = getItemProps(props, ['width', 'height', 'iconSize', 'badgeSize', 'gap']);
|
|
11
11
|
const value = datum.value;
|
|
12
|
+
const hasValue = value !== undefined;
|
|
13
|
+
const hasDesc = !!datum.desc;
|
|
14
|
+
const hasIcon = !!datum.icon;
|
|
12
15
|
const gradientId = `${themeColors.colorPrimary}-badge`;
|
|
13
16
|
const badgeX = positionH === 'flipped' ? width - gap - badgeSize : gap;
|
|
14
|
-
const contentStartX =
|
|
15
|
-
|
|
17
|
+
const contentStartX = hasIcon
|
|
18
|
+
? positionH === 'flipped'
|
|
19
|
+
? gap
|
|
20
|
+
: badgeSize + 2 * gap
|
|
21
|
+
: gap; // 没有图标时从左边距开始
|
|
16
22
|
const fullWidth = width - gap * 2;
|
|
17
|
-
const
|
|
18
|
-
const hasDesc = !!datum.desc;
|
|
23
|
+
const contentWidth = hasIcon ? width - badgeSize - 3 * gap : fullWidth;
|
|
19
24
|
// 描述区域的固定位置(label + value 区域的下方)
|
|
20
25
|
const descY = gap + 14 + 18 + 8; // label(14) + value(18) + gap(8)
|
|
21
26
|
const contentAreaHeight = descY - gap; // label 和 value 占据的总高度
|
|
@@ -25,7 +30,7 @@ export const BadgeCard = (props) => {
|
|
|
25
30
|
const contentY = !hasValue && !hasDesc ? (height - 14) / 2 : gap;
|
|
26
31
|
return (_jsxs(Group, { ...restProps, width: width, height: height, children: [_jsx(Defs, { children: _jsxs("radialGradient", { id: gradientId, cx: "50%", cy: "50%", r: "50%", children: [_jsx("stop", { offset: "0%", stopColor: themeColors.colorPrimary }), _jsx("stop", { offset: "100%", stopColor: tinycolor(themeColors.colorPrimary)
|
|
27
32
|
.darken(20)
|
|
28
|
-
.toHexString() })] }) }), _jsx(Rect, { x: 0, y: 0, width: width, height: height, fill: themeColors.colorPrimaryBg, rx: 8, ry: 8 }), _jsx(Ellipse, { x: badgeX, y: badgeY, width: badgeSize, height: badgeSize, fill: `url(#${gradientId})` }), _jsx(ItemIcon, { indexes: indexes, x: badgeX + (badgeSize - iconSize) / 2, y: badgeY + (badgeSize - iconSize) / 2, size: iconSize, fill: themeColors.colorWhite }), _jsxs(FlexLayout, { flexDirection: "column", x: contentStartX, y: contentY, width: contentWidth, height: !hasValue && !hasDesc ? undefined : contentAreaHeight, alignItems: "center", justifyContent: "center", children: [_jsx(ItemLabel, { indexes: indexes, width: contentWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', alignVertical: 'center', fontSize: 14, fill: themeColors.colorText, children: datum.label }), hasValue && (_jsx(ItemValue, { indexes: indexes, width: contentWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', alignVertical: "center", fontSize: 18, lineHeight: 1, fontWeight: "bold", fill: themeColors.colorPrimary, value: value, formatter: valueFormatter }))] }), hasDesc && (_jsx(ItemDesc, { indexes: indexes, x: gap, y: descY, width: fullWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', fontSize: 11, fill: themeColors.colorTextSecondary, lineNumber: 2, lineHeight: 1.2, wordWrap: true, children: datum.desc }))] }));
|
|
33
|
+
.toHexString() })] }) }), _jsx(Rect, { x: 0, y: 0, width: width, height: height, fill: themeColors.colorPrimaryBg, rx: 8, ry: 8 }), hasIcon && (_jsxs(_Fragment, { children: [_jsx(Ellipse, { x: badgeX, y: badgeY, width: badgeSize, height: badgeSize, fill: `url(#${gradientId})` }), _jsx(ItemIcon, { indexes: indexes, x: badgeX + (badgeSize - iconSize) / 2, y: badgeY + (badgeSize - iconSize) / 2, size: iconSize, fill: themeColors.colorWhite })] })), _jsxs(FlexLayout, { flexDirection: "column", x: contentStartX, y: contentY, width: contentWidth, height: !hasValue && !hasDesc ? undefined : contentAreaHeight, alignItems: "center", justifyContent: "center", children: [_jsx(ItemLabel, { indexes: indexes, width: contentWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', alignVertical: 'center', fontSize: 14, fill: themeColors.colorText, children: datum.label }), hasValue && (_jsx(ItemValue, { indexes: indexes, width: contentWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', alignVertical: "center", fontSize: 18, lineHeight: 1, fontWeight: "bold", fill: themeColors.colorPrimary, value: value, formatter: valueFormatter }))] }), hasDesc && (_jsx(ItemDesc, { indexes: indexes, x: gap, y: descY, width: fullWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', fontSize: 11, fill: themeColors.colorTextSecondary, lineNumber: 2, lineHeight: 1.2, wordWrap: true, children: datum.desc }))] }));
|
|
29
34
|
};
|
|
30
35
|
registerItem('badge-card', {
|
|
31
36
|
component: BadgeCard,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@antv/infographic-jsx/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @antv/infographic-jsx */
|
|
3
|
-
import { Ellipse, Group } from '@antv/infographic-jsx';
|
|
3
|
+
import { Ellipse, Group, Rect } from '@antv/infographic-jsx';
|
|
4
4
|
import { ItemLabel, ItemValue } from '../components';
|
|
5
5
|
import { getItemProps } from '../utils';
|
|
6
6
|
import { registerItem } from './registry';
|
|
@@ -16,7 +16,8 @@ export const CircularProgress = (props) => {
|
|
|
16
16
|
const center = size / 2;
|
|
17
17
|
const start = strokeWidth / 2;
|
|
18
18
|
const d = size - strokeWidth;
|
|
19
|
-
|
|
19
|
+
const bounds = { x: start, y: start, width: d, height: d };
|
|
20
|
+
return (_jsxs(Group, { ...restProps, width: size, height: size + gap + 20, children: [_jsx(Rect, { width: size, height: size, fill: "none" }), _jsx(Ellipse, { ...bounds, fill: "none", stroke: "#f0f0f0", strokeWidth: strokeWidth }), _jsx(Ellipse, { ...bounds, fill: "none", stroke: themeColors.colorPrimary, strokeWidth: strokeWidth, strokeLinecap: "round", strokeDasharray: strokeDasharray, strokeDashoffset: strokeDashoffset, transform: `rotate(-90 ${center} ${center})` }), _jsx(ItemValue, { indexes: indexes, x: strokeWidth, y: strokeWidth, width: d - strokeWidth, height: d - strokeWidth, fontSize: 24, fontWeight: "bold", fill: themeColors.colorPrimary, alignHorizontal: "center", alignVertical: "center", value: value, formatter: valueFormatter }), _jsx(ItemLabel, { indexes: indexes, x: 0, y: size + gap, width: size, alignHorizontal: "center", fontSize: 12, fill: themeColors.colorTextSecondary, children: datum.label })] }));
|
|
20
21
|
};
|
|
21
22
|
registerItem('circular-progress', {
|
|
22
23
|
component: CircularProgress,
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "@antv/infographic-jsx/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @antv/infographic-jsx */
|
|
3
3
|
import { Group, Path } from '@antv/infographic-jsx';
|
|
4
|
-
import {
|
|
4
|
+
import { ItemLabel } from '../components';
|
|
5
5
|
import { getItemId, getItemProps } from '../utils';
|
|
6
6
|
import { registerItem } from './registry';
|
|
7
7
|
export const DoneList = (props) => {
|
|
8
8
|
const [{ datum, indexes, width = 300, height = 30, iconSize = 30, gap = 5, positionH = 'normal', positionV = 'center', themeColors, }, restProps,] = getItemProps(props, ['width', 'height', 'iconSize', 'gap']);
|
|
9
|
-
const
|
|
9
|
+
const textWidth = width - iconSize - gap;
|
|
10
10
|
const shapeY = positionV === 'center'
|
|
11
11
|
? (height - iconSize) / 2
|
|
12
12
|
: positionV === 'flipped'
|
|
13
13
|
? height - iconSize
|
|
14
14
|
: 0;
|
|
15
|
-
return (_jsxs(Group, { ...restProps, children: [_jsx(Path, { id: getItemId(indexes, 'shape', 'done-icon'), x: positionH === 'flipped' ?
|
|
15
|
+
return (_jsxs(Group, { ...restProps, children: [_jsx(Path, { id: getItemId(indexes, 'shape', 'done-icon'), x: positionH === 'flipped' ? textWidth + gap : 0, y: shapeY, fill: themeColors.colorPrimary, width: iconSize, height: iconSize, d: "M14.7273 30C6.54538 30 0 22.9077 0 14.7269C0 6.54617 6.54538 0 14.7273 0C22.9092 0 30 6.54617 30 14.7269C30 22.9077 22.9092 30 14.7273 30ZM24.5454 10.9077C22.9092 9.27307 22.9092 9.27307 22.9092 9.27307C22.3638 8.72692 22.3638 8.7269 21.8181 8.7269C21.2727 8.7269 21.2727 8.72692 20.7273 9.27307C13.0908 16.9077 13.0908 16.9077 13.0908 16.9077C8.72731 12.5461 8.72731 12.5462 8.72731 12.5462C8.18193 12.5462 8.18193 12 7.63654 12L7.09077 12.5462C4.90923 14.1808 4.90923 14.1808 4.90923 14.1808C4.90923 14.7269 4.90923 14.7269 4.90923 15.2731C4.90923 15.8192 4.90923 15.8192 4.90923 16.3654C12 23.4539 12 23.4538 12 23.4538C12.5454 23.4538 12.5454 23.4538 13.0908 23.4538C13.6365 23.4538 13.6365 23.4538 14.1819 23.4538C24.5454 12.5461 24.5454 12.5462 24.5454 12.5462L25.0908 12C25.0908 11.4538 24.5454 10.9077 24.5454 10.9077Z" }), _jsx(ItemLabel, { indexes: indexes, x: positionH === 'flipped' ? 0 : iconSize + gap, width: textWidth, height: height, fontWeight: "normal", alignVertical: "center", wordWrap: false, fill: "#666", children: datum.label || datum.desc })] }));
|
|
16
16
|
};
|
|
17
17
|
registerItem('done-list', {
|
|
18
18
|
component: DoneList,
|
|
19
|
-
composites: ['
|
|
19
|
+
composites: ['label'],
|
|
20
20
|
});
|
|
@@ -16,7 +16,7 @@ export const ListColumn = (props) => {
|
|
|
16
16
|
items.forEach((item, index) => {
|
|
17
17
|
const itemY = (itemBounds.height + gap) * index;
|
|
18
18
|
const indexes = [index];
|
|
19
|
-
itemElements.push(_jsx(Item, { indexes: indexes, datum: item, data: data, y: itemY, width: width, positionV: "center", positionH: zigzag
|
|
19
|
+
itemElements.push(_jsx(Item, { indexes: indexes, datum: item, data: data, y: itemY, width: width, positionV: "center", positionH: zigzag ? (index % 2 === 0 ? 'normal' : 'flipped') : 'normal' }));
|
|
20
20
|
btnElements.push(_jsx(BtnRemove, { indexes: indexes, x: -btnBounds.width - 10, y: itemY + (itemBounds.height - btnBounds.height) / 2 }));
|
|
21
21
|
const btnAddY = index === 0 ? -btnBounds.height : itemY - gap / 2 - btnBounds.height / 2;
|
|
22
22
|
btnElements.push(_jsx(BtnAdd, { indexes: indexes, x: btnAddX, y: btnAddY }));
|
|
@@ -15,13 +15,18 @@ const registry_1 = require("./registry");
|
|
|
15
15
|
const BadgeCard = (props) => {
|
|
16
16
|
const [{ datum, indexes, width = 200, height = 80, iconSize = 24, badgeSize = 32, gap = 8, positionH = 'normal', themeColors, valueFormatter, }, restProps,] = (0, utils_1.getItemProps)(props, ['width', 'height', 'iconSize', 'badgeSize', 'gap']);
|
|
17
17
|
const value = datum.value;
|
|
18
|
+
const hasValue = value !== undefined;
|
|
19
|
+
const hasDesc = !!datum.desc;
|
|
20
|
+
const hasIcon = !!datum.icon;
|
|
18
21
|
const gradientId = `${themeColors.colorPrimary}-badge`;
|
|
19
22
|
const badgeX = positionH === 'flipped' ? width - gap - badgeSize : gap;
|
|
20
|
-
const contentStartX =
|
|
21
|
-
|
|
23
|
+
const contentStartX = hasIcon
|
|
24
|
+
? positionH === 'flipped'
|
|
25
|
+
? gap
|
|
26
|
+
: badgeSize + 2 * gap
|
|
27
|
+
: gap; // 没有图标时从左边距开始
|
|
22
28
|
const fullWidth = width - gap * 2;
|
|
23
|
-
const
|
|
24
|
-
const hasDesc = !!datum.desc;
|
|
29
|
+
const contentWidth = hasIcon ? width - badgeSize - 3 * gap : fullWidth;
|
|
25
30
|
// 描述区域的固定位置(label + value 区域的下方)
|
|
26
31
|
const descY = gap + 14 + 18 + 8; // label(14) + value(18) + gap(8)
|
|
27
32
|
const contentAreaHeight = descY - gap; // label 和 value 占据的总高度
|
|
@@ -31,7 +36,7 @@ const BadgeCard = (props) => {
|
|
|
31
36
|
const contentY = !hasValue && !hasDesc ? (height - 14) / 2 : gap;
|
|
32
37
|
return ((0, jsx_runtime_1.jsxs)(infographic_jsx_1.Group, { ...restProps, width: width, height: height, children: [(0, jsx_runtime_1.jsx)(infographic_jsx_1.Defs, { children: (0, jsx_runtime_1.jsxs)("radialGradient", { id: gradientId, cx: "50%", cy: "50%", r: "50%", children: [(0, jsx_runtime_1.jsx)("stop", { offset: "0%", stopColor: themeColors.colorPrimary }), (0, jsx_runtime_1.jsx)("stop", { offset: "100%", stopColor: (0, tinycolor2_1.default)(themeColors.colorPrimary)
|
|
33
38
|
.darken(20)
|
|
34
|
-
.toHexString() })] }) }), (0, jsx_runtime_1.jsx)(infographic_jsx_1.Rect, { x: 0, y: 0, width: width, height: height, fill: themeColors.colorPrimaryBg, rx: 8, ry: 8 }), (0, jsx_runtime_1.jsx)(infographic_jsx_1.Ellipse, { x: badgeX, y: badgeY, width: badgeSize, height: badgeSize, fill: `url(#${gradientId})` }), (0, jsx_runtime_1.jsx)(components_1.ItemIcon, { indexes: indexes, x: badgeX + (badgeSize - iconSize) / 2, y: badgeY + (badgeSize - iconSize) / 2, size: iconSize, fill: themeColors.colorWhite }), (0, jsx_runtime_1.jsxs)(layouts_1.FlexLayout, { flexDirection: "column", x: contentStartX, y: contentY, width: contentWidth, height: !hasValue && !hasDesc ? undefined : contentAreaHeight, alignItems: "center", justifyContent: "center", children: [(0, jsx_runtime_1.jsx)(components_1.ItemLabel, { indexes: indexes, width: contentWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', alignVertical: 'center', fontSize: 14, fill: themeColors.colorText, children: datum.label }), hasValue && ((0, jsx_runtime_1.jsx)(components_1.ItemValue, { indexes: indexes, width: contentWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', alignVertical: "center", fontSize: 18, lineHeight: 1, fontWeight: "bold", fill: themeColors.colorPrimary, value: value, formatter: valueFormatter }))] }), hasDesc && ((0, jsx_runtime_1.jsx)(components_1.ItemDesc, { indexes: indexes, x: gap, y: descY, width: fullWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', fontSize: 11, fill: themeColors.colorTextSecondary, lineNumber: 2, lineHeight: 1.2, wordWrap: true, children: datum.desc }))] }));
|
|
39
|
+
.toHexString() })] }) }), (0, jsx_runtime_1.jsx)(infographic_jsx_1.Rect, { x: 0, y: 0, width: width, height: height, fill: themeColors.colorPrimaryBg, rx: 8, ry: 8 }), hasIcon && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(infographic_jsx_1.Ellipse, { x: badgeX, y: badgeY, width: badgeSize, height: badgeSize, fill: `url(#${gradientId})` }), (0, jsx_runtime_1.jsx)(components_1.ItemIcon, { indexes: indexes, x: badgeX + (badgeSize - iconSize) / 2, y: badgeY + (badgeSize - iconSize) / 2, size: iconSize, fill: themeColors.colorWhite })] })), (0, jsx_runtime_1.jsxs)(layouts_1.FlexLayout, { flexDirection: "column", x: contentStartX, y: contentY, width: contentWidth, height: !hasValue && !hasDesc ? undefined : contentAreaHeight, alignItems: "center", justifyContent: "center", children: [(0, jsx_runtime_1.jsx)(components_1.ItemLabel, { indexes: indexes, width: contentWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', alignVertical: 'center', fontSize: 14, fill: themeColors.colorText, children: datum.label }), hasValue && ((0, jsx_runtime_1.jsx)(components_1.ItemValue, { indexes: indexes, width: contentWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', alignVertical: "center", fontSize: 18, lineHeight: 1, fontWeight: "bold", fill: themeColors.colorPrimary, value: value, formatter: valueFormatter }))] }), hasDesc && ((0, jsx_runtime_1.jsx)(components_1.ItemDesc, { indexes: indexes, x: gap, y: descY, width: fullWidth, alignHorizontal: positionH === 'flipped' ? 'right' : 'left', fontSize: 11, fill: themeColors.colorTextSecondary, lineNumber: 2, lineHeight: 1.2, wordWrap: true, children: datum.desc }))] }));
|
|
35
40
|
};
|
|
36
41
|
exports.BadgeCard = BadgeCard;
|
|
37
42
|
(0, registry_1.registerItem)('badge-card', {
|
|
@@ -19,7 +19,8 @@ const CircularProgress = (props) => {
|
|
|
19
19
|
const center = size / 2;
|
|
20
20
|
const start = strokeWidth / 2;
|
|
21
21
|
const d = size - strokeWidth;
|
|
22
|
-
|
|
22
|
+
const bounds = { x: start, y: start, width: d, height: d };
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)(infographic_jsx_1.Group, { ...restProps, width: size, height: size + gap + 20, children: [(0, jsx_runtime_1.jsx)(infographic_jsx_1.Rect, { width: size, height: size, fill: "none" }), (0, jsx_runtime_1.jsx)(infographic_jsx_1.Ellipse, { ...bounds, fill: "none", stroke: "#f0f0f0", strokeWidth: strokeWidth }), (0, jsx_runtime_1.jsx)(infographic_jsx_1.Ellipse, { ...bounds, fill: "none", stroke: themeColors.colorPrimary, strokeWidth: strokeWidth, strokeLinecap: "round", strokeDasharray: strokeDasharray, strokeDashoffset: strokeDashoffset, transform: `rotate(-90 ${center} ${center})` }), (0, jsx_runtime_1.jsx)(components_1.ItemValue, { indexes: indexes, x: strokeWidth, y: strokeWidth, width: d - strokeWidth, height: d - strokeWidth, fontSize: 24, fontWeight: "bold", fill: themeColors.colorPrimary, alignHorizontal: "center", alignVertical: "center", value: value, formatter: valueFormatter }), (0, jsx_runtime_1.jsx)(components_1.ItemLabel, { indexes: indexes, x: 0, y: size + gap, width: size, alignHorizontal: "center", fontSize: 12, fill: themeColors.colorTextSecondary, children: datum.label })] }));
|
|
23
24
|
};
|
|
24
25
|
exports.CircularProgress = CircularProgress;
|
|
25
26
|
(0, registry_1.registerItem)('circular-progress', {
|
|
@@ -9,16 +9,16 @@ const utils_1 = require("../utils");
|
|
|
9
9
|
const registry_1 = require("./registry");
|
|
10
10
|
const DoneList = (props) => {
|
|
11
11
|
const [{ datum, indexes, width = 300, height = 30, iconSize = 30, gap = 5, positionH = 'normal', positionV = 'center', themeColors, }, restProps,] = (0, utils_1.getItemProps)(props, ['width', 'height', 'iconSize', 'gap']);
|
|
12
|
-
const
|
|
12
|
+
const textWidth = width - iconSize - gap;
|
|
13
13
|
const shapeY = positionV === 'center'
|
|
14
14
|
? (height - iconSize) / 2
|
|
15
15
|
: positionV === 'flipped'
|
|
16
16
|
? height - iconSize
|
|
17
17
|
: 0;
|
|
18
|
-
return ((0, jsx_runtime_1.jsxs)(infographic_jsx_1.Group, { ...restProps, children: [(0, jsx_runtime_1.jsx)(infographic_jsx_1.Path, { id: (0, utils_1.getItemId)(indexes, 'shape', 'done-icon'), x: positionH === 'flipped' ?
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)(infographic_jsx_1.Group, { ...restProps, children: [(0, jsx_runtime_1.jsx)(infographic_jsx_1.Path, { id: (0, utils_1.getItemId)(indexes, 'shape', 'done-icon'), x: positionH === 'flipped' ? textWidth + gap : 0, y: shapeY, fill: themeColors.colorPrimary, width: iconSize, height: iconSize, d: "M14.7273 30C6.54538 30 0 22.9077 0 14.7269C0 6.54617 6.54538 0 14.7273 0C22.9092 0 30 6.54617 30 14.7269C30 22.9077 22.9092 30 14.7273 30ZM24.5454 10.9077C22.9092 9.27307 22.9092 9.27307 22.9092 9.27307C22.3638 8.72692 22.3638 8.7269 21.8181 8.7269C21.2727 8.7269 21.2727 8.72692 20.7273 9.27307C13.0908 16.9077 13.0908 16.9077 13.0908 16.9077C8.72731 12.5461 8.72731 12.5462 8.72731 12.5462C8.18193 12.5462 8.18193 12 7.63654 12L7.09077 12.5462C4.90923 14.1808 4.90923 14.1808 4.90923 14.1808C4.90923 14.7269 4.90923 14.7269 4.90923 15.2731C4.90923 15.8192 4.90923 15.8192 4.90923 16.3654C12 23.4539 12 23.4538 12 23.4538C12.5454 23.4538 12.5454 23.4538 13.0908 23.4538C13.6365 23.4538 13.6365 23.4538 14.1819 23.4538C24.5454 12.5461 24.5454 12.5462 24.5454 12.5462L25.0908 12C25.0908 11.4538 24.5454 10.9077 24.5454 10.9077Z" }), (0, jsx_runtime_1.jsx)(components_1.ItemLabel, { indexes: indexes, x: positionH === 'flipped' ? 0 : iconSize + gap, width: textWidth, height: height, fontWeight: "normal", alignVertical: "center", wordWrap: false, fill: "#666", children: datum.label || datum.desc })] }));
|
|
19
19
|
};
|
|
20
20
|
exports.DoneList = DoneList;
|
|
21
21
|
(0, registry_1.registerItem)('done-list', {
|
|
22
22
|
component: exports.DoneList,
|
|
23
|
-
composites: ['
|
|
23
|
+
composites: ['label'],
|
|
24
24
|
});
|
|
@@ -19,7 +19,7 @@ const ListColumn = (props) => {
|
|
|
19
19
|
items.forEach((item, index) => {
|
|
20
20
|
const itemY = (itemBounds.height + gap) * index;
|
|
21
21
|
const indexes = [index];
|
|
22
|
-
itemElements.push((0, jsx_runtime_1.jsx)(Item, { indexes: indexes, datum: item, data: data, y: itemY, width: width, positionV: "center", positionH: zigzag
|
|
22
|
+
itemElements.push((0, jsx_runtime_1.jsx)(Item, { indexes: indexes, datum: item, data: data, y: itemY, width: width, positionV: "center", positionH: zigzag ? (index % 2 === 0 ? 'normal' : 'flipped') : 'normal' }));
|
|
23
23
|
btnElements.push((0, jsx_runtime_1.jsx)(components_1.BtnRemove, { indexes: indexes, x: -btnBounds.width - 10, y: itemY + (itemBounds.height - btnBounds.height) / 2 }));
|
|
24
24
|
const btnAddY = index === 0 ? -btnBounds.height : itemY - gap / 2 - btnBounds.height / 2;
|
|
25
25
|
btnElements.push((0, jsx_runtime_1.jsx)(components_1.BtnAdd, { indexes: indexes, x: btnAddX, y: btnAddY }));
|
package/package.json
CHANGED
|
@@ -38,14 +38,19 @@ export const BadgeCard: ComponentType<BadgeCardProps> = (props) => {
|
|
|
38
38
|
restProps,
|
|
39
39
|
] = getItemProps(props, ['width', 'height', 'iconSize', 'badgeSize', 'gap']);
|
|
40
40
|
const value = datum.value;
|
|
41
|
+
const hasValue = value !== undefined;
|
|
42
|
+
const hasDesc = !!datum.desc;
|
|
43
|
+
const hasIcon = !!datum.icon;
|
|
41
44
|
const gradientId = `${themeColors.colorPrimary}-badge`;
|
|
42
45
|
|
|
43
46
|
const badgeX = positionH === 'flipped' ? width - gap - badgeSize : gap;
|
|
44
|
-
const contentStartX =
|
|
45
|
-
|
|
47
|
+
const contentStartX = hasIcon
|
|
48
|
+
? positionH === 'flipped'
|
|
49
|
+
? gap
|
|
50
|
+
: badgeSize + 2 * gap
|
|
51
|
+
: gap; // 没有图标时从左边距开始
|
|
46
52
|
const fullWidth = width - gap * 2;
|
|
47
|
-
const
|
|
48
|
-
const hasDesc = !!datum.desc;
|
|
53
|
+
const contentWidth = hasIcon ? width - badgeSize - 3 * gap : fullWidth;
|
|
49
54
|
|
|
50
55
|
// 描述区域的固定位置(label + value 区域的下方)
|
|
51
56
|
const descY = gap + 14 + 18 + 8; // label(14) + value(18) + gap(8)
|
|
@@ -81,23 +86,27 @@ export const BadgeCard: ComponentType<BadgeCardProps> = (props) => {
|
|
|
81
86
|
ry={8}
|
|
82
87
|
/>
|
|
83
88
|
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
89
|
+
{hasIcon && (
|
|
90
|
+
<>
|
|
91
|
+
{/* 徽章背景 */}
|
|
92
|
+
<Ellipse
|
|
93
|
+
x={badgeX}
|
|
94
|
+
y={badgeY}
|
|
95
|
+
width={badgeSize}
|
|
96
|
+
height={badgeSize}
|
|
97
|
+
fill={`url(#${gradientId})`}
|
|
98
|
+
/>
|
|
92
99
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
100
|
+
{/* 徽章图标 */}
|
|
101
|
+
<ItemIcon
|
|
102
|
+
indexes={indexes}
|
|
103
|
+
x={badgeX + (badgeSize - iconSize) / 2}
|
|
104
|
+
y={badgeY + (badgeSize - iconSize) / 2}
|
|
105
|
+
size={iconSize}
|
|
106
|
+
fill={themeColors.colorWhite}
|
|
107
|
+
/>
|
|
108
|
+
</>
|
|
109
|
+
)}
|
|
101
110
|
|
|
102
111
|
{/* 上方内容区域:label 和 value */}
|
|
103
112
|
<FlexLayout
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @jsxImportSource @antv/infographic-jsx */
|
|
2
|
-
import { ComponentType, Ellipse, Group } from '@antv/infographic-jsx';
|
|
2
|
+
import { ComponentType, Ellipse, Group, Rect } from '@antv/infographic-jsx';
|
|
3
3
|
import { ItemLabel, ItemValue } from '../components';
|
|
4
4
|
import { getItemProps } from '../utils';
|
|
5
5
|
import { registerItem } from './registry';
|
|
@@ -40,14 +40,14 @@ export const CircularProgress: ComponentType<CircularProgressProps> = (
|
|
|
40
40
|
const start = strokeWidth / 2;
|
|
41
41
|
const d = size - strokeWidth;
|
|
42
42
|
|
|
43
|
+
const bounds = { x: start, y: start, width: d, height: d };
|
|
43
44
|
return (
|
|
44
45
|
<Group {...restProps} width={size} height={size + gap + 20}>
|
|
46
|
+
{/* 圆环背景轮廓,避免 getBBox 不准确 */}
|
|
47
|
+
<Rect width={size} height={size} fill="none" />
|
|
45
48
|
{/* 完整圆环背景轨道 - 表示100% */}
|
|
46
49
|
<Ellipse
|
|
47
|
-
|
|
48
|
-
y={start}
|
|
49
|
-
width={d}
|
|
50
|
-
height={d}
|
|
50
|
+
{...bounds}
|
|
51
51
|
fill="none"
|
|
52
52
|
stroke="#f0f0f0"
|
|
53
53
|
strokeWidth={strokeWidth}
|
|
@@ -55,10 +55,7 @@ export const CircularProgress: ComponentType<CircularProgressProps> = (
|
|
|
55
55
|
|
|
56
56
|
{/* 进度圆环 */}
|
|
57
57
|
<Ellipse
|
|
58
|
-
|
|
59
|
-
y={start}
|
|
60
|
-
width={d}
|
|
61
|
-
height={d}
|
|
58
|
+
{...bounds}
|
|
62
59
|
fill="none"
|
|
63
60
|
stroke={themeColors.colorPrimary}
|
|
64
61
|
strokeWidth={strokeWidth}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @jsxImportSource @antv/infographic-jsx */
|
|
2
2
|
import { ComponentType, Group, Path } from '@antv/infographic-jsx';
|
|
3
|
-
import {
|
|
3
|
+
import { ItemLabel } from '../components';
|
|
4
4
|
import { getItemId, getItemProps } from '../utils';
|
|
5
5
|
import { registerItem } from './registry';
|
|
6
6
|
import type { BaseItemProps } from './types';
|
|
@@ -28,7 +28,7 @@ export const DoneList: ComponentType<DoneListProps> = (props) => {
|
|
|
28
28
|
restProps,
|
|
29
29
|
] = getItemProps(props, ['width', 'height', 'iconSize', 'gap']);
|
|
30
30
|
|
|
31
|
-
const
|
|
31
|
+
const textWidth = width - iconSize - gap;
|
|
32
32
|
|
|
33
33
|
const shapeY =
|
|
34
34
|
positionV === 'center'
|
|
@@ -41,29 +41,30 @@ export const DoneList: ComponentType<DoneListProps> = (props) => {
|
|
|
41
41
|
<Group {...restProps}>
|
|
42
42
|
<Path
|
|
43
43
|
id={getItemId(indexes, 'shape', 'done-icon')}
|
|
44
|
-
x={positionH === 'flipped' ?
|
|
44
|
+
x={positionH === 'flipped' ? textWidth + gap : 0}
|
|
45
45
|
y={shapeY}
|
|
46
46
|
fill={themeColors.colorPrimary}
|
|
47
47
|
width={iconSize}
|
|
48
48
|
height={iconSize}
|
|
49
49
|
d="M14.7273 30C6.54538 30 0 22.9077 0 14.7269C0 6.54617 6.54538 0 14.7273 0C22.9092 0 30 6.54617 30 14.7269C30 22.9077 22.9092 30 14.7273 30ZM24.5454 10.9077C22.9092 9.27307 22.9092 9.27307 22.9092 9.27307C22.3638 8.72692 22.3638 8.7269 21.8181 8.7269C21.2727 8.7269 21.2727 8.72692 20.7273 9.27307C13.0908 16.9077 13.0908 16.9077 13.0908 16.9077C8.72731 12.5461 8.72731 12.5462 8.72731 12.5462C8.18193 12.5462 8.18193 12 7.63654 12L7.09077 12.5462C4.90923 14.1808 4.90923 14.1808 4.90923 14.1808C4.90923 14.7269 4.90923 14.7269 4.90923 15.2731C4.90923 15.8192 4.90923 15.8192 4.90923 16.3654C12 23.4539 12 23.4538 12 23.4538C12.5454 23.4538 12.5454 23.4538 13.0908 23.4538C13.6365 23.4538 13.6365 23.4538 14.1819 23.4538C24.5454 12.5461 24.5454 12.5462 24.5454 12.5462L25.0908 12C25.0908 11.4538 24.5454 10.9077 24.5454 10.9077Z"
|
|
50
50
|
/>
|
|
51
|
-
<
|
|
51
|
+
<ItemLabel
|
|
52
52
|
indexes={indexes}
|
|
53
53
|
x={positionH === 'flipped' ? 0 : iconSize + gap}
|
|
54
|
-
|
|
55
|
-
width={descWidth}
|
|
54
|
+
width={textWidth}
|
|
56
55
|
height={height}
|
|
56
|
+
fontWeight="normal"
|
|
57
57
|
alignVertical="center"
|
|
58
58
|
wordWrap={false}
|
|
59
|
+
fill="#666"
|
|
59
60
|
>
|
|
60
|
-
{datum.desc}
|
|
61
|
-
</
|
|
61
|
+
{datum.label || datum.desc}
|
|
62
|
+
</ItemLabel>
|
|
62
63
|
</Group>
|
|
63
64
|
);
|
|
64
65
|
};
|
|
65
66
|
|
|
66
67
|
registerItem('done-list', {
|
|
67
68
|
component: DoneList,
|
|
68
|
-
composites: ['
|
|
69
|
+
composites: ['label'],
|
|
69
70
|
});
|
|
@@ -40,7 +40,7 @@ export const ListColumn: ComponentType<ListColumnProps> = (props) => {
|
|
|
40
40
|
y={itemY}
|
|
41
41
|
width={width}
|
|
42
42
|
positionV="center"
|
|
43
|
-
positionH={zigzag
|
|
43
|
+
positionH={zigzag ? (index % 2 === 0 ? 'normal' : 'flipped') : 'normal'}
|
|
44
44
|
/>,
|
|
45
45
|
);
|
|
46
46
|
|
package/src/options/parser.ts
CHANGED