Merge pull request #204 from liby/feature/remove-react-fc

chore: remove residual `FC` and `FunctionComponent` from components
This commit is contained in:
DarkSky
2022-08-12 19:52:35 +08:00
committed by GitHub
86 changed files with 97 additions and 121 deletions
@@ -1,9 +1,15 @@
import { type FC, useRef } from 'react'; import { type ComponentType, useRef } from 'react';
import * as uiIcons from '@toeverything/components/icons'; import * as uiIcons from '@toeverything/components/icons';
import { message, styled } from '@toeverything/components/ui'; import { message, styled } from '@toeverything/components/ui';
import { copy } from './copy'; import { copy } from './copy';
const IconBooth = ({ name, Icon }: { name: string; Icon: FC<any> }) => { const IconBooth = ({
name,
Icon,
}: {
name: string;
Icon: ComponentType<any>;
}) => {
const on_click = () => { const on_click = () => {
copy(`<${name} />`); copy(`<${name} />`);
message.success('Copied ~'); message.success('Copied ~');
@@ -36,7 +42,13 @@ export const Icons = () => {
<hr /> <hr />
<IconsContainer> <IconsContainer>
{_icons.map(([key, icon]) => { {_icons.map(([key, icon]) => {
return <IconBooth key={key} name={key} Icon={icon as FC} />; return (
<IconBooth
key={key}
name={key}
Icon={icon as ComponentType<any>}
/>
);
})} })}
</IconsContainer> </IconsContainer>
</Container> </Container>
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import type { TldrawApp } from '@toeverything/components/board-state'; import type { TldrawApp } from '@toeverything/components/board-state';
import type { TDShape } from '@toeverything/components/board-types'; import type { TDShape } from '@toeverything/components/board-types';
import { Popover, Tooltip, IconButton } from '@toeverything/components/ui'; import { Popover, Tooltip, IconButton } from '@toeverything/components/ui';
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import { Fragment } from 'react'; import { Fragment } from 'react';
import { Vec } from '@tldraw/vec'; import { Vec } from '@tldraw/vec';
import { TldrawApp, TLDR } from '@toeverything/components/board-state'; import { TldrawApp, TLDR } from '@toeverything/components/board-state';
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import type { TldrawApp } from '@toeverything/components/board-state'; import type { TldrawApp } from '@toeverything/components/board-state';
import type { TDShape } from '@toeverything/components/board-types'; import type { TDShape } from '@toeverything/components/board-types';
import { IconButton, Tooltip } from '@toeverything/components/ui'; import { IconButton, Tooltip } from '@toeverything/components/ui';
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import type { TldrawApp } from '@toeverything/components/board-state'; import type { TldrawApp } from '@toeverything/components/board-state';
import type { TDShape } from '@toeverything/components/board-types'; import type { TDShape } from '@toeverything/components/board-types';
import { import {
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import type { TldrawApp } from '@toeverything/components/board-state'; import type { TldrawApp } from '@toeverything/components/board-state';
import type { TDShape } from '@toeverything/components/board-types'; import type { TDShape } from '@toeverything/components/board-types';
import { FontSizeStyle } from '@toeverything/components/board-types'; import { FontSizeStyle } from '@toeverything/components/board-types';
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import type { TldrawApp } from '@toeverything/components/board-state'; import type { TldrawApp } from '@toeverything/components/board-state';
import type { TDShape } from '@toeverything/components/board-types'; import type { TDShape } from '@toeverything/components/board-types';
import { import {
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import type { TldrawApp } from '@toeverything/components/board-state'; import type { TldrawApp } from '@toeverything/components/board-state';
import type { TDShape } from '@toeverything/components/board-types'; import type { TDShape } from '@toeverything/components/board-types';
import { IconButton, Tooltip } from '@toeverything/components/ui'; import { IconButton, Tooltip } from '@toeverything/components/ui';
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import type { TldrawApp } from '@toeverything/components/board-state'; import type { TldrawApp } from '@toeverything/components/board-state';
import type { TDShape } from '@toeverything/components/board-types'; import type { TDShape } from '@toeverything/components/board-types';
import { IconButton, Tooltip } from '@toeverything/components/ui'; import { IconButton, Tooltip } from '@toeverything/components/ui';
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import { DashStyle, StrokeWidth } from '@toeverything/components/board-types'; import { DashStyle, StrokeWidth } from '@toeverything/components/board-types';
import { import {
LineNoneIcon, LineNoneIcon,
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import type { TldrawApp } from '@toeverything/components/board-state'; import type { TldrawApp } from '@toeverything/components/board-state';
import { DashStyle, StrokeWidth } from '@toeverything/components/board-types'; import { DashStyle, StrokeWidth } from '@toeverything/components/board-types';
import type { TDShape } from '@toeverything/components/board-types'; import type { TDShape } from '@toeverything/components/board-types';
@@ -1,4 +1,4 @@
import type { FC, ReactNode } from 'react'; import type { ReactNode } from 'react';
export const ContextMenu = ({ children }: { children: ReactNode }) => { export const ContextMenu = ({ children }: { children: ReactNode }) => {
return <div>{children}</div>; return <div>{children}</div>;
@@ -1,4 +1,4 @@
import type { FC, PropsWithChildren } from 'react'; import type { PropsWithChildren } from 'react';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { styled, Tooltip } from '@toeverything/components/ui'; import { styled, Tooltip } from '@toeverything/components/ui';
import { ShapeColorNoneIcon } from '@toeverything/components/icons'; import { ShapeColorNoneIcon } from '@toeverything/components/icons';
@@ -1,4 +1,4 @@
import { FC, useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import { import {
ConnectorIcon, ConnectorIcon,
ConectorLineIcon, ConectorLineIcon,
@@ -1,4 +1,4 @@
import { FC, useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
import { import {
ShapeIcon, ShapeIcon,
RectangleIcon, RectangleIcon,
@@ -1,4 +1,3 @@
import { FC } from 'react';
import style9 from 'style9'; import style9 from 'style9';
import { import {
// MuiIconButton as IconButton, // MuiIconButton as IconButton,
@@ -14,6 +13,10 @@ import {
SelectIcon, SelectIcon,
TextIcon, TextIcon,
EraserIcon, EraserIcon,
SelectIconProps,
EraserIconProps,
HandToolIconProps,
TextIconProps,
} from '@toeverything/components/icons'; } from '@toeverything/components/icons';
import { import {
@@ -26,6 +29,7 @@ import { TldrawApp } from '@toeverything/components/board-state';
import { ShapeTools } from './ShapeTools'; import { ShapeTools } from './ShapeTools';
import { PenTools } from './pen-tools'; import { PenTools } from './pen-tools';
import { LineTools } from './LineTools'; import { LineTools } from './LineTools';
import { ComponentType, Component } from 'react';
const activeToolSelector = (s: TDSnapshot) => s.appState.activeTool; const activeToolSelector = (s: TDSnapshot) => s.appState.activeTool;
const toolLockedSelector = (s: TDSnapshot) => s.appState.isToolLocked; const toolLockedSelector = (s: TDSnapshot) => s.appState.isToolLocked;
@@ -34,8 +38,10 @@ const tools: Array<{
type: string; type: string;
label?: string; label?: string;
tooltip?: string; tooltip?: string;
icon?: FC; icon?: ComponentType<
component?: FC<{ app: TldrawApp }>; SelectIconProps | EraserIconProps | HandToolIconProps | TextIconProps
>;
component?: ComponentType<{ app: TldrawApp }>;
}> = [ }> = [
{ {
type: 'select', type: 'select',
@@ -1,4 +1,4 @@
import type { FC, ReactNode } from 'react'; import type { ReactNode } from 'react';
import { Tooltip, styled, IconButton } from '@toeverything/components/ui'; import { Tooltip, styled, IconButton } from '@toeverything/components/ui';
interface PenProps { interface PenProps {
@@ -1,4 +1,4 @@
import { FC, ReactElement, type CSSProperties } from 'react'; import { ReactElement, type CSSProperties } from 'react';
import style9 from 'style9'; import style9 from 'style9';
import { import {
MuiDivider as Divider, MuiDivider as Divider,
@@ -1,4 +1,3 @@
import { FC } from 'react';
import { import {
MuiIconButton as IconButton, MuiIconButton as IconButton,
MuiButton as Button, MuiButton as Button,
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import { Utils } from '@tldraw/core'; import { Utils } from '@tldraw/core';
import Vec from '@tldraw/vec'; import Vec from '@tldraw/vec';
import { TLDR } from '@toeverything/components/board-state'; import { TLDR } from '@toeverything/components/board-state';
@@ -1,4 +1,4 @@
import type { FC, CSSProperties } from 'react'; import type { CSSProperties } from 'react';
import type { TLBounds } from '@tldraw/core'; import type { TLBounds } from '@tldraw/core';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
@@ -1,4 +1,4 @@
import type { FC, CSSProperties, PointerEventHandler } from 'react'; import type { CSSProperties, PointerEventHandler } from 'react';
import { useState, useRef } from 'react'; import { useState, useRef } from 'react';
import type { TLBounds } from '@tldraw/core'; import type { TLBounds } from '@tldraw/core';
import Vec from '@tldraw/vec'; import Vec from '@tldraw/vec';
@@ -1,4 +1,4 @@
import { FC, useState } from 'react'; import { useState } from 'react';
import { useNavigate } from 'react-router'; import { useNavigate } from 'react-router';
import clsx from 'clsx'; import clsx from 'clsx';
import style9 from 'style9'; import style9 from 'style9';
@@ -21,7 +21,7 @@ export const commonListContainer = 'commonListContainer';
type Content = { type Content = {
id: string; id: string;
content: string; content: string;
icon: FC<SvgIconProps>; icon: (prop: SvgIconProps) => JSX.Element;
}; };
export type CommonListItem = { export type CommonListItem = {
@@ -5,7 +5,7 @@ import {
Protocol, Protocol,
} from '@toeverything/datasource/db-service'; } from '@toeverything/datasource/db-service';
import { type CreateView } from '@toeverything/framework/virgo'; import { type CreateView } from '@toeverything/framework/virgo';
import { useEffect, useRef, useState, type FC } from 'react'; import { useEffect, useRef, useState } from 'react';
import { import {
TextManage, TextManage,
@@ -1,4 +1,4 @@
import { FC, useState, useRef, useEffect } from 'react'; import { useState, useRef, useEffect } from 'react';
import { StyleWithAtRules } from 'style9'; import { StyleWithAtRules } from 'style9';
import { CreateView } from '@toeverything/framework/virgo'; import { CreateView } from '@toeverything/framework/virgo';
@@ -1,4 +1,4 @@
import { FC, useState } from 'react'; import { useState } from 'react';
import { CreateView } from '@toeverything/framework/virgo'; import { CreateView } from '@toeverything/framework/virgo';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import { useOnSelect } from '@toeverything/components/editor-core'; import { useOnSelect } from '@toeverything/components/editor-core';
@@ -1,4 +1,4 @@
import { FC, useState } from 'react'; import { useState } from 'react';
import { CreateView } from '@toeverything/framework/virgo'; import { CreateView } from '@toeverything/framework/virgo';
import { import {
BlockPendantProvider, BlockPendantProvider,
@@ -1,4 +1,4 @@
import { FC, useState } from 'react'; import { useState } from 'react';
import { CreateView } from '@toeverything/framework/virgo'; import { CreateView } from '@toeverything/framework/virgo';
import { import {
useOnSelect, useOnSelect,
@@ -1,4 +1,4 @@
import { FC, useState, useEffect, useRef } from 'react'; import { useState, useEffect, useRef } from 'react';
import { CreateView } from '@toeverything/framework/virgo'; import { CreateView } from '@toeverything/framework/virgo';
import { Upload } from '../../components/upload/upload'; import { Upload } from '../../components/upload/upload';
import { services, FileColumnValue } from '@toeverything/datasource/db-service'; import { services, FileColumnValue } from '@toeverything/datasource/db-service';
@@ -1,4 +1,4 @@
import { FC, useEffect, useLayoutEffect, useRef } from 'react'; import { useEffect, useLayoutEffect, useRef } from 'react';
import { ChildrenView } from '@toeverything/framework/virgo'; import { ChildrenView } from '@toeverything/framework/virgo';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import { sleep } from '@toeverything/utils'; import { sleep } from '@toeverything/utils';
@@ -1,8 +1,9 @@
import { FC } from 'react';
import { RenderBlock } from '@toeverything/components/editor-core'; import { RenderBlock } from '@toeverything/components/editor-core';
import { ChildrenView, CreateView } from '@toeverything/framework/virgo'; import { ChildrenView, CreateView } from '@toeverything/framework/virgo';
export const GridItemRender = function (creator: FC<ChildrenView>) { export const GridItemRender = function (
creator: (prop: ChildrenView) => JSX.Element
) {
const GridItem = function (props: CreateView) { const GridItem = function (props: CreateView) {
const { block } = props; const { block } = props;
const children = ( const children = (
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import { useState } from 'react'; import { useState } from 'react';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import { BlockEditor } from '@toeverything/framework/virgo'; import { BlockEditor } from '@toeverything/framework/virgo';
@@ -1,6 +1,6 @@
import { RenderBlock } from '@toeverything/components/editor-core'; import { RenderBlock } from '@toeverything/components/editor-core';
import { CreateView } from '@toeverything/framework/virgo'; import { CreateView } from '@toeverything/framework/virgo';
import React, { FC, useEffect, useRef, useState } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import { GridHandle } from './GirdHandle'; import { GridHandle } from './GirdHandle';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
@@ -1,8 +1,7 @@
import { FC } from 'react';
import { CreateView } from '@toeverything/framework/virgo'; import { CreateView } from '@toeverything/framework/virgo';
import { BlockContainer } from '../../components/BlockContainer'; import { BlockContainer } from '../../components/BlockContainer';
export function GridRender(creator: FC<CreateView>) { export function GridRender(creator: (prop: CreateView) => JSX.Element) {
return function GridWithItem(props: CreateView) { return function GridWithItem(props: CreateView) {
const { editor, block } = props; const { editor, block } = props;
return ( return (
@@ -8,7 +8,7 @@ import {
} from '@toeverything/components/editor-core'; } from '@toeverything/components/editor-core';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import type { CreateView } from '@toeverything/framework/virgo'; import type { CreateView } from '@toeverything/framework/virgo';
import type { ComponentType, FC } from 'react'; import type { ComponentType } from 'react';
import { useState } from 'react'; import { useState } from 'react';
import { GroupMenuWrapper } from './group-menu'; import { GroupMenuWrapper } from './group-menu';
import { SceneKanban } from './scene-kanban'; import { SceneKanban } from './scene-kanban';
@@ -1,6 +1,5 @@
import { RenderBlockChildren } from '@toeverything/components/editor-core'; import { RenderBlockChildren } from '@toeverything/components/editor-core';
import type { CreateView } from '@toeverything/framework/virgo'; import type { CreateView } from '@toeverything/framework/virgo';
import { FC } from 'react';
export const ScenePage = ({ block }: CreateView) => { export const ScenePage = ({ block }: CreateView) => {
return <RenderBlockChildren block={block} />; return <RenderBlockChildren block={block} />;
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import { useState, useMemo, useEffect } from 'react'; import { useState, useMemo, useEffect } from 'react';
import type { DefaultColumnsValue } from '@toeverything/datasource/db-service'; import type { DefaultColumnsValue } from '@toeverything/datasource/db-service';
import type { CreateView } from '@toeverything/framework/virgo'; import type { CreateView } from '@toeverything/framework/virgo';
@@ -1,9 +1,9 @@
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import type { FC } from 'react';
import type { SvgIconProps } from '@toeverything/components/ui'; import type { SvgIconProps } from '@toeverything/components/ui';
interface Props { interface Props {
Icon: FC<SvgIconProps>; Icon: (prop: SvgIconProps) => JSX.Element;
text?: string; text?: string;
onClick: () => void; onClick: () => void;
} }
@@ -1,4 +1,3 @@
import { FC } from 'react';
import { CreateView } from '@toeverything/framework/virgo'; import { CreateView } from '@toeverything/framework/virgo';
export const GroupDividerView = ({ block, editor }: CreateView) => { export const GroupDividerView = ({ block, editor }: CreateView) => {
@@ -6,7 +6,7 @@ import {
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import { services } from '@toeverything/datasource/db-service'; import { services } from '@toeverything/datasource/db-service';
import { CreateView } from '@toeverything/framework/virgo'; import { CreateView } from '@toeverything/framework/virgo';
import { FC, useEffect, useRef, useState } from 'react'; import { useEffect, useRef, useState } from 'react';
import { Image as SourceView } from '../../components/ImageView'; import { Image as SourceView } from '../../components/ImageView';
import { Upload } from '../../components/upload/upload'; import { Upload } from '../../components/upload/upload';
import { SCENE_CONFIG } from '../group/config'; import { SCENE_CONFIG } from '../group/config';
@@ -5,7 +5,7 @@ import {
Protocol, Protocol,
} from '@toeverything/datasource/db-service'; } from '@toeverything/datasource/db-service';
import { type CreateView } from '@toeverything/framework/virgo'; import { type CreateView } from '@toeverything/framework/virgo';
import { useEffect, useRef, useState, type FC } from 'react'; import { useEffect, useRef, useState } from 'react';
import { import {
TextManage, TextManage,
type ExtendedTextUtils, type ExtendedTextUtils,
@@ -1,4 +1,4 @@
import { FC, useRef, useEffect, useMemo, useState } from 'react'; import { useRef, useEffect, useMemo, useState } from 'react';
import { useParams } from 'react-router'; import { useParams } from 'react-router';
import { BackLink, TextProps } from '@toeverything/components/common'; import { BackLink, TextProps } from '@toeverything/components/common';
@@ -13,9 +13,9 @@ import {
} from '@toeverything/framework/virgo'; } from '@toeverything/framework/virgo';
import { PageView } from './PageView'; import { PageView } from './PageView';
import { ComponentType, FC } from 'react';
export const PageChildrenView: FC<ChildrenView> = props => props.children; export const PageChildrenView: (prop: ChildrenView) => JSX.Element = props =>
props.children;
export class PageBlock extends BaseView { export class PageBlock extends BaseView {
type = Protocol.Block.Type.page; type = Protocol.Block.Type.page;
@@ -1,4 +1,4 @@
import { FC, useEffect, useMemo, useState } from 'react'; import { useEffect, useMemo, useState } from 'react';
import { InlineRefLink } from '@toeverything/components/common'; import { InlineRefLink } from '@toeverything/components/common';
import { CreateView } from '@toeverything/framework/virgo'; import { CreateView } from '@toeverything/framework/virgo';
@@ -10,13 +10,13 @@ import {
getTextProperties, getTextProperties,
SelectBlock, SelectBlock,
} from '@toeverything/framework/virgo'; } from '@toeverything/framework/virgo';
import { FC } from 'react';
import { TextView } from './TextView'; import { TextView } from './TextView';
export class QuoteBlock extends BaseView { export class QuoteBlock extends BaseView {
type = Protocol.Block.Type.quote; type = Protocol.Block.Type.quote;
View: FC<CreateView> = TextView; View: (prop: CreateView) => JSX.Element = TextView;
// override ChildrenView = IndentWrapper; // override ChildrenView = IndentWrapper;
@@ -83,7 +83,7 @@ export class QuoteBlock extends BaseView {
export class CalloutBlock extends BaseView { export class CalloutBlock extends BaseView {
type = Protocol.Block.Type.callout; type = Protocol.Block.Type.callout;
View: FC<CreateView> = TextView; View: (prop: CreateView) => JSX.Element = TextView;
// override ChildrenView = IndentWrapper; // override ChildrenView = IndentWrapper;
@@ -11,13 +11,13 @@ import {
Protocol, Protocol,
} from '@toeverything/datasource/db-service'; } from '@toeverything/datasource/db-service';
import { TextView } from './TextView'; import { TextView } from './TextView';
import { FC } from 'react';
import { getRandomString } from '@toeverything/components/common'; import { getRandomString } from '@toeverything/components/common';
export class TextBlock extends BaseView { export class TextBlock extends BaseView {
type = Protocol.Block.Type.text; type = Protocol.Block.Type.text;
View: FC<CreateView> = TextView; View: (prop: CreateView) => JSX.Element = TextView;
override async onCreate(block: AsyncBlock): Promise<AsyncBlock> { override async onCreate(block: AsyncBlock): Promise<AsyncBlock> {
if (!block.getProperty('text')) { if (!block.getProperty('text')) {
@@ -134,7 +134,7 @@ export class TextBlock extends BaseView {
export class Heading1Block extends BaseView { export class Heading1Block extends BaseView {
type = Protocol.Block.Type.heading1; type = Protocol.Block.Type.heading1;
View: FC<CreateView> = TextView; View: (prop: CreateView) => JSX.Element = TextView;
override async onCreate(block: AsyncBlock): Promise<AsyncBlock> { override async onCreate(block: AsyncBlock): Promise<AsyncBlock> {
if (!block.getProperty('text')) { if (!block.getProperty('text')) {
@@ -199,7 +199,7 @@ export class Heading1Block extends BaseView {
export class Heading2Block extends BaseView { export class Heading2Block extends BaseView {
type = Protocol.Block.Type.heading2; type = Protocol.Block.Type.heading2;
View: FC<CreateView> = TextView; View: (prop: CreateView) => JSX.Element = TextView;
override async onCreate(block: AsyncBlock): Promise<AsyncBlock> { override async onCreate(block: AsyncBlock): Promise<AsyncBlock> {
if (!block.getProperty('text')) { if (!block.getProperty('text')) {
@@ -264,7 +264,7 @@ export class Heading2Block extends BaseView {
export class Heading3Block extends BaseView { export class Heading3Block extends BaseView {
type = Protocol.Block.Type.heading3; type = Protocol.Block.Type.heading3;
View: FC<CreateView> = TextView; View: (prop: CreateView) => JSX.Element = TextView;
override async onCreate(block: AsyncBlock): Promise<AsyncBlock> { override async onCreate(block: AsyncBlock): Promise<AsyncBlock> {
if (!block.getProperty('text')) { if (!block.getProperty('text')) {
@@ -1,4 +1,4 @@
import { FC, useState } from 'react'; import { useState } from 'react';
import { CustomText, TextProps } from '@toeverything/components/common'; import { CustomText, TextProps } from '@toeverything/components/common';
import { import {
@@ -1,4 +1,4 @@
import { FC, useEffect, useState } from 'react'; import { useEffect, useState } from 'react';
import { CreateView } from '@toeverything/framework/virgo'; import { CreateView } from '@toeverything/framework/virgo';
import { import {
is_heading_child_type, is_heading_child_type,
@@ -1,5 +1,5 @@
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import { FC, useMemo } from 'react'; import { useMemo } from 'react';
interface CheckBoxProps { interface CheckBoxProps {
size?: number; size?: number;
@@ -5,7 +5,7 @@ import {
Protocol, Protocol,
} from '@toeverything/datasource/db-service'; } from '@toeverything/datasource/db-service';
import { AsyncBlock, type CreateView } from '@toeverything/framework/virgo'; import { AsyncBlock, type CreateView } from '@toeverything/framework/virgo';
import { useRef, type FC } from 'react'; import { useRef } from 'react';
import { import {
TextManage, TextManage,
type ExtendedTextUtils, type ExtendedTextUtils,
@@ -1,4 +1,4 @@
import { FC, useState } from 'react'; import { useState } from 'react';
import { CreateView } from '@toeverything/framework/virgo'; import { CreateView } from '@toeverything/framework/virgo';
import { Upload } from '../../components/upload/upload'; import { Upload } from '../../components/upload/upload';
import { SourceView } from '../../components/source-view'; import { SourceView } from '../../components/source-view';
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import { AsyncBlock, BlockEditor } from '@toeverything/framework/virgo'; import { AsyncBlock, BlockEditor } from '@toeverything/framework/virgo';
@@ -1,5 +1,5 @@
import { AsyncBlock } from '@toeverything/framework/virgo'; import { AsyncBlock } from '@toeverything/framework/virgo';
import { FC } from 'react';
import { ResizableBox } from 'react-resizable'; import { ResizableBox } from 'react-resizable';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
@@ -1,4 +1,4 @@
import { FC, PropsWithChildren } from 'react'; import { PropsWithChildren } from 'react';
import { ChildrenView } from '@toeverything/framework/virgo'; import { ChildrenView } from '@toeverything/framework/virgo';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
@@ -1,4 +1,4 @@
import { FC, useMemo } from 'react'; import { useMemo } from 'react';
import { createEditor } from 'slate'; import { createEditor } from 'slate';
import { Slate, Editable as SlateEditable, withReact } from 'slate-react'; import { Slate, Editable as SlateEditable, withReact } from 'slate-react';
import { ErrorBoundary } from '@toeverything/utils'; import { ErrorBoundary } from '@toeverything/utils';
@@ -4,14 +4,7 @@ import {
useLazyIframe, useLazyIframe,
} from '@toeverything/components/editor-core'; } from '@toeverything/components/editor-core';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import { import { ReactElement, ReactNode, useEffect, useRef, useState } from 'react';
FC,
ReactElement,
ReactNode,
useEffect,
useRef,
useState,
} from 'react';
import { SCENE_CONFIG } from '../../blocks/group/config'; import { SCENE_CONFIG } from '../../blocks/group/config';
import { BlockPreview } from './BlockView'; import { BlockPreview } from './BlockView';
import { formatUrl } from './format-url'; import { formatUrl } from './format-url';
@@ -6,7 +6,7 @@ import {
useLayoutEffect, useLayoutEffect,
useCallback, useCallback,
} from 'react'; } from 'react';
import type { FC } from 'react';
import { VariableSizeGrid, areEqual } from 'react-window'; import { VariableSizeGrid, areEqual } from 'react-window';
import type { import type {
GridChildComponentProps, GridChildComponentProps,
@@ -34,7 +34,7 @@ export interface CustomCellProps<T = unknown> {
value: T; value: T;
valueKey: string; valueKey: string;
} }
export type CustomCell<T = unknown> = FC<CustomCellProps<T>>; export type CustomCell<T = unknown> = (prop: CustomCellProps<T>) => JSX.Element;
interface TableData { interface TableData {
columns: readonly TableColumn[]; columns: readonly TableColumn[];
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import { Checkbox } from '@toeverything/components/ui'; import { Checkbox } from '@toeverything/components/ui';
import type { BooleanColumnValue } from '@toeverything/datasource/db-service'; import type { BooleanColumnValue } from '@toeverything/datasource/db-service';
import type { CellProps } from '../types'; import type { CellProps } from '../types';
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import { ColumnType } from '@toeverything/datasource/db-service'; import { ColumnType } from '@toeverything/datasource/db-service';
import type { CustomCellProps as TableCustomCellProps } from '../basic-table'; import type { CustomCellProps as TableCustomCellProps } from '../basic-table';
import { DEFAULT_RENDER_CELL } from '../basic-table'; import { DEFAULT_RENDER_CELL } from '../basic-table';
@@ -16,7 +15,7 @@ const DefaultCell = ({ onChange, ...props }: CellProps) => {
/** /**
* @deprecated * @deprecated
*/ */
const cellMap: Record<ColumnType, FC<CellProps<any>>> = { const cellMap: Record<ColumnType, (prop: CellProps<any>) => JSX.Element> = {
[ColumnType.content]: DefaultCell, [ColumnType.content]: DefaultCell,
[ColumnType.number]: DefaultCell, [ColumnType.number]: DefaultCell,
[ColumnType.enum]: SelectCell, [ColumnType.enum]: SelectCell,
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import { useMemo } from 'react'; import { useMemo } from 'react';
import { OldSelect } from '@toeverything/components/ui'; import { OldSelect } from '@toeverything/components/ui';
import type { EnumColumnValue } from '@toeverything/datasource/db-service'; import type { EnumColumnValue } from '@toeverything/datasource/db-service';
@@ -1,4 +1,4 @@
import type { FC, ReactNode } from 'react'; import type { ReactNode } from 'react';
import { BasicTable } from './basic-table'; import { BasicTable } from './basic-table';
import type { BasicTableProps } from './basic-table'; import type { BasicTableProps } from './basic-table';
@@ -1,5 +1,4 @@
import { import {
FC,
useRef, useRef,
ChangeEvent, ChangeEvent,
ReactElement, ReactElement,
@@ -1,4 +1,4 @@
import type { FC, PropsWithChildren } from 'react'; import type { PropsWithChildren } from 'react';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import type { AsyncBlock } from '../editor'; import type { AsyncBlock } from '../editor';
import { PendantPopover } from './pendant-popover'; import { PendantPopover } from './pendant-popover';
@@ -1,4 +1,4 @@
import { FC, useRef } from 'react'; import { useRef } from 'react';
import { AsyncBlock } from '../../editor'; import { AsyncBlock } from '../../editor';
import { PendantHistoryPanel } from '../pendant-history-panel'; import { PendantHistoryPanel } from '../pendant-history-panel';
import { import {
@@ -4,7 +4,6 @@ import {
SelectOption, SelectOption,
SelectOptionId, SelectOptionId,
} from '../recast-block'; } from '../recast-block';
import { FunctionComponent } from 'react';
import { TextFontIcon } from '@toeverything/components/icons'; import { TextFontIcon } from '@toeverything/components/icons';
export { PropertyType as PendantTypes } from '../recast-block'; export { PropertyType as PendantTypes } from '../recast-block';
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import type { AsyncBlock } from '../editor'; import type { AsyncBlock } from '../editor';
import { RenderBlock } from './RenderBlock'; import { RenderBlock } from './RenderBlock';
@@ -1,4 +1,4 @@
import { useCallback, type FC, type MouseEvent } from 'react'; import { useCallback, type MouseEvent } from 'react';
import { import {
styled, styled,
Tooltip, Tooltip,
@@ -83,7 +83,7 @@ export const AddCommentActions = ({
}; };
type IconButtonWithTooltipProps = { type IconButtonWithTooltipProps = {
icon: FC<SvgIconProps>; icon: (prop: SvgIconProps) => JSX.Element;
tooltip?: string; tooltip?: string;
}; };
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import { import {
HeadingOneIcon, HeadingOneIcon,
HeadingTwoIcon, HeadingTwoIcon,
@@ -40,7 +39,7 @@ type ClickItemHandler = (
export type CommandMenuDataType = { export type CommandMenuDataType = {
type: BlockFlavorKeys; type: BlockFlavorKeys;
text: string; text: string;
icon: FC<SvgIconProps>; icon: (prop: SvgIconProps) => JSX.Element;
}; };
export const commonCommandMenuHandler: ClickItemHandler = async ( export const commonCommandMenuHandler: ClickItemHandler = async (
@@ -135,7 +135,9 @@ export const MenuDropdownItem = ({
); );
}; };
const withStylesForIcon = (FontIconComponent: React.FC<SvgIconProps>) => const withStylesForIcon = (
FontIconComponent: (prop: SvgIconProps) => JSX.Element
) =>
styled(FontIconComponent, { styled(FontIconComponent, {
shouldForwardProp: (prop: string) => shouldForwardProp: (prop: string) =>
!['fontColor', 'fontBgColor'].includes(prop), !['fontColor', 'fontBgColor'].includes(prop),
@@ -1,4 +1,3 @@
import React, { type FC } from 'react';
import type { SvgIconProps } from '@toeverything/components/ui'; import type { SvgIconProps } from '@toeverything/components/ui';
import type { Virgo, SelectionInfo } from '@toeverything/framework/virgo'; import type { Virgo, SelectionInfo } from '@toeverything/framework/virgo';
import { inlineMenuNames, INLINE_MENU_UI_TYPES } from './config'; import { inlineMenuNames, INLINE_MENU_UI_TYPES } from './config';
@@ -23,7 +22,7 @@ export type ClickItemHandler = ({
export type IconItemType = { export type IconItemType = {
type: typeof INLINE_MENU_UI_TYPES['icon']; type: typeof INLINE_MENU_UI_TYPES['icon'];
icon: FC<SvgIconProps>; icon: (prop: SvgIconProps) => JSX.Element;
nameKey: InlineMenuNamesType; nameKey: InlineMenuNamesType;
name: typeof inlineMenuNames[InlineMenuNamesType]; name: typeof inlineMenuNames[InlineMenuNamesType];
onClick?: ClickItemHandler; onClick?: ClickItemHandler;
@@ -32,7 +31,7 @@ export type IconItemType = {
export type DropdownItemType = { export type DropdownItemType = {
type: typeof INLINE_MENU_UI_TYPES['dropdown']; type: typeof INLINE_MENU_UI_TYPES['dropdown'];
icon: FC<SvgIconProps>; icon: (prop: SvgIconProps) => JSX.Element;
nameKey: InlineMenuNamesType; nameKey: InlineMenuNamesType;
name: typeof inlineMenuNames[InlineMenuNamesType]; name: typeof inlineMenuNames[InlineMenuNamesType];
children: IconItemType[]; children: IconItemType[];
@@ -1,7 +1,6 @@
import { import {
useState, useState,
useEffect, useEffect,
FC,
type MouseEvent, type MouseEvent,
type DragEvent, type DragEvent,
type ReactNode, type ReactNode,
@@ -1,4 +1,4 @@
export const timestamp = 1660239514133; export const timestamp = 1660270988401;
export * from './image/image'; export * from './image/image';
export * from './format-clear/format-clear'; export * from './format-clear/format-clear';
export * from './backward-undo/backward-undo'; export * from './backward-undo/backward-undo';
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import type { DocMode } from './type'; import type { DocMode } from './type';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import { StatusIcon } from './StatusIcon'; import { StatusIcon } from './StatusIcon';
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import { styled } from '@toeverything/components/ui'; import { styled } from '@toeverything/components/ui';
import { LastModified } from './LastModified'; import { LastModified } from './LastModified';
import { Logout } from './Logout'; import { Logout } from './Logout';
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import format from 'date-fns/format'; import format from 'date-fns/format';
import { Typography, styled } from '@toeverything/components/ui'; import { Typography, styled } from '@toeverything/components/ui';
import { useUserAndSpaces } from '@toeverything/datasource/state'; import { useUserAndSpaces } from '@toeverything/datasource/state';
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import { MoveToIcon } from '@toeverything/components/icons'; import { MoveToIcon } from '@toeverything/components/icons';
import { import {
ListItem, ListItem,
@@ -1,5 +1,4 @@
import type { import type {
FC,
MouseEventHandler, MouseEventHandler,
CSSProperties, CSSProperties,
PropsWithChildren, PropsWithChildren,
+1 -1
View File
@@ -41,7 +41,7 @@ type ListButtonProps = {
content?: string; content?: string;
children?: () => JSX.Element; children?: () => JSX.Element;
hover?: boolean; hover?: boolean;
icon?: React.FC<SvgIconProps>; icon?: (prop: SvgIconProps) => JSX.Element;
}; };
export const ListButton = (props: ListButtonProps) => { export const ListButton = (props: ListButtonProps) => {
+1 -1
View File
@@ -1,4 +1,4 @@
import type { FC, ReactNode, CSSProperties } from 'react'; import type { ReactNode, CSSProperties } from 'react';
import { styled } from '../styled'; import { styled } from '../styled';
import { MuiDivider } from '../mui'; import { MuiDivider } from '../mui';
import type { MuiDividerProps } from '../mui'; import type { MuiDividerProps } from '../mui';
+1 -1
View File
@@ -1,4 +1,4 @@
import type { FC, PropsWithChildren, CSSProperties } from 'react'; import type { PropsWithChildren, CSSProperties } from 'react';
import { Clickable } from '../clickable'; import { Clickable } from '../clickable';
import { styled } from '../styled'; import { styled } from '../styled';
+1 -1
View File
@@ -1,6 +1,6 @@
import { useCallback } from 'react'; import { useCallback } from 'react';
import { styled } from '../styled'; import { styled } from '../styled';
import type { FC, CSSProperties, ChangeEvent } from 'react'; import type { CSSProperties, ChangeEvent } from 'react';
/** /**
* WARNING: This component is about to be deprecated, use Select replace * WARNING: This component is about to be deprecated, use Select replace
-1
View File
@@ -1,4 +1,3 @@
import type { FC } from 'react';
import { SliderUnstyled, sliderUnstyledClasses } from '@mui/base'; import { SliderUnstyled, sliderUnstyledClasses } from '@mui/base';
import type { SliderUnstyledProps } from '@mui/base'; import type { SliderUnstyledProps } from '@mui/base';
import { alpha } from '@mui/system'; import { alpha } from '@mui/system';
-1
View File
@@ -1,5 +1,4 @@
import type { import type {
FC,
ChangeEventHandler, ChangeEventHandler,
PropsWithChildren, PropsWithChildren,
CSSProperties, CSSProperties,
+3 -3
View File
@@ -1,4 +1,4 @@
import type { FC, PropsWithChildren, ReactNode } from 'react'; import type { PropsWithChildren, ReactNode } from 'react';
// eslint-disable-next-line no-restricted-imports // eslint-disable-next-line no-restricted-imports
import { import {
createTheme, createTheme,
@@ -30,8 +30,8 @@ export const ThemeProvider = ({ children }: { children?: ReactNode }) => {
export const useTheme = () => muiUseTheme(); export const useTheme = () => muiUseTheme();
export const withTheme = <T,>( export const withTheme = <T,>(
Component: FC<T & { theme: MuiTheme }> Component: (prop: T & { theme: MuiTheme }) => JSX.Element
): FC<T> => { ): ((prop: T) => JSX.Element) => {
return props => { return props => {
const theme = useTheme(); const theme = useTheme();
return <Component {...props} theme={theme} />; return <Component {...props} theme={theme} />;
+2 -5
View File
@@ -24,10 +24,7 @@ interface ErrorBoundaryPropsWithComponent {
declare function FallbackRender( declare function FallbackRender(
props: FallbackProps props: FallbackProps
): React.ReactElement< ): React.ReactElement<unknown, string | typeof React.Component> | null;
unknown,
string | React.FunctionComponent | typeof React.Component
> | null;
interface ErrorBoundaryPropsWithRender { interface ErrorBoundaryPropsWithRender {
onResetKeysChange?: ( onResetKeysChange?: (
@@ -52,7 +49,7 @@ interface ErrorBoundaryPropsWithFallback {
resetKeys?: Array<unknown>; resetKeys?: Array<unknown>;
fallback: React.ReactElement< fallback: React.ReactElement<
unknown, unknown,
string | React.FunctionComponent | typeof React.Component string | typeof React.Component
> | null; > | null;
FallbackComponent?: never; FallbackComponent?: never;
fallbackRender?: never; fallbackRender?: never;
+1 -2
View File
@@ -84,9 +84,8 @@ async function getJSXContent(name, svgCode) {
} }
let matcher = svgrContent.match(/<svg ([^\>]+)>([\s\S]*?)<\/svg>/); let matcher = svgrContent.match(/<svg ([^\>]+)>([\s\S]*?)<\/svg>/);
return ` return `
import { FC } from 'react';
import { SvgIcon, SvgIconProps } from '@mui/material'; import { SvgIcon, SvgIconProps } from '@mui/material';
export const ${name}Icon: FC<SvgIconProps> = (props) => ( export const ${name}Icon = (props: SvgIconProps) => (
<SvgIcon ${matcher[1]}> <SvgIcon ${matcher[1]}>
${matcher[2]} ${matcher[2]}
</SvgIcon> </SvgIcon>