import { ClearOutlined, ReloadOutlined } from '@ant-design/icons'; import { Button, Col, Input, Row } from 'antd'; import React, { useState } from 'react'; import { TypeInputProps } from './TypeInput'; import { UUID } from 'bson'; export const UUIDInput = ({ property, defaultValue, set, extraProps, isPrimary, }: TypeInputProps) => { const [_, setReset] = useState(0); const [value, setValue] = useState( defaultValue ? (defaultValue as UUID).toString() : null ); const onChange = (value: string) => { setValue(value); if (UUID.isValid(value)) { set(new UUID(value)); } else { set(null); } }; return ( onChange(v.target.value)} placeholder={property.optional ? 'null' : undefined} status={ (value === null && property.optional) || (value !== null && UUID.isValid(value)) ? '' : 'error' } /> {property.optional ? ( ) : null} ); };