import * as React from 'react'; import { PropertyType } from '../../Enums/PropertyType'; import { type IContainerProperties } from '../../Interfaces/IContainerProperties'; import { type ISymbolModel } from '../../Interfaces/ISymbolModel'; import { SHOW_BORROWER_DIMENSIONS, SHOW_CHILDREN_DIMENSIONS, SHOW_SELF_DIMENSIONS, SHOW_SELF_MARGINS_DIMENSIONS } from '../../utils/default'; import { ApplyWidthMargin, ApplyXMargin, RemoveWidthMargin, RemoveXMargin, RestoreX, RestoreY, TransformX, TransformY } from '../../utils/svg'; import { Text } from '../Text/Text'; import { InputGroup } from '../InputGroup/InputGroup'; import { TextInputGroup } from '../InputGroup/TextInputGroup'; import { Select } from '../Select/Select'; import { ToggleButton, ToggleType } from '../ToggleButton/ToggleButton'; import { PositionReferenceSelector } from '../RadioGroupButtons/PositionReferenceSelector'; import { OrientationSelector } from '../RadioGroupButtons/OrientationSelector'; import { OrientationCheckboxes } from '../CheckboxGroupButtons/OrientationCheckboxes'; import { PositionCheckboxes } from '../CheckboxGroupButtons/PositionCheckboxes'; import { Category } from '../Category/Category'; import { Orientation } from '../../Enums/Orientation'; import { FindContainerById } from '../../utils/itertools'; import { type IContainerModel } from '../../Interfaces/IContainerModel'; interface IContainerFormProps { containers: Map properties: IContainerProperties symbols: Map onChange: (key: string, value: string | number | boolean | number[], type?: PropertyType) => void } export function ContainerForm(props: IContainerFormProps): JSX.Element { const categoryHeight = 'h-11'; const parent = FindContainerById(props.containers, props.properties.parentId); const isVertical = parent?.properties.orientation === Orientation.Vertical; return (
{ props.onChange('displayedText', value); }}/>
{ props.onChange( 'x', ApplyXMargin( RestoreX( Number(value), props.properties.width, props.properties.positionReference ), props.properties.margin.left ) ); }}/> { props.onChange( 'y', ApplyXMargin( RestoreY( Number(value), props.properties.height, props.properties.positionReference ), props.properties.margin.top ) ); }}/>
{ props.onChange('minWidth', Number(value)); }}/> { props.onChange('width', ApplyWidthMargin(Number(value), props.properties.margin.left, props.properties.margin.right)); }} isDisabled={props.properties.isFlex}/> { props.onChange('maxWidth', Number(value)); }}/>
{ props.onChange('minHeight', Number(value)); }}/> { props.onChange('height', ApplyWidthMargin(Number(value), props.properties.margin.top, props.properties.margin.bottom)); }} isDisabled={props.properties.isFlex} /> { props.onChange('maxHeight', Number(value)); }}/>
{ props.onChange('left', Number(value), PropertyType.Margin); }}/> { props.onChange('bottom', Number(value), PropertyType.Margin); }}/> { props.onChange('top', Number(value), PropertyType.Margin); }}/> { props.onChange('right', Number(value), PropertyType.Margin); }}/>
{ props.onChange('isFlex', event.target.checked); }} /> { props.onChange('isAnchor', event.target.checked); }}/>