@ -136,7 +136,7 @@ export const FieldInput = ({
|
|||||||
onShiftTab={onShiftTab}
|
onShiftTab={onShiftTab}
|
||||||
/>
|
/>
|
||||||
) : isFieldLinks(fieldDefinition) ? (
|
) : isFieldLinks(fieldDefinition) ? (
|
||||||
<LinksFieldInput onCancel={onCancel} onSubmit={onSubmit} />
|
<LinksFieldInput onCancel={onCancel} />
|
||||||
) : isFieldCurrency(fieldDefinition) ? (
|
) : isFieldCurrency(fieldDefinition) ? (
|
||||||
<CurrencyFieldInput
|
<CurrencyFieldInput
|
||||||
onEnter={onEnter}
|
onEnter={onEnter}
|
||||||
|
|||||||
@ -5,7 +5,6 @@ import { IconCheck, IconPlus } from 'twenty-ui';
|
|||||||
|
|
||||||
import { useLinksField } from '@/object-record/record-field/meta-types/hooks/useLinksField';
|
import { useLinksField } from '@/object-record/record-field/meta-types/hooks/useLinksField';
|
||||||
import { LinksFieldMenuItem } from '@/object-record/record-field/meta-types/input/components/LinksFieldMenuItem';
|
import { LinksFieldMenuItem } from '@/object-record/record-field/meta-types/input/components/LinksFieldMenuItem';
|
||||||
import { FieldInputEvent } from '@/object-record/record-field/types/FieldInputEvent';
|
|
||||||
import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
|
import { LightIconButton } from '@/ui/input/button/components/LightIconButton';
|
||||||
import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu';
|
import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu';
|
||||||
import { DropdownMenuInput } from '@/ui/layout/dropdown/components/DropdownMenuInput';
|
import { DropdownMenuInput } from '@/ui/layout/dropdown/components/DropdownMenuInput';
|
||||||
@ -27,13 +26,9 @@ const StyledDropdownMenu = styled(DropdownMenu)`
|
|||||||
|
|
||||||
export type LinksFieldInputProps = {
|
export type LinksFieldInputProps = {
|
||||||
onCancel?: () => void;
|
onCancel?: () => void;
|
||||||
onSubmit?: FieldInputEvent;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const LinksFieldInput = ({
|
export const LinksFieldInput = ({ onCancel }: LinksFieldInputProps) => {
|
||||||
onCancel,
|
|
||||||
onSubmit,
|
|
||||||
}: LinksFieldInputProps) => {
|
|
||||||
const { persistLinksField, hotkeyScope, fieldValue } = useLinksField();
|
const { persistLinksField, hotkeyScope, fieldValue } = useLinksField();
|
||||||
|
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
@ -99,7 +94,6 @@ export const LinksFieldInput = ({
|
|||||||
) {
|
) {
|
||||||
setIsInputDisplayed(false);
|
setIsInputDisplayed(false);
|
||||||
setInputValue('');
|
setInputValue('');
|
||||||
onCancel?.();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,14 +103,11 @@ export const LinksFieldInput = ({
|
|||||||
: toSpliced(links, linkToEditIndex, 1, linkValue);
|
: toSpliced(links, linkToEditIndex, 1, linkValue);
|
||||||
const [nextPrimaryLink, ...nextSecondaryLinks] = nextLinks;
|
const [nextPrimaryLink, ...nextSecondaryLinks] = nextLinks;
|
||||||
|
|
||||||
onSubmit?.(() =>
|
persistLinksField({
|
||||||
persistLinksField({
|
primaryLinkUrl: nextPrimaryLink.url ?? '',
|
||||||
primaryLinkUrl: nextPrimaryLink.url ?? '',
|
primaryLinkLabel: nextPrimaryLink.label ?? '',
|
||||||
primaryLinkLabel: nextPrimaryLink.label ?? '',
|
secondaryLinks: nextSecondaryLinks,
|
||||||
secondaryLinks: nextSecondaryLinks,
|
});
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
setIsInputDisplayed(false);
|
setIsInputDisplayed(false);
|
||||||
setInputValue('');
|
setInputValue('');
|
||||||
};
|
};
|
||||||
@ -125,26 +116,18 @@ export const LinksFieldInput = ({
|
|||||||
const nextLinks = moveArrayItem(links, { fromIndex: index, toIndex: 0 });
|
const nextLinks = moveArrayItem(links, { fromIndex: index, toIndex: 0 });
|
||||||
const [nextPrimaryLink, ...nextSecondaryLinks] = nextLinks;
|
const [nextPrimaryLink, ...nextSecondaryLinks] = nextLinks;
|
||||||
|
|
||||||
onSubmit?.(() =>
|
persistLinksField({
|
||||||
persistLinksField({
|
primaryLinkUrl: nextPrimaryLink.url ?? '',
|
||||||
primaryLinkUrl: nextPrimaryLink.url ?? '',
|
primaryLinkLabel: nextPrimaryLink.label ?? '',
|
||||||
primaryLinkLabel: nextPrimaryLink.label ?? '',
|
secondaryLinks: nextSecondaryLinks,
|
||||||
secondaryLinks: nextSecondaryLinks,
|
});
|
||||||
}),
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteLink = (index: number) => {
|
const handleDeleteLink = (index: number) => {
|
||||||
onSubmit?.(() =>
|
persistLinksField({
|
||||||
persistLinksField({
|
...fieldValue,
|
||||||
...fieldValue,
|
secondaryLinks: toSpliced(fieldValue.secondaryLinks ?? [], index - 1, 1),
|
||||||
secondaryLinks: toSpliced(
|
});
|
||||||
fieldValue.secondaryLinks ?? [],
|
|
||||||
index - 1,
|
|
||||||
1,
|
|
||||||
),
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { useEffect } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
import {
|
import {
|
||||||
IconBookmark,
|
IconBookmark,
|
||||||
@ -40,8 +40,12 @@ export const LinksFieldMenuItem = ({
|
|||||||
onDelete,
|
onDelete,
|
||||||
url,
|
url,
|
||||||
}: LinksFieldMenuItemProps) => {
|
}: LinksFieldMenuItemProps) => {
|
||||||
|
const [isHovered, setIsHovered] = useState(false);
|
||||||
const { isDropdownOpen, closeDropdown } = useDropdown(dropdownId);
|
const { isDropdownOpen, closeDropdown } = useDropdown(dropdownId);
|
||||||
|
|
||||||
|
const handleMouseEnter = () => setIsHovered(true);
|
||||||
|
const handleMouseLeave = () => setIsHovered(false);
|
||||||
|
|
||||||
// Make sure dropdown closes on unmount.
|
// Make sure dropdown closes on unmount.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isDropdownOpen) {
|
if (isDropdownOpen) {
|
||||||
@ -51,13 +55,14 @@ export const LinksFieldMenuItem = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
|
onMouseEnter={handleMouseEnter}
|
||||||
|
onMouseLeave={handleMouseLeave}
|
||||||
text={<LinkDisplay value={{ label, url }} />}
|
text={<LinkDisplay value={{ label, url }} />}
|
||||||
isIconDisplayedOnHoverOnly={!isPrimary && !isDropdownOpen}
|
isIconDisplayedOnHoverOnly={!isPrimary && !isDropdownOpen}
|
||||||
iconButtons={[
|
iconButtons={[
|
||||||
{
|
{
|
||||||
Wrapper: isPrimary
|
Wrapper: isHovered
|
||||||
? undefined
|
? ({ iconButton }) => (
|
||||||
: ({ iconButton }) => (
|
|
||||||
<Dropdown
|
<Dropdown
|
||||||
dropdownId={dropdownId}
|
dropdownId={dropdownId}
|
||||||
dropdownHotkeyScope={{
|
dropdownHotkeyScope={{
|
||||||
@ -69,31 +74,37 @@ export const LinksFieldMenuItem = ({
|
|||||||
clickableComponent={iconButton}
|
clickableComponent={iconButton}
|
||||||
dropdownComponents={
|
dropdownComponents={
|
||||||
<DropdownMenuItemsContainer>
|
<DropdownMenuItemsContainer>
|
||||||
<MenuItem
|
{!isPrimary && (
|
||||||
LeftIcon={IconBookmarkPlus}
|
<MenuItem
|
||||||
text="Set as Primary"
|
LeftIcon={IconBookmarkPlus}
|
||||||
onClick={onSetAsPrimary}
|
text="Set as Primary"
|
||||||
/>
|
onClick={onSetAsPrimary}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
<MenuItem
|
<MenuItem
|
||||||
LeftIcon={IconPencil}
|
LeftIcon={IconPencil}
|
||||||
text="Edit"
|
text="Edit"
|
||||||
onClick={onEdit}
|
onClick={onEdit}
|
||||||
/>
|
/>
|
||||||
<MenuItem
|
{!isPrimary && (
|
||||||
accent="danger"
|
<MenuItem
|
||||||
LeftIcon={IconTrash}
|
accent="danger"
|
||||||
text="Delete"
|
LeftIcon={IconTrash}
|
||||||
onClick={onDelete}
|
text="Delete"
|
||||||
/>
|
onClick={onDelete}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</DropdownMenuItemsContainer>
|
</DropdownMenuItemsContainer>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
),
|
)
|
||||||
Icon: isPrimary
|
: undefined,
|
||||||
? (StyledIconBookmark as IconComponent)
|
Icon:
|
||||||
: IconDotsVertical,
|
isPrimary && !isHovered
|
||||||
|
? (StyledIconBookmark as IconComponent)
|
||||||
|
: IconDotsVertical,
|
||||||
accent: 'tertiary',
|
accent: 'tertiary',
|
||||||
onClick: isPrimary ? undefined : () => {},
|
onClick: isHovered ? () => {} : undefined,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -2,7 +2,6 @@ import { useRef, useState } from 'react';
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
import { useMultiSelectField } from '@/object-record/record-field/meta-types/hooks/useMultiSelectField';
|
import { useMultiSelectField } from '@/object-record/record-field/meta-types/hooks/useMultiSelectField';
|
||||||
import { FieldInputEvent } from '@/object-record/record-field/types/FieldInputEvent';
|
|
||||||
import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu';
|
import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu';
|
||||||
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
|
||||||
import { DropdownMenuSearchInput } from '@/ui/layout/dropdown/components/DropdownMenuSearchInput';
|
import { DropdownMenuSearchInput } from '@/ui/layout/dropdown/components/DropdownMenuSearchInput';
|
||||||
@ -18,7 +17,6 @@ const StyledRelationPickerContainer = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
export type MultiSelectFieldInputProps = {
|
export type MultiSelectFieldInputProps = {
|
||||||
onSubmit?: FieldInputEvent;
|
|
||||||
onCancel?: () => void;
|
onCancel?: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { MouseEvent } from 'react';
|
import { MouseEvent } from 'react';
|
||||||
import styled from '@emotion/styled';
|
|
||||||
|
|
||||||
import { FieldLinkValue } from '@/object-record/record-field/types/FieldMetadata';
|
import { FieldLinkValue } from '@/object-record/record-field/types/FieldMetadata';
|
||||||
import { RoundedLink } from '@/ui/navigation/link/components/RoundedLink';
|
import { RoundedLink } from '@/ui/navigation/link/components/RoundedLink';
|
||||||
@ -11,15 +10,6 @@ import { checkUrlType } from '~/utils/checkUrlType';
|
|||||||
import { getAbsoluteUrl } from '~/utils/url/getAbsoluteUrl';
|
import { getAbsoluteUrl } from '~/utils/url/getAbsoluteUrl';
|
||||||
import { getUrlHostName } from '~/utils/url/getUrlHostName';
|
import { getUrlHostName } from '~/utils/url/getUrlHostName';
|
||||||
|
|
||||||
import { EllipsisDisplay } from './EllipsisDisplay';
|
|
||||||
|
|
||||||
const StyledRawLink = styled(RoundedLink)`
|
|
||||||
a {
|
|
||||||
font-size: ${({ theme }) => theme.font.size.md};
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
type LinkDisplayProps = {
|
type LinkDisplayProps = {
|
||||||
value?: FieldLinkValue;
|
value?: FieldLinkValue;
|
||||||
};
|
};
|
||||||
@ -35,18 +25,15 @@ export const LinkDisplay = ({ value }: LinkDisplayProps) => {
|
|||||||
|
|
||||||
if (type === LinkType.LinkedIn || type === LinkType.Twitter) {
|
if (type === LinkType.LinkedIn || type === LinkType.Twitter) {
|
||||||
return (
|
return (
|
||||||
<EllipsisDisplay>
|
<SocialLink href={absoluteUrl} onClick={handleClick} type={type}>
|
||||||
<SocialLink href={absoluteUrl} onClick={handleClick} type={type}>
|
{displayedValue}
|
||||||
{displayedValue}
|
</SocialLink>
|
||||||
</SocialLink>
|
|
||||||
</EllipsisDisplay>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<EllipsisDisplay>
|
<RoundedLink href={absoluteUrl} onClick={handleClick}>
|
||||||
<StyledRawLink href={absoluteUrl} onClick={handleClick}>
|
{displayedValue}
|
||||||
{displayedValue}
|
</RoundedLink>
|
||||||
</StyledRawLink>
|
|
||||||
</EllipsisDisplay>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -11,14 +11,18 @@ type RoundedLinkProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const StyledLink = styled(ReactLink)`
|
const StyledLink = styled(ReactLink)`
|
||||||
|
font-size: ${({ theme }) => theme.font.size.md};
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
height: ${({ theme }) => theme.spacing(5)};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledChip = styled(Chip)`
|
const StyledChip = styled(Chip)`
|
||||||
border-color: ${({ theme }) => theme.border.color.strong};
|
border-color: ${({ theme }) => theme.border.color.strong};
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding: ${({ theme }) => theme.spacing(2)};
|
padding: ${({ theme }) => theme.spacing(0, 2)};
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
height: ${({ theme }) => theme.spacing(5)};
|
||||||
|
min-width: 40px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const RoundedLink = ({
|
export const RoundedLink = ({
|
||||||
@ -39,7 +43,7 @@ export const RoundedLink = ({
|
|||||||
<StyledChip
|
<StyledChip
|
||||||
label={`${children}`}
|
label={`${children}`}
|
||||||
variant={ChipVariant.Rounded}
|
variant={ChipVariant.Rounded}
|
||||||
size={ChipSize.Small}
|
size={ChipSize.Large}
|
||||||
/>
|
/>
|
||||||
</StyledLink>
|
</StyledLink>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import styled from '@emotion/styled';
|
|
||||||
|
|
||||||
import { getDisplayValueByUrlType } from '~/utils/getDisplayValueByUrlType';
|
import { getDisplayValueByUrlType } from '~/utils/getDisplayValueByUrlType';
|
||||||
|
|
||||||
@ -18,16 +17,6 @@ type SocialLinkProps = {
|
|||||||
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
|
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const StyledRawLink = styled(RoundedLink)`
|
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
a {
|
|
||||||
overflow: hidden;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
white-space: nowrap;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const SocialLink = ({
|
export const SocialLink = ({
|
||||||
children,
|
children,
|
||||||
href,
|
href,
|
||||||
@ -38,8 +27,8 @@ export const SocialLink = ({
|
|||||||
getDisplayValueByUrlType({ type: type, href: href }) ?? children;
|
getDisplayValueByUrlType({ type: type, href: href }) ?? children;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledRawLink href={href} onClick={onClick}>
|
<RoundedLink href={href} onClick={onClick}>
|
||||||
{displayValue}
|
{displayValue}
|
||||||
</StyledRawLink>
|
</RoundedLink>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -19,26 +19,30 @@ export type MenuItemIconButton = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type MenuItemProps = {
|
export type MenuItemProps = {
|
||||||
LeftIcon?: IconComponent | null;
|
|
||||||
accent?: MenuItemAccent;
|
accent?: MenuItemAccent;
|
||||||
text: ReactNode;
|
className?: string;
|
||||||
iconButtons?: MenuItemIconButton[];
|
iconButtons?: MenuItemIconButton[];
|
||||||
isIconDisplayedOnHoverOnly?: boolean;
|
isIconDisplayedOnHoverOnly?: boolean;
|
||||||
isTooltipOpen?: boolean;
|
isTooltipOpen?: boolean;
|
||||||
className?: string;
|
LeftIcon?: IconComponent | null;
|
||||||
testId?: string;
|
|
||||||
onClick?: (event: MouseEvent<HTMLDivElement>) => void;
|
onClick?: (event: MouseEvent<HTMLDivElement>) => void;
|
||||||
|
onMouseEnter?: (event: MouseEvent<HTMLDivElement>) => void;
|
||||||
|
onMouseLeave?: (event: MouseEvent<HTMLDivElement>) => void;
|
||||||
|
testId?: string;
|
||||||
|
text: ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const MenuItem = ({
|
export const MenuItem = ({
|
||||||
LeftIcon,
|
|
||||||
accent = 'default',
|
accent = 'default',
|
||||||
text,
|
className,
|
||||||
iconButtons,
|
iconButtons,
|
||||||
isIconDisplayedOnHoverOnly = true,
|
isIconDisplayedOnHoverOnly = true,
|
||||||
className,
|
LeftIcon,
|
||||||
testId,
|
|
||||||
onClick,
|
onClick,
|
||||||
|
onMouseEnter,
|
||||||
|
onMouseLeave,
|
||||||
|
testId,
|
||||||
|
text,
|
||||||
}: MenuItemProps) => {
|
}: MenuItemProps) => {
|
||||||
const showIconButtons = Array.isArray(iconButtons) && iconButtons.length > 0;
|
const showIconButtons = Array.isArray(iconButtons) && iconButtons.length > 0;
|
||||||
|
|
||||||
@ -57,6 +61,8 @@ export const MenuItem = ({
|
|||||||
className={className}
|
className={className}
|
||||||
accent={accent}
|
accent={accent}
|
||||||
isIconDisplayedOnHoverOnly={isIconDisplayedOnHoverOnly}
|
isIconDisplayedOnHoverOnly={isIconDisplayedOnHoverOnly}
|
||||||
|
onMouseEnter={onMouseEnter}
|
||||||
|
onMouseLeave={onMouseLeave}
|
||||||
>
|
>
|
||||||
<StyledMenuItemLeftContent>
|
<StyledMenuItemLeftContent>
|
||||||
<MenuItemLeftContent LeftIcon={LeftIcon ?? undefined} text={text} />
|
<MenuItemLeftContent LeftIcon={LeftIcon ?? undefined} text={text} />
|
||||||
|
|||||||
@ -87,13 +87,6 @@ const StyledContainer = styled('div', {
|
|||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
// Size style overrides
|
|
||||||
${({ theme, size }) =>
|
|
||||||
size === ChipSize.Large &&
|
|
||||||
css`
|
|
||||||
height: ${theme.spacing(4)};
|
|
||||||
`}
|
|
||||||
|
|
||||||
// Variant style overrides
|
// Variant style overrides
|
||||||
${({ disabled, theme, variant }) => {
|
${({ disabled, theme, variant }) => {
|
||||||
if (variant === ChipVariant.Regular) {
|
if (variant === ChipVariant.Regular) {
|
||||||
@ -153,6 +146,13 @@ const StyledLabel = styled.span`
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const StyledOverflowingTextWithTooltip = styled(OverflowingTextWithTooltip)<{
|
||||||
|
size?: ChipSize;
|
||||||
|
}>`
|
||||||
|
height: ${({ theme, size }) =>
|
||||||
|
size === ChipSize.Large ? theme.spacing(4) : 'auto'};
|
||||||
|
`;
|
||||||
|
|
||||||
export const Chip = ({
|
export const Chip = ({
|
||||||
size = ChipSize.Small,
|
size = ChipSize.Small,
|
||||||
label,
|
label,
|
||||||
@ -183,7 +183,7 @@ export const Chip = ({
|
|||||||
>
|
>
|
||||||
{leftComponent}
|
{leftComponent}
|
||||||
<StyledLabel>
|
<StyledLabel>
|
||||||
<OverflowingTextWithTooltip text={label} />
|
<StyledOverflowingTextWithTooltip size={size} text={label} />
|
||||||
</StyledLabel>
|
</StyledLabel>
|
||||||
{rightComponent}
|
{rightComponent}
|
||||||
</StyledContainer>
|
</StyledContainer>
|
||||||
|
|||||||
Reference in New Issue
Block a user