import {GenerateIcon} from '@sanity/icons/Generate' import {Button, Stack} from '@sanity/ui' import {useToast} from '@sanity/ui/toast' import {useCallback} from 'react' import {set} from 'sanity' import type {StringInputProps} from 'sanity' import {createId} from '../../core/createId' import type {Options} from '../../types' type IdentifierProps = StringInputProps & { ident?: Options['ident'] } /** * #### Create Unique Identifier * For schemes and concepts created in previous versions of the * plugin. * - Input is only visible if no identifier has been assigned * - Input disappears once an ID is generated */ export const Identifier = (props: IdentifierProps) => { const {onChange, ident} = props const toast = useToast() const handleChange = useCallback(() => { const id = createId(ident) onChange(set(id)) toast.push({ status: 'success', title: 'Identifier created.', closable: true, }) }, [onChange, toast, ident]) return (