The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
import { styled } from '@linaria/react';
import { useContext } from 'react';
import { FieldContext } from '@/object-record/record-field/ui/contexts/FieldContext';
import { useFieldFocus } from '@/object-record/record-field/ui/hooks/useFieldFocus';
import { useRecordInlineCellContext } from '@/object-record/record-inline-cell/components/RecordInlineCellContext';
import { RecordInlineCellValue } from '@/object-record/record-inline-cell/components/RecordInlineCellValue';
import { themeCssVariables } from 'twenty-ui/theme';
const StyledValueContainer = styled.div<{ readonly: boolean }>`
display: flex;
min-width: 0;
position: relative;
width: 100%;
`;
const StyledInlineCellBaseContainer = styled.div<{ readonly: boolean }>`
align-items: center;
box-sizing: border-box;
cursor: ${({ readonly }) => (readonly ? 'default' : 'pointer')};
display: flex;
gap: ${themeCssVariables.spacing[1]};
height: fit-content;
user-select: none;
width: 100%;
`;
export const FieldWidgetInlineCellContainer = () => {
const { readonly } = useRecordInlineCellContext();
const { onMouseEnter, onMouseLeave, anchorId } = useContext(FieldContext);
const { setIsFocused } = useFieldFocus();
const handleContainerMouseEnter = () => {
if (!readonly) {
setIsFocused(true);
}
onMouseEnter?.();
};
const handleContainerMouseLeave = () => {
if (!readonly) {
setIsFocused(false);
}
onMouseLeave?.();
};
return (
<StyledInlineCellBaseContainer
readonly={readonly ?? false}
onMouseEnter={handleContainerMouseEnter}
onMouseLeave={handleContainerMouseLeave}
>
<StyledValueContainer readonly={readonly ?? false} id={anchorId}>
<RecordInlineCellValue />
</StyledValueContainer>
</StyledInlineCellBaseContainer>
);
};