[Update] Symbol alignement behavior + filtered Symbollist in ContainerForm.tsx
This commit is contained in:
parent
bf4f69a95f
commit
a476017d99
8 changed files with 148 additions and 32 deletions
|
@ -5,7 +5,8 @@ import { type ISymbolModel } from '../../Interfaces/ISymbolModel';
|
|||
import {
|
||||
SHOW_BORROWER_DIMENSIONS,
|
||||
SHOW_CHILDREN_DIMENSIONS,
|
||||
SHOW_SELF_DIMENSIONS, SHOW_SELF_MARGINS_DIMENSIONS
|
||||
SHOW_SELF_DIMENSIONS,
|
||||
SHOW_SELF_MARGINS_DIMENSIONS
|
||||
} from '../../utils/default';
|
||||
import {
|
||||
ApplyWidthMargin,
|
||||
|
@ -27,8 +28,12 @@ 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<string, IContainerModel>
|
||||
properties: IContainerProperties
|
||||
symbols: Map<string, ISymbolModel>
|
||||
onChange: (key: string, value: string | number | boolean | number[], type?: PropertyType) => void
|
||||
|
@ -36,6 +41,8 @@ interface IContainerFormProps {
|
|||
|
||||
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 (
|
||||
<div className='grid grid-cols-1 gap-y-4 items-center'>
|
||||
<TextInputGroup
|
||||
|
@ -185,8 +192,14 @@ export function ContainerForm(props: IContainerFormProps): JSX.Element {
|
|||
type='number'
|
||||
min={props.properties.minWidth}
|
||||
max={props.properties.maxWidth}
|
||||
value={(RemoveWidthMargin(props.properties.width, props.properties.margin.left, props.properties.margin.right)).toString()}
|
||||
onChange={(value) => { props.onChange('width', ApplyWidthMargin(Number(value), props.properties.margin.left, props.properties.margin.right)); }}
|
||||
value={(RemoveWidthMargin(props.properties.width,
|
||||
props.properties.margin.left,
|
||||
props.properties.margin.right)).toString()}
|
||||
onChange={(value) => {
|
||||
props.onChange('width', ApplyWidthMargin(Number(value),
|
||||
props.properties.margin.left,
|
||||
props.properties.margin.right));
|
||||
}}
|
||||
isDisabled={props.properties.isFlex}/>
|
||||
<TextInputGroup
|
||||
id={`${props.properties.id}-maxWidth`}
|
||||
|
@ -218,8 +231,14 @@ export function ContainerForm(props: IContainerFormProps): JSX.Element {
|
|||
type='number'
|
||||
min={props.properties.minHeight}
|
||||
max={props.properties.maxHeight}
|
||||
value={(RemoveWidthMargin(props.properties.height, props.properties.margin.top, props.properties.margin.bottom)).toString()}
|
||||
onChange={(value) => { props.onChange('height', ApplyWidthMargin(Number(value), props.properties.margin.top, props.properties.margin.bottom)); }}
|
||||
value={(RemoveWidthMargin(props.properties.height,
|
||||
props.properties.margin.top,
|
||||
props.properties.margin.bottom)).toString()}
|
||||
onChange={(value) => {
|
||||
props.onChange('height', ApplyWidthMargin(Number(value),
|
||||
props.properties.margin.top,
|
||||
props.properties.margin.bottom));
|
||||
}}
|
||||
isDisabled={props.properties.isFlex}
|
||||
/>
|
||||
<TextInputGroup
|
||||
|
@ -332,7 +351,7 @@ export function ContainerForm(props: IContainerFormProps): JSX.Element {
|
|||
labelText={Text({ textId: '@ContainerAlignWithSymbol' })}
|
||||
labelClassName=''
|
||||
inputClassName=''
|
||||
inputs={[...props.symbols.values()].map(symbol => ({
|
||||
inputs={[...props.symbols.values()].filter(symbol => (symbol.isVertical === isVertical)).map(symbol => ({
|
||||
key: symbol.id,
|
||||
text: symbol.id,
|
||||
value: symbol.id
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import React from 'react';
|
||||
import { PropertyType } from '../../Enums/PropertyType';
|
||||
import { IContainerProperties } from '../../Interfaces/IContainerProperties';
|
||||
import { ISymbolModel } from '../../Interfaces/ISymbolModel';
|
||||
import { type PropertyType } from '../../Enums/PropertyType';
|
||||
import { type IContainerProperties } from '../../Interfaces/IContainerProperties';
|
||||
import { type ISymbolModel } from '../../Interfaces/ISymbolModel';
|
||||
import { ContainerForm } from './ContainerForm';
|
||||
import { type IContainerModel } from '../../Interfaces/IContainerModel';
|
||||
|
||||
interface IPropertiesProps {
|
||||
containers: Map<string, IContainerModel>
|
||||
properties?: IContainerProperties
|
||||
symbols: Map<string, ISymbolModel>
|
||||
onChange: (key: string, value: string | number | boolean | number[], type?: PropertyType) => void
|
||||
|
@ -18,6 +20,7 @@ export function ContainerProperties(props: IPropertiesProps): JSX.Element {
|
|||
return (
|
||||
<div className='h-full p-3 bg-slate-200 overflow-y-auto'>
|
||||
<ContainerForm
|
||||
containers={props.containers}
|
||||
properties={props.properties}
|
||||
symbols={props.symbols}
|
||||
onChange={props.onChange} />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue