From 29a5f6cd4bfdcd74bb7acbaa9fa5c8a1fd6bf82f Mon Sep 17 00:00:00 2001 From: Chika Date: Fri, 3 Jun 2022 17:19:41 +0300 Subject: [PATCH] Elements: add new Segmented --- .../Calculation/config/elements-components.ts | 3 +- .../Calculation/config/elements-props.ts | 4 -- .../Calculation/types/elements-props.ts | 3 +- Elements/Segmented.tsx | 37 +++++++++++++++++++ 4 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 Elements/Segmented.tsx diff --git a/Components/Calculation/config/elements-components.ts b/Components/Calculation/config/elements-components.ts index 49c6c6a..3ec064b 100644 --- a/Components/Calculation/config/elements-components.ts +++ b/Components/Calculation/config/elements-components.ts @@ -4,6 +4,7 @@ import Input from 'Elements/Input'; import InputNumber from 'Elements/InputNumber'; import Link from 'Elements/Link'; import Radio from 'Elements/Radio'; +import Segmented from 'Elements/Segmented'; import Select from 'Elements/Select'; import Switch from 'Elements/Switch'; import Text from 'Elements/Text'; @@ -45,7 +46,7 @@ const components: Record< selectConfiguration: Select, labelDepreciationGroup: Text, cbxLeaseObjectUsed: Checkbox, - radioDeliveryTime: Radio, + radioDeliveryTime: Segmented, tbxLeaseObjectCount: InputNumber, selectLeaseObjectUseFor: Select, tbxLeaseObjectYear: InputNumber, diff --git a/Components/Calculation/config/elements-props.ts b/Components/Calculation/config/elements-props.ts index 4d8f909..7185933 100644 --- a/Components/Calculation/config/elements-props.ts +++ b/Components/Calculation/config/elements-props.ts @@ -121,10 +121,6 @@ const props: Partial = { selectConfiguration: { showSearch: true, }, - radioDeliveryTime: { - optionType: 'button', - buttonStyle: 'solid', - }, tbxLeaseObjectCount: { min: 1, max: 1000, diff --git a/Components/Calculation/types/elements-props.ts b/Components/Calculation/types/elements-props.ts index e97fd61..017a303 100644 --- a/Components/Calculation/types/elements-props.ts +++ b/Components/Calculation/types/elements-props.ts @@ -4,6 +4,7 @@ import type { InputProps } from 'Elements/Input'; import type { InputNumberProps } from 'Elements/InputNumber'; import type { LinkProps } from 'Elements/Link'; import type { RadioProps } from 'Elements/Radio'; +import type { SegmentedProps } from 'Elements/Segmented'; import type { SelectProps } from 'Elements/Select'; import type { SwitchProps } from 'Elements/Switch'; import type { TextProps } from 'Elements/Text'; @@ -39,7 +40,7 @@ export interface ElementsProps { selectConfiguration: SelectProps; labelDepreciationGroup: TextProps; cbxLeaseObjectUsed: CheckboxProps; - radioDeliveryTime: RadioProps; + radioDeliveryTime: SegmentedProps; tbxLeaseObjectCount: InputNumberProps; selectLeaseObjectUseFor: SelectProps; tbxLeaseObjectYear: InputNumberProps; diff --git a/Elements/Segmented.tsx b/Elements/Segmented.tsx new file mode 100644 index 0000000..3cc2f4f --- /dev/null +++ b/Elements/Segmented.tsx @@ -0,0 +1,37 @@ +import type { SegmentedProps, SpaceProps } from 'antd'; +import { Form, Segmented as AntSegmented } from 'antd'; +import type { BaseElementProps, BaseOption } from './types'; + +const { Item: FormItem } = Form; + +type ElementProps = BaseElementProps & { + options: BaseOption[]; + spaceProps?: SpaceProps; + style: SegmentedProps['style']; +}; + +export default function Segmented({ + value, + setValue, + options, + status, + isValid, + help, + spaceProps, + style, + ...props +}: ElementProps) { + return ( + + + + ); +} + +export { type SegmentedProps } from 'antd';