// @flow /* eslint-disable react-hooks/rules-of-hooks */ import * as React from 'react'; import Button from '../../../components/button/Button'; import SharedLinkModal from '../SharedLinkModal'; import notes from './SharedLinkModal.stories.md'; export const basic = () => { const contacts = [ { id: 0, name: 'Jackie', email: 'j@example.com', type: 'user' }, { id: 1, name: 'Jeff', email: 'jt@example.com', type: 'user' }, { id: 2, name: 'David', email: 'dt@example.com', type: 'user' }, { id: 3, name: 'Yang', email: 'yz@example.com', type: 'user' }, { id: 4, name: 'Yong', email: 'ysu@example.com', type: 'user' }, { id: 5, name: 'Will', email: 'wy@example.com', type: 'user' }, { id: 6, name: 'Dave', email: 'd@example.com', type: 'user' }, { id: 7, name: 'Ke', email: 'k@example.com', type: 'user' }, { id: 8, name: 'Wenbo', email: 'w@example.com', type: 'user' }, { id: 11, name: 'Supersupersupersuperreallyreallyreallylongfirstname incrediblyspectacularlylonglastname', email: 'Supersupersupersuperreallyreallyreallyincrediblyspectacularlylongemail@example.com', type: 'user', }, ]; const [isOpen, setIsOpen] = React.useState(false); const [accessLevel, setAccessLevel] = React.useState('peopleInYourCompany'); const [permissionLevel, setPermissionLevel] = React.useState('canView'); const [selectorOptions, setSelectorOptions] = React.useState([]); const [submitting, setSubmitting] = React.useState(false); const closeModal = () => { setIsOpen(false); }; const fakeRequest = () => { setSubmitting(true); return new Promise(resolve => { setTimeout(() => { setSubmitting(false); resolve(); }, 500); }); }; const isSubstring = (value, searchString) => { return value && value.toLowerCase().indexOf(searchString.toLowerCase()) !== -1; }; const getContacts = searchString => { const filteredContacts = contacts.filter( ({ name, email }) => isSubstring(name, searchString) || isSubstring(email, searchString), ); setSelectorOptions(filteredContacts); }; return (