Elements: add new Segmented
This commit is contained in:
parent
f413b99950
commit
29a5f6cd4b
@ -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,
|
||||
|
||||
@ -121,10 +121,6 @@ const props: Partial<ElementsProps> = {
|
||||
selectConfiguration: {
|
||||
showSearch: true,
|
||||
},
|
||||
radioDeliveryTime: {
|
||||
optionType: 'button',
|
||||
buttonStyle: 'solid',
|
||||
},
|
||||
tbxLeaseObjectCount: {
|
||||
min: 1,
|
||||
max: 1000,
|
||||
|
||||
@ -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;
|
||||
|
||||
37
Elements/Segmented.tsx
Normal file
37
Elements/Segmented.tsx
Normal file
@ -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<string | number> & {
|
||||
options: BaseOption[];
|
||||
spaceProps?: SpaceProps;
|
||||
style: SegmentedProps['style'];
|
||||
};
|
||||
|
||||
export default function Segmented({
|
||||
value,
|
||||
setValue,
|
||||
options,
|
||||
status,
|
||||
isValid,
|
||||
help,
|
||||
spaceProps,
|
||||
style,
|
||||
...props
|
||||
}: ElementProps) {
|
||||
return (
|
||||
<FormItem hasFeedback validateStatus={isValid === false ? 'error' : ''} help={help}>
|
||||
<AntSegmented
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
disabled={status === 'Disabled'}
|
||||
options={options}
|
||||
{...props}
|
||||
/>
|
||||
</FormItem>
|
||||
);
|
||||
}
|
||||
|
||||
export { type SegmentedProps } from 'antd';
|
||||
Loading…
x
Reference in New Issue
Block a user