refactor: export and use components props

This commit is contained in:
rusconn
2022-04-06 20:28:17 +09:00
parent dfb6461eef
commit a06ea5bad9
29 changed files with 119 additions and 112 deletions

View File

@@ -1,7 +1,7 @@
import { css, Theme } from "@mui/material/styles"; import { css, Theme } from "@mui/material/styles";
import { config } from "ace-builds"; import { config } from "ace-builds";
import { ComponentPropsWithoutRef, memo } from "react"; import { memo } from "react";
import AceEditor from "react-ace"; import AceEditor, { IAceEditorProps } from "react-ace";
// https://github.com/securingsincity/react-ace/issues/725 // https://github.com/securingsincity/react-ace/issues/725
config.set("basePath", "https://cdn.jsdelivr.net/npm/ace-builds@1.4.14/src-min-noconflict/"); config.set("basePath", "https://cdn.jsdelivr.net/npm/ace-builds@1.4.14/src-min-noconflict/");
@@ -10,7 +10,7 @@ config.setModuleUrl(
"https://cdn.jsdelivr.net/npm/ace-builds@1.4.14/src-min-noconflict/worker-javascript.js" "https://cdn.jsdelivr.net/npm/ace-builds@1.4.14/src-min-noconflict/worker-javascript.js"
); );
type Props = ComponentPropsWithoutRef<typeof AceEditor>; export type Props = IAceEditorProps;
const editor = (theme: Theme) => css` const editor = (theme: Theme) => css`
box-shadow: ${theme.shadows[1]}; box-shadow: ${theme.shadows[1]};

View File

