mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-19 14:09:31 +02:00
feat: minify json
This commit is contained in:
@@ -17,7 +17,7 @@ interface ToolContentPropsBase<T, I> extends ToolComponentProps {
|
||||
|
||||
// Tool options
|
||||
initialValues: T;
|
||||
getGroups: GetGroupsType<T>;
|
||||
getGroups: GetGroupsType<T> | null;
|
||||
|
||||
// Computation function
|
||||
compute: (optionsValues: T, input: I) => void;
|
||||
|
@@ -18,7 +18,7 @@ export interface ExampleCardProps<T> {
|
||||
sampleResult: string;
|
||||
sampleOptions: T;
|
||||
changeInputResult: (newInput: string, newOptions: T) => void;
|
||||
getGroups: GetGroupsType<T>;
|
||||
getGroups: GetGroupsType<T> | null;
|
||||
}
|
||||
|
||||
export default function ExampleCard<T>({
|
||||
|
@@ -7,12 +7,12 @@ export default function ExampleOptions<T>({
|
||||
getGroups
|
||||
}: {
|
||||
options: T;
|
||||
getGroups: GetGroupsType<T>;
|
||||
getGroups: GetGroupsType<T> | null;
|
||||
}) {
|
||||
return (
|
||||
<ToolOptionGroups
|
||||
// @ts-ignore
|
||||
groups={getGroups({ values: options })}
|
||||
groups={getGroups?.({ values: options }) ?? []}
|
||||
vertical
|
||||
/>
|
||||
);
|
||||
|
@@ -13,7 +13,7 @@ export interface ExampleProps<T> {
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
exampleCards: CardExampleType<T>[];
|
||||
getGroups: GetGroupsType<T>;
|
||||
getGroups: GetGroupsType<T> | null;
|
||||
formRef: React.RefObject<FormikProps<T>>;
|
||||
setInput: React.Dispatch<React.SetStateAction<any>>;
|
||||
}
|
||||
|
@@ -86,44 +86,45 @@ export default function ToolOptions<T extends FormikValues>({
|
||||
validationSchema?: any | (() => any);
|
||||
compute: (optionsValues: T, input: any) => void;
|
||||
input?: any;
|
||||
getGroups: GetGroupsType<T>;
|
||||
getGroups: GetGroupsType<T> | null;
|
||||
formRef?: RefObject<FormikProps<T>>;
|
||||
}) {
|
||||
const theme = useTheme();
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
mb: 2,
|
||||
borderRadius: 2,
|
||||
padding: 2,
|
||||
backgroundColor: theme.palette.background.default,
|
||||
boxShadow: '2'
|
||||
}}
|
||||
mt={2}
|
||||
>
|
||||
<Stack direction={'row'} spacing={1} alignItems={'center'}>
|
||||
<SettingsIcon />
|
||||
<Typography fontSize={22}>Tool options</Typography>
|
||||
</Stack>
|
||||
<Box mt={2}>
|
||||
<Formik
|
||||
innerRef={formRef}
|
||||
initialValues={initialValues}
|
||||
validationSchema={validationSchema}
|
||||
onSubmit={() => {}}
|
||||
>
|
||||
{(formikProps) => (
|
||||
<ToolBody
|
||||
compute={compute}
|
||||
input={input}
|
||||
getGroups={getGroups}
|
||||
formikProps={formikProps}
|
||||
>
|
||||
{children}
|
||||
</ToolBody>
|
||||
)}
|
||||
</Formik>
|
||||
if (getGroups)
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
mb: 2,
|
||||
borderRadius: 2,
|
||||
padding: 2,
|
||||
backgroundColor: theme.palette.background.default,
|
||||
boxShadow: '2'
|
||||
}}
|
||||
mt={2}
|
||||
>
|
||||
<Stack direction={'row'} spacing={1} alignItems={'center'}>
|
||||
<SettingsIcon />
|
||||
<Typography fontSize={22}>Tool options</Typography>
|
||||
</Stack>
|
||||
<Box mt={2}>
|
||||
<Formik
|
||||
innerRef={formRef}
|
||||
initialValues={initialValues}
|
||||
validationSchema={validationSchema}
|
||||
onSubmit={() => {}}
|
||||
>
|
||||
{(formikProps) => (
|
||||
<ToolBody
|
||||
compute={compute}
|
||||
input={input}
|
||||
getGroups={getGroups}
|
||||
formikProps={formikProps}
|
||||
>
|
||||
{children}
|
||||
</ToolBody>
|
||||
)}
|
||||
</Formik>
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
);
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user