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 InputNumber from 'Elements/InputNumber';
|
||||||
import Link from 'Elements/Link';
|
import Link from 'Elements/Link';
|
||||||
import Radio from 'Elements/Radio';
|
import Radio from 'Elements/Radio';
|
||||||
|
import Segmented from 'Elements/Segmented';
|
||||||
import Select from 'Elements/Select';
|
import Select from 'Elements/Select';
|
||||||
import Switch from 'Elements/Switch';
|
import Switch from 'Elements/Switch';
|
||||||
import Text from 'Elements/Text';
|
import Text from 'Elements/Text';
|
||||||
@ -45,7 +46,7 @@ const components: Record<
|
|||||||
selectConfiguration: Select,
|
selectConfiguration: Select,
|
||||||
labelDepreciationGroup: Text,
|
labelDepreciationGroup: Text,
|
||||||
cbxLeaseObjectUsed: Checkbox,
|
cbxLeaseObjectUsed: Checkbox,
|
||||||
radioDeliveryTime: Radio,
|
radioDeliveryTime: Segmented,
|
||||||
tbxLeaseObjectCount: InputNumber,
|
tbxLeaseObjectCount: InputNumber,
|
||||||
selectLeaseObjectUseFor: Select,
|
selectLeaseObjectUseFor: Select,
|
||||||
tbxLeaseObjectYear: InputNumber,
|
tbxLeaseObjectYear: InputNumber,
|
||||||
|
|||||||
@ -121,10 +121,6 @@ const props: Partial<ElementsProps> = {
|
|||||||
selectConfiguration: {
|
selectConfiguration: {
|
||||||
showSearch: true,
|
showSearch: true,
|
||||||
},
|
},
|
||||||
radioDeliveryTime: {
|
|
||||||
optionType: 'button',
|
|
||||||
buttonStyle: 'solid',
|
|
||||||
},
|
|
||||||
tbxLeaseObjectCount: {
|
tbxLeaseObjectCount: {
|
||||||
min: 1,
|
min: 1,
|
||||||
max: 1000,
|
max: 1000,
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import type { InputProps } from 'Elements/Input';
|
|||||||
import type { InputNumberProps } from 'Elements/InputNumber';
|
import type { InputNumberProps } from 'Elements/InputNumber';
|
||||||
import type { LinkProps } from 'Elements/Link';
|
import type { LinkProps } from 'Elements/Link';
|
||||||
import type { RadioProps } from 'Elements/Radio';
|
import type { RadioProps } from 'Elements/Radio';
|
||||||
|
import type { SegmentedProps } from 'Elements/Segmented';
|
||||||
import type { SelectProps } from 'Elements/Select';
|
import type { SelectProps } from 'Elements/Select';
|
||||||
import type { SwitchProps } from 'Elements/Switch';
|
import type { SwitchProps } from 'Elements/Switch';
|
||||||
import type { TextProps } from 'Elements/Text';
|
import type { TextProps } from 'Elements/Text';
|
||||||
@ -39,7 +40,7 @@ export interface ElementsProps {
|
|||||||
selectConfiguration: SelectProps;
|
selectConfiguration: SelectProps;
|
||||||
labelDepreciationGroup: TextProps;
|
labelDepreciationGroup: TextProps;
|
||||||
cbxLeaseObjectUsed: CheckboxProps;
|
cbxLeaseObjectUsed: CheckboxProps;
|
||||||
radioDeliveryTime: RadioProps;
|
radioDeliveryTime: SegmentedProps;
|
||||||
tbxLeaseObjectCount: InputNumberProps;
|
tbxLeaseObjectCount: InputNumberProps;
|
||||||
selectLeaseObjectUseFor: SelectProps;
|
selectLeaseObjectUseFor: SelectProps;
|
||||||
tbxLeaseObjectYear: InputNumberProps;
|
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