@@ -2,7 +2,7 @@ import { Box, Paper, Stack, Typography } from "@mui/material";
import { css, Theme } from "@mui/material/styles"; import { css, Theme } from "@mui/material/styles";
import { memo, ReactNode } from "react"; import { memo, ReactNode } from "react";
type Props = { export type Props = {
icon: ReactNode; icon: ReactNode;
title: string; title: string;
input: ReactNode; input: ReactNode;

View File

@@ -1,11 +1,11 @@
import { Stack } from "@mui/material"; import { Stack } from "@mui/material";
import equal from "fast-deep-equal"; import equal from "fast-deep-equal";
import { ComponentPropsWithoutRef, memo } from "react"; import { memo } from "react";
import Configuration from "./Configuration"; import Configuration, { Props as ConfigurationProps } from "./Configuration";
type Props = { export type Props = {
configurations: ComponentPropsWithoutRef<typeof Configuration>[]; configurations: ConfigurationProps[];
}; };
const StyledComponent = ({ configurations }: Props) => ( const StyledComponent = ({ configurations }: Props) => (

View File

@@ -1,12 +1,8 @@
import { Stack, Typography } from "@mui/material"; import { Stack, StackProps, Typography } from "@mui/material";
import { css, Theme } from "@mui/material/styles"; import { css, Theme } from "@mui/material/styles";
import { ComponentPropsWithoutRef, memo, PropsWithChildren } from "react"; import { memo, PropsWithChildren } from "react";
type Props = PropsWithChildren< export type Props = PropsWithChildren<{ title: string } & StackProps>;
{
title: string;
} & ComponentPropsWithoutRef<typeof Stack>
>;
const mainTitle = (theme: Theme) => css` const mainTitle = (theme: Theme) => css`
font-size: ${theme.typography.fontSize * 3}px; font-size: ${theme.typography.fontSize * 3}px;

View File

@@ -1,11 +1,7 @@
import { Box, Stack, Typography } from "@mui/material"; import { Box, Stack, StackProps, Typography } from "@mui/material";
import { ComponentPropsWithoutRef, memo, PropsWithChildren } from "react"; import { memo, PropsWithChildren } from "react";
type Props = PropsWithChildren< export type Props = PropsWithChildren<{ title: string } & StackProps>;
{
title: string;
} & ComponentPropsWithoutRef<typeof Stack>
>;
const StyledComponent = ({ children, title, ...stackProps }: Props) => ( const StyledComponent = ({ children, title, ...stackProps }: Props) => (
// eslint-disable-next-line react/jsx-props-no-spreading // eslint-disable-next-line react/jsx-props-no-spreading

View File

@@ -1,7 +1,7 @@
import { TextField } from "@mui/material"; import { TextField, TextFieldProps } from "@mui/material";
import { ComponentPropsWithoutRef, memo } from "react"; import { memo } from "react";
type Props = ComponentPropsWithoutRef<typeof TextField>; export type Props = TextFieldProps;
const StyledComponent = (props: Props) => ( const StyledComponent = (props: Props) => (
<TextField <TextField

View File

@@ -11,7 +11,7 @@ import { css, Theme } from "@mui/material/styles";
import NextLink, { LinkProps } from "next/link"; import NextLink, { LinkProps } from "next/link";
import { memo, ReactNode } from "react"; import { memo, ReactNode } from "react";
type Props = { export type Props = {
icon: ReactNode; icon: ReactNode;
title: string; title: string;
description: string; description: string;

View File

@@ -1,11 +1,11 @@
import { Grid } from "@mui/material"; import { Grid } from "@mui/material";
import equal from "fast-deep-equal"; import equal from "fast-deep-equal";
import { ComponentPropsWithoutRef, memo } from "react"; import { memo } from "react";
import ToolCard from "./ToolCard"; import ToolCard, { Props as ToolCardProps } from "./ToolCard";
type Props = { export type Props = {
tools: ComponentPropsWithoutRef<typeof ToolCard>[]; tools: ToolCardProps[];
}; };
const StyledComponent = ({ tools }: Props) => ( const StyledComponent = ({ tools }: Props) => (

View File

@@ -1,7 +1,17 @@
import Configurations from "./Configurations"; import { Props as CodeEditorProps } from "./CodeEditor";
import Main from "./Main"; import Configurations, { Props as ConfigurationsProps } from "./Configurations";
import MainItem from "./MainItem"; import Main, { Props as MainProps } from "./Main";
import TextField from "./TextField"; import MainItem, { Props as MainItemProps } from "./MainItem";
import ToolCardGrid from "./ToolCardGrid"; import TextField, { Props as TextFieldProps } from "./TextField";
import ToolCardGrid, { Props as ToolCardGridProps } from "./ToolCardGrid";
export type {
CodeEditorProps,
ConfigurationsProps,
MainProps,
MainItemProps,
TextFieldProps,
ToolCardGridProps,
};
export { Configurations, Main, MainItem, TextField, ToolCardGrid }; export { Configurations, Main, MainItem, TextField, ToolCardGrid };

View File

@@ -1,17 +1,17 @@
import { Home } from "@mui/icons-material"; import { Home } from "@mui/icons-material";
import { Box, Divider, Drawer, List, Stack } from "@mui/material"; import { Box, Divider, Drawer, List, Stack } from "@mui/material";
import { css } from "@mui/material/styles"; import { css } from "@mui/material/styles";
import { ComponentPropsWithoutRef, memo } from "react"; import { memo } from "react";
import { drawerToolGroups } from "@/data/tools"; import { drawerToolGroups } from "@/data/tools";
import { pagesPath } from "@/libs/$path"; import { pagesPath } from "@/libs/$path";
import DrawerCollapseItem from "./DrawerCollapseItem"; import DrawerCollapseItem, { Props as DrawerCollapseItemProps } from "./DrawerCollapseItem";
import DrawerItem from "./DrawerItem"; import DrawerItem from "./DrawerItem";
import SearchBar from "./SearchBar"; import SearchBar from "./SearchBar";
type Props = { type Props = {
toolGroups: ComponentPropsWithoutRef<typeof DrawerCollapseItem>[]; toolGroups: DrawerCollapseItemProps[];
}; };
export const drawerWidth = 300; export const drawerWidth = 300;

View File

@@ -1,22 +1,22 @@
import { ExpandLess, ExpandMore } from "@mui/icons-material"; import { ExpandLess, ExpandMore } from "@mui/icons-material";
import { Collapse, List, ListItemButton, ListItemText } from "@mui/material"; import { Collapse, List, ListItemButton, ListItemText } from "@mui/material";
import equal from "fast-deep-equal"; import equal from "fast-deep-equal";
import { ComponentPropsWithoutRef, memo, MouseEventHandler, useCallback, useState } from "react"; import { memo, MouseEventHandler, useCallback, useState } from "react";
import DrawerItem from "./DrawerItem"; import DrawerItem, { Props as DrawerItemProps } from "./DrawerItem";
import DrawerItemIcon from "./DrawerItemIcon"; import DrawerItemIcon, { Props as DrawerItemIconProps } from "./DrawerItemIcon";
type ContainerProps = { export type Props = {
title: string; title: string;
tools: ComponentPropsWithoutRef<typeof DrawerItem>[]; tools: DrawerItemProps[];
} & ComponentPropsWithoutRef<typeof DrawerItemIcon>; } & DrawerItemIconProps;
type Props = { type ComponentProps = {
open: boolean; open: boolean;
onClick: MouseEventHandler<HTMLDivElement>; onClick: MouseEventHandler<HTMLDivElement>;
} & ContainerProps; } & Props;
const StyledComponent = ({ icon, title, tools, open, onClick }: Props) => ( const StyledComponent = ({ icon, title, tools, open, onClick }: ComponentProps) => (
<> <>
<ListItemButton {...{ onClick }}> <ListItemButton {...{ onClick }}>
<DrawerItemIcon {...{ icon }} /> <DrawerItemIcon {...{ icon }} />
@@ -42,7 +42,7 @@ const StyledComponent = ({ icon, title, tools, open, onClick }: Props) => (
export const Component = memo(StyledComponent, equal); export const Component = memo(StyledComponent, equal);
const Container = ({ icon, title, tools }: ContainerProps) => { const Container = ({ icon, title, tools }: Props) => {
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const onClick = useCallback(() => { const onClick = useCallback(() => {

View File

@@ -1,16 +1,16 @@
import { Box, ListItemButton, ListItemText, Tooltip } from "@mui/material"; import { Box, ListItemButton, ListItemText, Tooltip } from "@mui/material";
import { css } from "@mui/material/styles"; import { css } from "@mui/material/styles";
import NextLink, { LinkProps } from "next/link"; import NextLink, { LinkProps } from "next/link";
import { ComponentPropsWithoutRef, memo } from "react"; import { memo } from "react";
import DrawerItemIcon from "./DrawerItemIcon"; import DrawerItemIcon, { Props as DrawerItemIconProps } from "./DrawerItemIcon";
type Props = { export type Props = {
title: string; title: string;
disabled?: boolean; disabled?: boolean;
subItem?: true; subItem?: true;
} & Pick<LinkProps, "href"> & } & Pick<LinkProps, "href"> &
ComponentPropsWithoutRef<typeof DrawerItemIcon>; DrawerItemIconProps;
const indent = css` const indent = css`
text-indent: 40px; text-indent: 40px;

View File

@@ -2,7 +2,7 @@ import { ListItemIcon } from "@mui/material";
import { css } from "@mui/material/styles"; import { css } from "@mui/material/styles";
import { memo, ReactNode } from "react"; import { memo, ReactNode } from "react";
type Props = { export type Props = {
icon: ReactNode; icon: ReactNode;
}; };

View File

@@ -12,7 +12,7 @@ export const isSpaces = (x: number): x is Spaces => spacesArray.includes(x as Sp
type OnSelectChange<T> = NonNullable<SelectInputProps<T>["onChange"]>; type OnSelectChange<T> = NonNullable<SelectInputProps<T>["onChange"]>;
type Props = { export type Props = {
spaces: Spaces; spaces: Spaces;
onSpacesChange: OnSelectChange<Spaces>; onSpacesChange: OnSelectChange<Spaces>;
}; };

View File

@@ -1,11 +1,12 @@
import { Skeleton, Stack } from "@mui/material"; import { Skeleton, Stack } from "@mui/material";
import dynamic from "next/dynamic"; import dynamic from "next/dynamic";
import { ComponentPropsWithoutRef, memo, useCallback, useState } from "react"; import { memo, useCallback, useState } from "react";
import YAML from "yaml"; import YAML from "yaml";
import { Main, MainItem } from "@/components/common"; import { Main, MainItem } from "@/components/common";
import { Props as CodeEditorProps } from "@/components/common/CodeEditor";
import Configuration, { isSpaces, Spaces } from "./Configuration"; import Configuration, { Props as ConfigurationProps, isSpaces, Spaces } from "./Configuration";
// https://github.com/securingsincity/react-ace/issues/27 // https://github.com/securingsincity/react-ace/issues/27
const CodeEditor = dynamic( const CodeEditor = dynamic(
@@ -20,15 +21,15 @@ const CodeEditor = dynamic(
{ ssr: false, loading: () => <Skeleton variant="rectangular" height="100%" /> } { ssr: false, loading: () => <Skeleton variant="rectangular" height="100%" /> }
); );
type CodeValue = NonNullable<ComponentPropsWithoutRef<typeof CodeEditor>["value"]>; type CodeValue = NonNullable<CodeEditorProps["value"]>;
type OnCodeChange = NonNullable<ComponentPropsWithoutRef<typeof CodeEditor>["onChange"]>; type OnCodeChange = NonNullable<CodeEditorProps["onChange"]>;
type Props = { type Props = {
json: CodeValue; json: CodeValue;
yaml: CodeValue; yaml: CodeValue;
onJsonChange: OnCodeChange; onJsonChange: OnCodeChange;
onYamlChange: OnCodeChange; onYamlChange: OnCodeChange;
} & ComponentPropsWithoutRef<typeof Configuration>; } & ConfigurationProps;
const StyledComponent = ({ const StyledComponent = ({
json, json,

View File

@@ -8,7 +8,7 @@ import { Configurations } from "@/components/common";
type SwitchChecked = NonNullable<SwitchBaseProps["checked"]>; type SwitchChecked = NonNullable<SwitchBaseProps["checked"]>;
type OnSwitchChange = NonNullable<SwitchBaseProps["onChange"]>; type OnSwitchChange = NonNullable<SwitchBaseProps["onChange"]>;
type Props = { export type Props = {
format: SwitchChecked; format: SwitchChecked;
onFormatChange: OnSwitchChange; onFormatChange: OnSwitchChange;
}; };

View File

@@ -1,7 +1,7 @@
import { Stack } from "@mui/material"; import { Stack } from "@mui/material";
import { ComponentPropsWithoutRef, memo, useCallback, useState } from "react"; import { memo, useCallback, useState } from "react";
import { Main, MainItem, TextField } from "@/components/common"; import { Main, MainItem, TextField, TextFieldProps } from "@/components/common";
import { import {
formatBinary, formatBinary,
formatDecimal, formatDecimal,
@@ -17,10 +17,10 @@ import {
unformatOctal, unformatOctal,
} from "@/libs/string"; } from "@/libs/string";
import Configuration from "./Configuration"; import Configuration, { Props as ConfigurationProps } from "./Configuration";
type TextFieldValue = ComponentPropsWithoutRef<typeof TextField>["value"]; type TextFieldValue = TextFieldProps["value"];
type OnTextFieldChange = NonNullable<ComponentPropsWithoutRef<typeof TextField>["onChange"]>; type OnTextFieldChange = NonNullable<TextFieldProps["onChange"]>;
type Props = { type Props = {
dec: TextFieldValue; dec: TextFieldValue;
@@ -31,7 +31,7 @@ type Props = {
onHexChange: OnTextFieldChange; onHexChange: OnTextFieldChange;
onOctChange: OnTextFieldChange; onOctChange: OnTextFieldChange;
onBinChange: OnTextFieldChange; onBinChange: OnTextFieldChange;
} & ComponentPropsWithoutRef<typeof Configuration>; } & ConfigurationProps;
const StyledComponent = ({ const StyledComponent = ({
format, format,

View File

@@ -1,10 +1,10 @@
import { encode, decode, isValid } from "js-base64"; import { encode, decode, isValid } from "js-base64";
import { ComponentPropsWithoutRef, memo, useCallback, useState } from "react"; import { memo, useCallback, useState } from "react";
import { Main, MainItem, TextField } from "@/components/common"; import { Main, MainItem, TextField, TextFieldProps } from "@/components/common";
type TextFieldValue = ComponentPropsWithoutRef<typeof TextField>["value"]; type TextFieldValue = TextFieldProps["value"];
type OnTextFieldChange = NonNullable<ComponentPropsWithoutRef<typeof TextField>["onChange"]>; type OnTextFieldChange = NonNullable<TextFieldProps["onChange"]>;
type Props = { type Props = {
decoded: TextFieldValue; decoded: TextFieldValue;

View File

@@ -1,10 +1,10 @@
import { decode, encode } from "html-entities"; import { decode, encode } from "html-entities";
import { ComponentPropsWithoutRef, memo, useCallback, useState } from "react"; import { memo, useCallback, useState } from "react";
import { Main, MainItem, TextField } from "@/components/common"; import { Main, MainItem, TextField, TextFieldProps } from "@/components/common";
type TextFieldValue = ComponentPropsWithoutRef<typeof TextField>["value"]; type TextFieldValue = TextFieldProps["value"];
type OnTextFieldChange = NonNullable<ComponentPropsWithoutRef<typeof TextField>["onChange"]>; type OnTextFieldChange = NonNullable<TextFieldProps["onChange"]>;
type Props = { type Props = {
decoded: TextFieldValue; decoded: TextFieldValue;

View File

@@ -1,8 +1,8 @@
import { Skeleton } from "@mui/material"; import { Skeleton } from "@mui/material";
import dynamic from "next/dynamic"; import dynamic from "next/dynamic";
import { ComponentPropsWithoutRef, memo, useCallback, useState } from "react"; import { memo, useCallback, useState } from "react";
import { Main, MainItem, TextField } from "@/components/common"; import { CodeEditorProps, Main, MainItem, TextField, TextFieldProps } from "@/components/common";
import { decode } from "@/libs/jwt"; import { decode } from "@/libs/jwt";
// https://github.com/securingsincity/react-ace/issues/27 // https://github.com/securingsincity/react-ace/issues/27
@@ -15,9 +15,9 @@ const CodeEditor = dynamic(
{ ssr: false, loading: () => <Skeleton variant="rectangular" width="100%" height="160px" /> } { ssr: false, loading: () => <Skeleton variant="rectangular" width="100%" height="160px" /> }
); );
type TextFieldValue = ComponentPropsWithoutRef<typeof TextField>["value"]; type TextFieldValue = TextFieldProps["value"];
type CodeValue = NonNullable<ComponentPropsWithoutRef<typeof CodeEditor>["value"]>; type CodeValue = NonNullable<CodeEditorProps["value"]>;
type OnTextFieldChange = NonNullable<ComponentPropsWithoutRef<typeof TextField>["onChange"]>; type OnTextFieldChange = NonNullable<TextFieldProps["onChange"]>;
type Props = { type Props = {
jwt: TextFieldValue; jwt: TextFieldValue;

View File

@@ -1,9 +1,9 @@
import { ComponentPropsWithoutRef, memo, useCallback, useState } from "react"; import { memo, useCallback, useState } from "react";
import { Main, MainItem, TextField } from "@/components/common"; import { Main, MainItem, TextField, TextFieldProps } from "@/components/common";
type TextFieldValue = ComponentPropsWithoutRef<typeof TextField>["value"]; type TextFieldValue = TextFieldProps["value"];
type OnTextFieldChange = NonNullable<ComponentPropsWithoutRef<typeof TextField>["onChange"]>; type OnTextFieldChange = NonNullable<TextFieldProps["onChange"]>;
type Props = { type Props = {
decoded: TextFieldValue; decoded: TextFieldValue;

View File

@@ -12,7 +12,7 @@ export const isSpaces = (x: number): x is Spaces => spacesArray.includes(x as Sp
type OnSelectChange<T> = NonNullable<SelectInputProps<T>["onChange"]>; type OnSelectChange<T> = NonNullable<SelectInputProps<T>["onChange"]>;
type Props = { export type Props = {
spaces: Spaces; spaces: Spaces;
onSpacesChange: OnSelectChange<Spaces>; onSpacesChange: OnSelectChange<Spaces>;
}; };

View File

@@ -1,10 +1,10 @@
import { Skeleton, Stack } from "@mui/material"; import { Skeleton, Stack } from "@mui/material";
import dynamic from "next/dynamic"; import dynamic from "next/dynamic";
import { ComponentPropsWithoutRef, memo, useCallback, useState } from "react"; import { memo, useCallback, useState } from "react";
import { Main, MainItem } from "@/components/common"; import { CodeEditorProps, Main, MainItem } from "@/components/common";
import Configuration, { isSpaces, Spaces } from "./Configuration"; import Configuration, { Props as ConfigurationProps, isSpaces, Spaces } from "./Configuration";
// https://github.com/securingsincity/react-ace/issues/27 // https://github.com/securingsincity/react-ace/issues/27
const CodeEditor = dynamic( const CodeEditor = dynamic(
@@ -16,14 +16,14 @@ const CodeEditor = dynamic(
{ ssr: false, loading: () => <Skeleton variant="rectangular" height="100%" /> } { ssr: false, loading: () => <Skeleton variant="rectangular" height="100%" /> }
); );
type CodeValue = NonNullable<ComponentPropsWithoutRef<typeof CodeEditor>["value"]>; type CodeValue = NonNullable<CodeEditorProps["value"]>;
type OnCodeChange = NonNullable<ComponentPropsWithoutRef<typeof CodeEditor>["onChange"]>; type OnCodeChange = NonNullable<CodeEditorProps["onChange"]>;
type Props = { type Props = {
json: CodeValue; json: CodeValue;
formatted: CodeValue; formatted: CodeValue;
onJsonChange: OnCodeChange; onJsonChange: OnCodeChange;
} & ComponentPropsWithoutRef<typeof Configuration>; } & ConfigurationProps;
const StyledComponent = ({ json, formatted, spaces, onJsonChange, onSpacesChange }: Props) => ( const StyledComponent = ({ json, formatted, spaces, onJsonChange, onSpacesChange }: Props) => (
<Main title="Json Formatter"> <Main title="Json Formatter">

View File

@@ -8,7 +8,7 @@ import { Configurations } from "@/components/common";
type SwitchChecked = NonNullable<SwitchBaseProps["checked"]>; type SwitchChecked = NonNullable<SwitchBaseProps["checked"]>;
type OnSwitchChange = NonNullable<SwitchBaseProps["onChange"]>; type OnSwitchChange = NonNullable<SwitchBaseProps["onChange"]>;
type Props = { export type Props = {
uppercase: SwitchChecked; uppercase: SwitchChecked;
onCaseChange: OnSwitchChange; onCaseChange: OnSwitchChange;
}; };

View File

@@ -1,13 +1,13 @@
import { Stack } from "@mui/material"; import { Stack } from "@mui/material";
import createHash from "create-hash"; // smaller bundle size than Node.js standard library import createHash from "create-hash"; // smaller bundle size than Node.js standard library
import { ComponentPropsWithoutRef, memo, useCallback, useState } from "react"; import { memo, useCallback, useState } from "react";
import { Main, MainItem, TextField } from "@/components/common"; import { Main, MainItem, TextField, TextFieldProps } from "@/components/common";
import Configuration from "./Configuration"; import Configuration, { Props as ConfigurationProps } from "./Configuration";
type TextFieldValue = ComponentPropsWithoutRef<typeof TextField>["value"]; type TextFieldValue = TextFieldProps["value"];
type OnTextFieldChange = NonNullable<ComponentPropsWithoutRef<typeof TextField>["onChange"]>; type OnTextFieldChange = NonNullable<TextFieldProps["onChange"]>;
type Props = { type Props = {
input: TextFieldValue; input: TextFieldValue;
@@ -16,7 +16,7 @@ type Props = {
sha256: TextFieldValue; sha256: TextFieldValue;
sha512: TextFieldValue; sha512: TextFieldValue;
onInputChange: OnTextFieldChange; onInputChange: OnTextFieldChange;
} & ComponentPropsWithoutRef<typeof Configuration>; } & ConfigurationProps;
const StyledComponent = ({ const StyledComponent = ({
uppercase, uppercase,

View File

@@ -16,7 +16,7 @@ type SwitchChecked = NonNullable<SwitchBaseProps["checked"]>;
type OnSwitchChange = NonNullable<SwitchBaseProps["onChange"]>; type OnSwitchChange = NonNullable<SwitchBaseProps["onChange"]>;
type OnSelectChange<T> = NonNullable<SelectInputProps<T>["onChange"]>; type OnSelectChange<T> = NonNullable<SelectInputProps<T>["onChange"]>;
type Props = { export type Props = {
hyphens: SwitchChecked; hyphens: SwitchChecked;
uppercase: SwitchChecked; uppercase: SwitchChecked;
uuidVersion: UuidVersion; uuidVersion: UuidVersion;

View File

@@ -1,22 +1,26 @@
import { Button, Stack, Typography } from "@mui/material"; import { Button, ButtonProps, Stack, Typography } from "@mui/material";
import { range } from "fp-ts/NonEmptyArray"; import { range } from "fp-ts/NonEmptyArray";
import { ComponentPropsWithoutRef, memo, useCallback, useState } from "react"; import { memo, useCallback, useState } from "react";
import { Main, MainItem, TextField } from "@/components/common"; import { Main, MainItem, TextField, TextFieldProps } from "@/components/common";
import { uuid } from "@/libs/uuid"; import { uuid } from "@/libs/uuid";
import Configuration, { isUuidVersion, UuidVersion } from "./Configuration"; import Configuration, {
Props as ConfigurationProps,
isUuidVersion,
UuidVersion,
} from "./Configuration";
type TextFieldValue = ComponentPropsWithoutRef<typeof TextField>["value"]; type TextFieldValue = TextFieldProps["value"];
type OnTextFieldChange = NonNullable<ComponentPropsWithoutRef<typeof TextField>["onChange"]>; type OnTextFieldChange = NonNullable<TextFieldProps["onChange"]>;
type OnButtonClick = NonNullable<ComponentPropsWithoutRef<typeof Button>["onChange"]>; type OnButtonClick = NonNullable<ButtonProps["onChange"]>;
type Props = { type Props = {
generates: TextFieldValue; generates: TextFieldValue;
uuids: TextFieldValue; uuids: TextFieldValue;
onGeneratesChange: OnTextFieldChange; onGeneratesChange: OnTextFieldChange;
onGenerateClick: OnButtonClick; onGenerateClick: OnButtonClick;
} & ComponentPropsWithoutRef<typeof Configuration>; } & ConfigurationProps;
const StyledComponent = ({ const StyledComponent = ({
hyphens, hyphens,

View File

@@ -1,9 +1,9 @@
import { ComponentPropsWithoutRef, memo } from "react"; import { memo } from "react";
import { Main, ToolCardGrid } from "@/components/common"; import { Main, ToolCardGrid, ToolCardGridProps } from "@/components/common";
import { homeTools } from "@/data/tools"; import { homeTools } from "@/data/tools";
type Props = ComponentPropsWithoutRef<typeof ToolCardGrid>; type Props = ToolCardGridProps;
const StyledComponent = ({ tools }: Props) => ( const StyledComponent = ({ tools }: Props) => (
<Main title="All tools" height="fit-content"> <Main title="All tools" height="fit-content">

View File

@@ -1,13 +1,13 @@
import equal from "fast-deep-equal"; import equal from "fast-deep-equal";
import Fuse from "fuse.js"; import Fuse from "fuse.js";
import { ComponentPropsWithoutRef, memo } from "react"; import { memo } from "react";
import { selector, useRecoilValue } from "recoil"; import { selector, useRecoilValue } from "recoil";
import { Main, ToolCardGrid } from "@/components/common"; import { Main, ToolCardGrid, ToolCardGridProps } from "@/components/common";
import { searchTextState } from "@/components/layout/states"; import { searchTextState } from "@/components/layout/states";
import { homeTools } from "@/data/tools"; import { homeTools } from "@/data/tools";
type Props = ComponentPropsWithoutRef<typeof ToolCardGrid>; type Props = ToolCardGridProps;
const StyledComponent = ({ tools }: Props) => ( const StyledComponent = ({ tools }: Props) => (
<Main title="Searched tools"> <Main title="Searched tools">