-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRangeField.tsx
More file actions
35 lines (32 loc) · 821 Bytes
/
RangeField.tsx
File metadata and controls
35 lines (32 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Col, FormItem, Row, Slider } from '@antmjs/vantui';
import { FormItemProps } from '@antmjs/vantui/types/form';
import { SliderProps } from '@antmjs/vantui/types/slider';
import { FC } from 'react';
export interface RangeFieldProps
extends Pick<FormItemProps, 'name' | 'required' | 'rules'>,
Pick<SliderProps, 'min' | 'max' | 'onChange'> {
title: string;
unit?: string;
value: [number, number];
}
export const RangeField: FC<RangeFieldProps> = ({
title,
unit,
name,
value,
required = false,
rules,
...rest
}) => (
<>
<FormItem label={title} {...{ name, required, rules }}>
{value?.[0]} ~ {value?.[1]}
{unit}
</FormItem>
<Row>
<Col span='14' offset='8' className='py-3'>
<Slider range value={value} {...rest} />
</Col>
</Row>
</>
);