-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
180 additions
and
79 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
import { tool as listSort } from './sort/meta'; | ||
export const listTools = []; | ||
|
||
export const listTools = [listSort]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,107 @@ | ||
import { Box } from '@mui/material'; | ||
import React from 'react'; | ||
import React, { useState } from 'react'; | ||
import ToolTextInput from '../../../components/input/ToolTextInput'; | ||
import ToolTextResult from '../../../components/result/ToolTextResult'; | ||
import * as Yup from 'yup'; | ||
import ToolOptions from '../../../components/options/ToolOptions'; | ||
import { Sort, SortingMethod, SplitOperatorType } from './service'; | ||
import ToolInputAndResult from '../../../components/ToolInputAndResult'; | ||
import SimpleRadio from '../../../components/options/SimpleRadio'; | ||
|
||
const initialValues = {}; | ||
const validationSchema = Yup.object({ | ||
// splitSeparator: Yup.string().required('The separator is required') | ||
}); | ||
export default function Sort() { | ||
return <Box>Lorem ipsum</Box>; | ||
const initialValues = { | ||
splitSeparatorType: 'symbol' as SplitOperatorType, | ||
sortingMethod: 'alphabetic' as SortingMethod, | ||
increasing: true, | ||
splitSeparator: ',', | ||
joinSeparator: ',', | ||
removeDuplicated: false, | ||
caseSensitive: false | ||
}; | ||
const splitOperators: { | ||
title: string; | ||
description: string; | ||
type: SplitOperatorType; | ||
}[] = [ | ||
{ | ||
title: 'Use a Symbol for Splitting', | ||
description: 'Delimit input list items with a character.', | ||
type: 'symbol' | ||
}, | ||
{ | ||
title: 'Use a Regex for Splitting', | ||
type: 'regex', | ||
description: 'Delimit input list items with a regular expression.' | ||
} | ||
]; | ||
|
||
export default function SplitText() { | ||
const [input, setInput] = useState<string>(''); | ||
const [result, setResult] = useState<string>(''); | ||
// const formRef = useRef<FormikProps<typeof initialValues>>(null); | ||
const computeExternal = (optionsValues: typeof initialValues, input: any) => { | ||
const { | ||
splitSeparatorType, | ||
joinSeparator, | ||
splitSeparator, | ||
increasing, | ||
caseSensitive, | ||
removeDuplicated, | ||
sortingMethod | ||
} = optionsValues; | ||
|
||
setResult( | ||
Sort( | ||
sortingMethod, | ||
splitSeparatorType, | ||
input, | ||
increasing, | ||
splitSeparator, | ||
joinSeparator, | ||
removeDuplicated, | ||
caseSensitive | ||
) | ||
); | ||
}; | ||
const validationSchema = Yup.object({ | ||
// splitSeparator: Yup.string().required('The separator is required') | ||
}); | ||
|
||
return ( | ||
<Box> | ||
<ToolInputAndResult | ||
input={ | ||
<ToolTextInput | ||
title={'Input list'} | ||
value={input} | ||
onChange={setInput} | ||
/> | ||
} | ||
result={<ToolTextResult title={'Sorted list'} value={result} />} | ||
/> | ||
<ToolOptions | ||
compute={computeExternal} | ||
getGroups={({ values, setFieldValue, handleChange }) => [ | ||
{ | ||
title: 'Input item separator', | ||
component: splitOperators.map(({ title, description, type }) => ( | ||
<SimpleRadio | ||
key={type} | ||
onClick={() => setFieldValue('splitSeparatorType', type)} | ||
title={title} | ||
description={description} | ||
checked={values.splitSeparatorType === type} | ||
/> | ||
)) | ||
}, | ||
{ | ||
title: 'Sort method', | ||
component: <Box></Box> | ||
} | ||
]} | ||
initialValues={initialValues} | ||
input={input} | ||
validationSchema={validationSchema} | ||
/> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.