removed unused files, unnecessary exports and renamed ownProps (#1225)

* remove unused files and rename ownProps

* restore unused icons
This commit is contained in:
Weiko
2023-08-15 17:02:02 -07:00
committed by GitHub
parent c9549c3833
commit aa1f9bcab3
41 changed files with 117 additions and 543 deletions

View File

@ -1,9 +0,0 @@
import Skeleton from 'react-loading-skeleton';
export function CellSkeleton() {
return (
<div style={{ width: '100%', alignItems: 'center' }}>
<Skeleton />
</div>
);
}

View File

@ -22,7 +22,7 @@ const StyledEditButtonContainer = styled(motion.div)`
right: 5px;
`;
export const CellBaseContainer = styled.div`
const StyledCellBaseContainer = styled.div`
align-items: center;
box-sizing: border-box;
cursor: pointer;
@ -33,7 +33,7 @@ export const CellBaseContainer = styled.div`
width: 100%;
`;
type OwnProps = {
export type EditableCellProps = {
editModeContent: ReactElement;
nonEditModeContent: ReactElement;
editModeHorizontalAlign?: 'left' | 'right';
@ -59,7 +59,7 @@ export function EditableCell({
transparent = false,
maxContentWidth,
useEditButton,
}: OwnProps) {
}: EditableCellProps) {
const { isCurrentCellInEditMode } = useCurrentCellEditMode();
const [isHovered, setIsHovered] = useState(false);
@ -88,7 +88,7 @@ export function EditableCell({
<CellHotkeyScopeContext.Provider
value={editHotkeyScope ?? DEFAULT_CELL_SCOPE}
>
<CellBaseContainer
<StyledCellBaseContainer
onMouseEnter={handleContainerMouseEnter}
onMouseLeave={handleContainerMouseLeave}
>
@ -128,7 +128,7 @@ export function EditableCell({
</EditableCellDisplayMode>
</>
)}
</CellBaseContainer>
</StyledCellBaseContainer>
</CellHotkeyScopeContext.Provider>
);
}

View File

@ -1,14 +1,14 @@
import { Ref } from 'react';
import styled from '@emotion/styled';
type Props = {
export type EditableCellDisplayContainerProps = {
softFocus?: boolean;
onClick?: () => void;
scrollRef?: Ref<HTMLDivElement>;
};
export const EditableCellDisplayModeOuterContainer = styled.div<
Pick<Props, 'softFocus'>
const StyledEditableCellDisplayModeOuterContainer = styled.div<
Pick<EditableCellDisplayContainerProps, 'softFocus'>
>`
align-items: center;
display: flex;
@ -22,12 +22,12 @@ export const EditableCellDisplayModeOuterContainer = styled.div<
${(props) =>
props.softFocus
? `background: ${props.theme.background.transparent.secondary};
border-radius: ${props.theme.border.radius.sm};
box-shadow: inset 0 0 0 1px ${props.theme.font.color.extraLight};`
border-radius: ${props.theme.border.radius.sm};
box-shadow: inset 0 0 0 1px ${props.theme.font.color.extraLight};`
: ''}
`;
export const EditableCellDisplayModeInnerContainer = styled.div`
const EditableCellDisplayModeInnerContainer = styled.div`
align-items: center;
display: flex;
height: 100%;
@ -40,9 +40,9 @@ export function EditableCellDisplayContainer({
softFocus,
onClick,
scrollRef,
}: React.PropsWithChildren<Props>) {
}: React.PropsWithChildren<EditableCellDisplayContainerProps>) {
return (
<EditableCellDisplayModeOuterContainer
<StyledEditableCellDisplayModeOuterContainer
data-testid={
softFocus
? 'editable-cell-soft-focus-mode'
@ -55,6 +55,6 @@ export function EditableCellDisplayContainer({
<EditableCellDisplayModeInnerContainer>
{children}
</EditableCellDisplayModeInnerContainer>
</EditableCellDisplayModeOuterContainer>
</StyledEditableCellDisplayModeOuterContainer>
);
}

View File

@ -3,7 +3,7 @@ import styled from '@emotion/styled';
import { overlayBackground } from '@/ui/theme/constants/effects';
export const EditableCellEditModeContainer = styled.div<OwnProps>`
const StyledEditableCellEditModeContainer = styled.div<EditableCellEditModeProps>`
align-items: center;
border: ${({ transparent, theme }) =>
transparent ? 'none' : `1px solid ${theme.border.color.light}`};
@ -28,7 +28,7 @@ export const EditableCellEditModeContainer = styled.div<OwnProps>`
z-index: 1;
`;
type OwnProps = {
export type EditableCellEditModeProps = {
children: ReactElement;
transparent?: boolean;
maxContentWidth?: number;
@ -43,9 +43,9 @@ export function EditableCellEditMode({
children,
transparent = false,
maxContentWidth,
}: OwnProps) {
}: EditableCellEditModeProps) {
return (
<EditableCellEditModeContainer
<StyledEditableCellEditModeContainer
maxContentWidth={maxContentWidth}
transparent={transparent}
data-testid="editable-cell-edit-mode-container"
@ -53,6 +53,6 @@ export function EditableCellEditMode({
editModeVerticalPosition={editModeVerticalPosition}
>
{children}
</EditableCellEditModeContainer>
</StyledEditableCellEditModeContainer>
);
}

View File

@ -9,17 +9,17 @@ import { useListenClickOutside } from '@/ui/utilities/pointer-event/hooks/useLis
import { useEditableCell } from '../../hooks/useEditableCell';
const EditableCellDateEditModeContainer = styled.div`
const StyledEditableCellDateEditModeContainer = styled.div`
margin-top: -1px;
width: 100%;
`;
export type EditableDateProps = {
export type DateCellEditProps = {
value: Date;
onSubmit: (date: Date) => void;
};
export function DateCellEdit({ value, onSubmit }: EditableDateProps) {
export function DateCellEdit({ value, onSubmit }: DateCellEditProps) {
const { closeEditableCell } = useEditableCell();
function handleDateChange(newDate: Date) {
@ -51,8 +51,8 @@ export function DateCellEdit({ value, onSubmit }: EditableDateProps) {
});
return (
<EditableCellDateEditModeContainer ref={containerRef}>
<StyledEditableCellDateEditModeContainer ref={containerRef}>
<DateInputEdit onChange={handleDateChange} value={value} />
</EditableCellDateEditModeContainer>
</StyledEditableCellDateEditModeContainer>
);
}

View File

@ -1,19 +0,0 @@
import { useRecoilCallback } from 'recoil';
import { tableRowIdsState } from '../states/tableRowIdsState';
export function useSetTableRowIds() {
return useRecoilCallback(
({ set, snapshot }) =>
(rowIds: string[]) => {
const currentRowIds = snapshot
.getLoadable(tableRowIdsState)
.valueOrThrow();
if (JSON.stringify(rowIds) !== JSON.stringify(currentRowIds)) {
set(tableRowIdsState, rowIds);
}
},
[],
);
}

View File

@ -1,6 +0,0 @@
import { atomFamily } from 'recoil';
export const currentColumnNumberScopedState = atomFamily<number, string>({
key: 'currentColumnNumberScopedState',
default: 0,
});

View File

@ -1,6 +0,0 @@
import { atomFamily } from 'recoil';
export const currentRowEntityIdScopedState = atomFamily<string | null, string>({
key: 'currentRowEntityIdScopedState',
default: null,
});

View File

@ -1,6 +0,0 @@
import { atomFamily } from 'recoil';
export const currentRowNumberScopedState = atomFamily<number, string>({
key: 'currentRowNumberScopedState',
default: 0,
});

View File

@ -1,5 +0,0 @@
export type EntityUpdateFieldHook = () => <T>(
entityId: string,
fieldName: string,
value: T,
) => void | Promise<void>;

View File

@ -1,7 +0,0 @@
import { CellPosition } from '../CellPosition';
export function isTablePosition(value: any): value is CellPosition {
return (
value && typeof value.row === 'number' && typeof value.column === 'number'
);
}