import type { ComponentType, JSXElement } from '../../jsx';
import { getElementBounds, Group } from '../../jsx';
import { BtnAdd, BtnRemove, BtnsGroup, ItemsGroup } from '../components';
import { FlexLayout } from '../layouts';
import { registerStructure } from './registry';
import type { BaseStructureProps } from './types';
export interface SequenceAscendingStepsProps extends BaseStructureProps {
hGap?: number;
vGap?: number;
}
export const SequenceAscendingSteps: ComponentType<
SequenceAscendingStepsProps
> = (props) => {
const { Title, Item, data, hGap = 0, vGap = 0 } = props as any;
const { title, desc, items = [] } = data;
const titleContent = Title ?
: null;
const itemBounds = getElementBounds(
,
);
const itemElements: JSXElement[] = [];
const btnElements: JSXElement[] = [];
const n = items.length;
const stepX = itemBounds.width + hGap;
const stepY = itemBounds.height / 2 + vGap;
const startX = itemBounds.width / 2;
const endY = 0;
const startY = endY + (n - 1) * stepY;
items.forEach((datum: any, index: number) => {
const x = startX + index * stepX;
const y = startY - index * stepY;
const indexes = [index];
itemElements.push(
,
);
btnElements.push(
,
);
btnElements.push(
,
);
});
return (
{titleContent}
{itemElements}
{btnElements}
);
};
registerStructure('sequence-ascending-steps', {
component: SequenceAscendingSteps,
composites: ['title', 'item'],
});