react-icons/ai#AiOutlineEdit TypeScript Examples
The following examples show how to use
react-icons/ai#AiOutlineEdit.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WebhooksTable.tsx From bluebubbles-server with Apache License 2.0 | 5 votes |
WebhooksTable = ({ webhooks }: { webhooks: Array<WebhookItem> }): JSX.Element => {
const dispatch = useAppDispatch();
const dialogRef = useRef(null);
const [selectedId, setSelectedId] = useState(undefined as number | undefined);
return (
<Box>
<Table variant="striped" colorScheme="blue">
<TableCaption>These are callbacks to receive events from the BlueBubbles Server</TableCaption>
<Thead>
<Tr>
<Th>URL</Th>
<Th>Event Subscriptions</Th>
<Th isNumeric>Actions</Th>
</Tr>
</Thead>
<Tbody>
{webhooks.map(item => (
<Tr key={item.id}>
<Td>{item.url}</Td>
<Td>{JSON.parse(item.events).map((e: string) => webhookEventValueToLabel(e)).join(', ')}</Td>
<Td isNumeric>
<Grid templateColumns="repeat(2, 1fr)">
<Tooltip label='Edit' placement='bottom'>
<GridItem _hover={{ cursor: 'pointer' }} onClick={() => setSelectedId(item.id)}>
<Icon as={AiOutlineEdit} />
</GridItem>
</Tooltip>
<Tooltip label='Delete' placement='bottom'>
<GridItem _hover={{ cursor: 'pointer' }} onClick={() => dispatch(remove(item.id))}>
<Icon as={FiTrash} />
</GridItem>
</Tooltip>
</Grid>
</Td>
</Tr>
))}
</Tbody>
</Table>
<AddWebhookDialog
existingId={selectedId}
modalRef={dialogRef}
isOpen={!!selectedId}
onClose={() => {
setSelectedId(undefined);
}}
/>
</Box>
);
}
Example #2
Source File: ProxyServiceField.tsx From bluebubbles-server with Apache License 2.0 | 4 votes |
ProxyServiceField = ({ helpText, showAddress = true }: ProxyServiceFieldProps): JSX.Element => {
const dispatch = useAppDispatch();
const dnsRef = useRef(null);
const alertRef = useRef(null);
const proxyService: string = (useAppSelector(state => state.config.proxy_service) ?? '').toLowerCase().replace(' ', '-');
const address: string = useAppSelector(state => state.config.server_address) ?? '';
const port: number = useAppSelector(state => state.config.socket_port) ?? 1234;
const [dnsModalOpen, setDnsModalOpen] = useBoolean();
const [requiresConfirmation, confirm] = useState((): string | null => {
return null;
});
return (
<FormControl>
<FormLabel htmlFor='proxy_service'>Proxy Service</FormLabel>
<Flex flexDirection='row' justifyContent='flex-start' alignItems='center'>
<Select
id='proxy_service'
placeholder='Select Proxy Service'
maxWidth="15em"
mr={3}
value={proxyService}
onChange={(e) => {
if (!e.target.value || e.target.value.length === 0) return;
onSelectChange(e);
if (e.target.value === 'dynamic-dns') {
setDnsModalOpen.on();
} else if (e.target.value === 'cloudflare') {
confirm('confirmation');
}
}}
>
<option value='ngrok'>Ngrok</option>
<option value='cloudflare'>Cloudflare</option>
<option value='dynamic-dns'>Dynamic DNS</option>
</Select>
{(proxyService === 'dynamic-dns')
? (
<IconButton
mr={3}
aria-label='Set address'
icon={<AiOutlineEdit />}
onClick={() => setDnsModalOpen.on()}
/>
) : null}
{(showAddress) ? (
<>
<Text fontSize="md" color="grey">Address: {address}</Text>
<IconButton
ml={3}
aria-label='Copy address'
icon={<BiCopy />}
onClick={() => copyToClipboard(address)}
/>
</>
) : null}
</Flex>
<FormHelperText>
{helpText ?? 'Select a proxy service to use to make your server internet-accessible. Without one selected, your server will only be accessible on your local network'}
</FormHelperText>
<DynamicDnsDialog
modalRef={dnsRef}
onConfirm={(address) => dispatch(setConfig({ name: 'server_address', value: address }))}
isOpen={dnsModalOpen}
port={port as number}
onClose={() => setDnsModalOpen.off()}
/>
<ConfirmationDialog
title="Notice"
modalRef={alertRef}
onClose={() => confirm(null)}
body={confirmationActions[requiresConfirmation as string]?.message}
acceptText="OK"
declineText={null}
onAccept={() => {
confirmationActions[requiresConfirmation as string].func();
}}
isOpen={requiresConfirmation !== null}
/>
</FormControl>
);
}
Example #3
Source File: ContactsTable.tsx From bluebubbles-server with Apache License 2.0 | 4 votes |
ContactsTable = ({
contacts,
onCreate,
onDelete,
onUpdate,
onAddressAdd,
onAddressDelete
}: {
contacts: Array<ContactItem>,
onCreate?: (contact: ContactItem) => void,
onDelete?: (contactId: number | string) => void,
onUpdate?: (contact: Partial<ContactItem>) => void,
onAddressAdd?: (contactId: number | string, address: string) => void;
onAddressDelete?: (contactAddressId: number) => void;
}): JSX.Element => {
const dialogRef = useRef(null);
const [dialogOpen, setDialogOpen] = useBoolean();
const [selectedContact, setSelectedContact] = useState(null as any | null);
return (
<Box>
<Table variant="striped" colorScheme="blue" size='sm'>
<Thead>
<Tr>
<Th>Edit</Th>
<Th>Display Name</Th>
<Th isNumeric>Addresses</Th>
</Tr>
</Thead>
<Tbody>
{contacts.map(item => {
const name = (item.displayName && item.displayName.length > 0)
? item.displayName
: [item?.firstName, item?.lastName].filter((e) => e && e.length > 0).join(' ');
const addresses = [
...(item.phoneNumbers ?? []).map(e => e.address),
...(item.emails ?? []).map(e => e.address)
];
return (
<Tr key={`${item.sourceType}-${item.id}-${name}-${addresses.join('_')}`}>
<Td _hover={{ cursor: (item?.sourceType === 'api') ? 'auto' : 'pointer' }} onClick={() => {
if (item?.sourceType === 'api') return;
setSelectedContact(item);
setDialogOpen.on();
}}>
{(item?.sourceType === 'api') ? (
<Tooltip label="Not Editable" hasArrow aria-label='not editable tooltip'>
<span>
<Icon as={MdOutlineEditOff} />
</span>
</Tooltip>
): (
<Tooltip label="Click to Edit" hasArrow aria-label='editable tooltip'>
<span>
<Icon as={AiOutlineEdit} />
</span>
</Tooltip>
)}
</Td>
<Td>{name}</Td>
<Td isNumeric>{addresses.map((addr) => (
<Badge ml={2} key={`${name}-${addr}-${addresses.length}`}>{addr}</Badge>
))}</Td>
</Tr>
);
})}
</Tbody>
</Table>
<ContactDialog
modalRef={dialogRef}
isOpen={dialogOpen}
existingContact={selectedContact}
onDelete={onDelete}
onCreate={onCreate}
onUpdate={onUpdate}
onAddressAdd={onAddressAdd}
onAddressDelete={onAddressDelete}
onClose={() => {
setSelectedContact(null);
setDialogOpen.off();
}}
/>
</Box>
);
}
Example #4
Source File: index.tsx From slice-machine with Apache License 2.0 | 4 votes |
function ListItem<F extends TabField, S extends AnyObjectSchema>({
item,
index,
deleteItem,
enterEditMode,
modelFieldName,
renderFieldAccessor,
HintElement,
CustomEditElement,
CustomEditElements,
widget,
draggableId,
children,
}: ListItemProps<F, S>): JSX.Element {
const { theme } = useThemeUI();
const {
key,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
value: { config },
} = item;
return (
<Fragment>
<Draggable draggableId={draggableId} index={index}>
{(provided) => (
<Fragment>
<Li
ref={provided.innerRef}
{...provided.draggableProps}
Component={Box}
sx={{
p: 0,
mx: 0,
my: 3,
}}
>
<Flex sx={{ width: "100%" }}>
<SliceMachineIconButton
label="Reorder slice field (drag and drop)"
Icon={FaBars}
color={theme.colors?.icons as string}
mr={1}
mt={3}
{...provided.dragHandleProps}
/>
<Box
sx={{
bg: "headSection",
width: "100%",
borderRadius: "3px",
border: (t) => `1px solid ${String(t.colors?.borders)}`,
}}
>
<Flex
sx={{
p: 3,
alignItems: "center",
justifyContent: "space-between",
width: "100%",
}}
>
<ItemHeader
theme={theme}
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
text={config?.label || key}
sliceFieldName={
renderFieldAccessor && renderFieldAccessor(key)
}
WidgetIcon={widget.Meta.icon}
/>
<Flex>
{CustomEditElements ? CustomEditElements : null}
{CustomEditElement ? (
CustomEditElement
) : (
<SliceMachineIconButton
size={22}
Icon={AiOutlineEdit}
label="Edit slice field"
sx={{ cursor: "pointer", color: theme.colors?.icons }}
onClick={() =>
enterEditMode(
[key, item.value],
modelFieldName,
index
)
}
/>
)}
<Menu>
<MenuButton
className="sliceMenuButton"
style={{
padding: "0",
cursor: "pointer",
width: "32px",
height: "32px",
border: "none",
background: "transparent",
outline: "0",
}}
>
<BsThreeDotsVertical
size={20}
color={theme.colors?.icons as string}
style={{ pointerEvents: "none" }}
/>
</MenuButton>
<MenuList
style={{
background: theme.colors?.gray as string,
border: "1px solid",
borderRadius: "3px",
borderColor: theme.colors?.borders as string,
outline: "0",
}}
>
<MenuItem
style={{ padding: "6px", cursor: "pointer" }}
onSelect={() => deleteItem(key)}
>
Delete field
</MenuItem>
</MenuList>
</Menu>
</Flex>
</Flex>
{HintElement ? HintElement : null}
</Box>
</Flex>
{children}
</Li>
</Fragment>
)}
</Draggable>
</Fragment>
);
}