import * as React from 'react'; import Modal from 'react-modal'; import noop from 'lodash/noop'; import { FormattedMessage, useIntl } from 'react-intl'; import { Button, Modal as BlueprintModal, Text } from '@box/blueprint-web'; import ShareAccessSelect from '../common/share-access-select'; import { CLASS_MODAL_CONTENT, CLASS_MODAL_OVERLAY, CLASS_MODAL } from '../../constants'; import type { Access, BoxItem } from '../../common/types/core'; import messages from '../common/messages'; import './ShareDialog.scss'; export interface ShareDialogProps { appElement: HTMLElement; canSetShareAccess: boolean; isLoading: boolean; isOpen: boolean; item: BoxItem; onCancel: () => void; onShareAccessChange: (access: Access) => void; parentElement: HTMLElement; } const ShareDialog = ({ appElement, canSetShareAccess, isLoading, isOpen, item, onCancel, onShareAccessChange, parentElement, }: ShareDialogProps) => { const { formatMessage } = useIntl(); let textInput = null; const copy = () => { if (textInput instanceof HTMLInputElement) { textInput.select(); document.execCommand('copy'); } }; const { shared_link: sharedLink }: BoxItem = item; const { url } = sharedLink || { url: formatMessage(messages.shareDialogNone), }; return ( parentElement} portalClassName={`${CLASS_MODAL} be-modal-share`} >
{ textInput = input; }} onChange={noop} type="text" value={url} />
); }; export default ShareDialog;