diff --git a/src/Components/EnumCheckboxGroupButtons/EnumCheckboxGroupButtons.tsx b/src/Components/CheckboxGroupButtons/CheckboxGroupButtons.tsx similarity index 86% rename from src/Components/EnumCheckboxGroupButtons/EnumCheckboxGroupButtons.tsx rename to src/Components/CheckboxGroupButtons/CheckboxGroupButtons.tsx index 59053b6..40ebffc 100644 --- a/src/Components/EnumCheckboxGroupButtons/EnumCheckboxGroupButtons.tsx +++ b/src/Components/CheckboxGroupButtons/CheckboxGroupButtons.tsx @@ -1,17 +1,19 @@ import * as React from 'react'; -import { IInputGroup } from '../../Interfaces/IInputGroup'; interface ICheckboxGroupButtonsProps { name: string selectedValues: number[] inputClassName: string labelText: string - inputGroups: IEnumCheckboxInputGroup[] + inputGroups: ICheckboxInputGroup[] colQty: number onChange: (newSelectedValues: number[]) => void } -interface IEnumCheckboxInputGroup extends Omit { +// TODO: After modeler uses Typescript >= 4.x, extends Omit +interface ICheckboxInputGroup { + key: string + text: React.ReactNode value: number } @@ -32,7 +34,7 @@ const GRID_COLS = [ 'grid-cols-12' ]; -export function EnumCheckboxGroupButtons(props: ICheckboxGroupButtonsProps): JSX.Element { +export function CheckboxGroupButtons(props: ICheckboxGroupButtonsProps): JSX.Element { const selectedOptions = new Set(props.selectedValues); const inputGroups = props.inputGroups.map((inputGroup) => (
@@ -69,7 +71,7 @@ export function EnumCheckboxGroupButtons(props: ICheckboxGroupButtonsProps): JSX ); - function IsChecked(inputGroup: IEnumCheckboxInputGroup): boolean { + function IsChecked(inputGroup: ICheckboxInputGroup): boolean { return selectedOptions.has(inputGroup.value); } diff --git a/src/Components/CheckboxGroupButtons/OrientationCheckboxes.tsx b/src/Components/CheckboxGroupButtons/OrientationCheckboxes.tsx new file mode 100644 index 0000000..97407a3 --- /dev/null +++ b/src/Components/CheckboxGroupButtons/OrientationCheckboxes.tsx @@ -0,0 +1,52 @@ +import React from 'react'; +import { ChevronUpDownIcon } from '@heroicons/react/20/solid'; +import { CheckboxGroupButtons } from './CheckboxGroupButtons'; +import { Orientation } from '../../Enums/Orientation'; + +interface IOrientationCheckboxesProps { + id: string + name: string + labelText: string + value: Orientation[] + onChange: (key: string, value: number[]) => void +} + +export function OrientationCheckboxes({ + id, + name, + labelText, + value, + onChange +}: IOrientationCheckboxesProps): JSX.Element { + return + +
+ ), + value: Orientation.Horizontal + }, + { + key: `${id}-vertical`, + text: ( +
+ +
+ ), + value: Orientation.Vertical + } + ]} + onChange={(newSelectedValues) => { + onChange(id, newSelectedValues); + }} + />; +} diff --git a/src/Components/CheckboxGroupButtons/PositionCheckboxes.tsx b/src/Components/CheckboxGroupButtons/PositionCheckboxes.tsx new file mode 100644 index 0000000..f86ae64 --- /dev/null +++ b/src/Components/CheckboxGroupButtons/PositionCheckboxes.tsx @@ -0,0 +1,70 @@ +import React from 'react'; +import { ArrowDownIcon, ArrowLeftIcon, ArrowRightIcon, ArrowUpIcon } from '@heroicons/react/20/solid'; +import { Position } from '../../Enums/Position'; +import { CheckboxGroupButtons } from './CheckboxGroupButtons'; + +interface IPositionCheckboxesProps { + id: string + name: string + labelText: string + value: Position[] + onChange: (key: string, value: number[]) => void +} + +export function PositionCheckboxes({ + id, + name, + labelText, + value, + onChange +}: IPositionCheckboxesProps): JSX.Element { + return + + + ), + value: Position.Left + }, + { + key: `${id}-down`, + text: ( +
+ +
+ ), + value: Position.Down + }, + { + key: `${id}-up`, + text: ( +
+ +
+ ), + value: Position.Up + }, + { + key: `${id}-right`, + text: ( +
+ +
+ ), + value: Position.Right + } + ]} + onChange={(newSelectedValues) => { + onChange(id, newSelectedValues); + }} + />; +} diff --git a/src/Components/ContainerProperties/ContainerForm.tsx b/src/Components/ContainerProperties/ContainerForm.tsx index 043a96c..adcc801 100644 --- a/src/Components/ContainerProperties/ContainerForm.tsx +++ b/src/Components/ContainerProperties/ContainerForm.tsx @@ -1,19 +1,17 @@ -import { Bars3BottomLeftIcon, Bars3CenterLeftIcon, Bars3Icon, Bars3BottomRightIcon, Bars2Icon } from '@heroicons/react/24/outline'; -import { FlagIcon, ViewColumnsIcon } from '@heroicons/react/20/solid'; import * as React from 'react'; import { PropertyType } from '../../Enums/PropertyType'; -import { PositionReference } from '../../Enums/PositionReference'; import { IContainerProperties } from '../../Interfaces/IContainerProperties'; import { ISymbolModel } from '../../Interfaces/ISymbolModel'; import { SHOW_BORROWER_DIMENSIONS, SHOW_CHILDREN_DIMENSIONS, SHOW_SELF_DIMENSIONS } from '../../utils/default'; import { ApplyWidthMargin, ApplyXMargin, RemoveWidthMargin, RemoveXMargin, RestoreX, RestoreY, TransformX, TransformY } from '../../utils/svg'; import { InputGroup } from '../InputGroup/InputGroup'; import { TextInputGroup } from '../InputGroup/TextInputGroup'; -import { RadioGroupButtons } from '../RadioGroupButtons/RadioGroupButtons'; import { Select } from '../Select/Select'; import { ToggleButton, ToggleType } from '../ToggleButton/ToggleButton'; -import { Orientation } from '../../Enums/Orientation'; -import { EnumCheckboxGroupButtons } from '../EnumCheckboxGroupButtons/EnumCheckboxGroupButtons'; +import { PositionReferenceSelector } from '../RadioGroupButtons/PositionReferenceSelector'; +import { OrientationSelector } from '../RadioGroupButtons/OrientationSelector'; +import { OrientationCheckboxes } from '../CheckboxGroupButtons/OrientationCheckboxes'; +import { PositionCheckboxes } from '../CheckboxGroupButtons/PositionCheckboxes'; interface IContainerFormProps { properties: IContainerProperties @@ -75,7 +73,13 @@ export function ContainerForm(props: IContainerFormProps): JSX.Element { type='string' value={props.properties.displayedText?.toString()} onChange={(value) => props.onChange('displayedText', value)} /> - + props.onChange('isAnchor', event.target.checked)} /> -