import {
Bounds,
ComponentType,
getElementBounds,
Group,
Polygon,
Text,
} from '../../jsx';
import { Gap, ItemDesc, ItemLabel } from '../components';
import { FlexLayout } from '../layouts';
import { AlignLayout } from '../layouts/Align';
import { getItemProps } from '../utils';
import { registerItem } from './registry';
import type { BaseItemProps } from './types';
export interface SimpleHorizontalArrowProps extends BaseItemProps {
width?: number;
/** 翻转方向 */
flipped?: boolean;
}
export const SimpleHorizontalArrow: ComponentType<
SimpleHorizontalArrowProps
> = (props) => {
const [
{ indexes, datum, width = 140, themeColors, positionV = 'normal' },
restProps,
] = getItemProps(props, ['width']);
const isVNormal = positionV !== 'flipped';
const textAlignVertical = isVNormal ? 'bottom' : 'top';
const label = (
{datum.label}
);
const desc = (
{datum.desc}
);
const arrowHeight = 30;
const labelGap = 10;
const labelBounds = getElementBounds(label);
const descBounds = getElementBounds(desc);
const textHeight = labelBounds.height + descBounds.height;
const totalHeight =
textHeight + labelGap + arrowHeight + labelGap + textHeight;
return (
{isVNormal ? (
<>
{desc}
{label}
>
) : (
<>
>
)}
{datum.time
? datum.time
: String(indexes[0] + 1)
.padStart(2, '0')
.slice(-2)}
{!isVNormal ? (
<>
{label}
{desc}
>
) : (
<>
>
)}
);
};
const HorizontalArrow = (
props: Partial & { fill: string; size?: number },
) => {
const {
x = 0,
y = 0,
width = 100,
height = 40,
fill = '#FF356A',
size = 10,
} = props;
return (
);
};
registerItem('simple-horizontal-arrow', {
component: SimpleHorizontalArrow,
composites: ['label', 'desc', 'time'],
});