mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-19 05:59:34 +02:00
feat: reverse list ui
This commit is contained in:
30
.idea/workspace.xml
generated
30
.idea/workspace.xml
generated
@@ -4,10 +4,10 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="feat: find unique ui">
|
||||
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="feat: group list ui">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/pages/list/find-unique/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/list/find-unique/index.tsx" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/pages/list/group/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/list/group/index.tsx" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/pages/list/reverse/index.tsx" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/list/reverse/index.tsx" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/pages/list/reverse/service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/list/reverse/service.ts" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -206,15 +206,7 @@
|
||||
<workItem from="1720557527691" duration="3245000" />
|
||||
<workItem from="1720564427492" duration="1523000" />
|
||||
<workItem from="1720613598176" duration="8000" />
|
||||
<workItem from="1720655252208" duration="1526000" />
|
||||
</task>
|
||||
<task id="LOCAL-00044" summary="fix: readme">
|
||||
<option name="closed" value="true" />
|
||||
<created>1719187190823</created>
|
||||
<option name="number" value="00044" />
|
||||
<option name="presentableId" value="LOCAL-00044" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1719187190823</updated>
|
||||
<workItem from="1720655252208" duration="2568000" />
|
||||
</task>
|
||||
<task id="LOCAL-00045" summary="fix: create-tool.mjs">
|
||||
<option name="closed" value="true" />
|
||||
@@ -600,7 +592,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1720565760853</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="93" />
|
||||
<task id="LOCAL-00093" summary="feat: group list ui">
|
||||
<option name="closed" value="true" />
|
||||
<created>1720656867853</created>
|
||||
<option name="number" value="00093" />
|
||||
<option name="presentableId" value="LOCAL-00093" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1720656867853</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="94" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -644,7 +644,6 @@
|
||||
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="false" />
|
||||
<option name="CHECK_NEW_TODO" value="false" />
|
||||
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
|
||||
<MESSAGE value="fix: merging branches" />
|
||||
<MESSAGE value="feat: make responsive" />
|
||||
<MESSAGE value="feat: make tool responsive" />
|
||||
<MESSAGE value="chore: make tool examples responsive" />
|
||||
@@ -669,7 +668,8 @@
|
||||
<MESSAGE value="fix: misc" />
|
||||
<MESSAGE value="fix: style" />
|
||||
<MESSAGE value="feat: find unique ui" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="feat: find unique ui" />
|
||||
<MESSAGE value="feat: group list ui" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="feat: group list ui" />
|
||||
</component>
|
||||
<component name="XSLT-Support.FileAssociations.UIState">
|
||||
<expand />
|
||||
|
@@ -1,11 +1,110 @@
|
||||
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 { reverseList, SplitOperatorType } from './service';
|
||||
import ToolInputAndResult from '../../../components/ToolInputAndResult';
|
||||
import SimpleRadio from '../../../components/options/SimpleRadio';
|
||||
import TextFieldWithDesc from '../../../components/options/TextFieldWithDesc';
|
||||
|
||||
const initialValues = {
|
||||
splitOperatorType: 'symbol' as SplitOperatorType,
|
||||
splitSeparator: ',',
|
||||
joinSeparator: '\\n'
|
||||
};
|
||||
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.'
|
||||
}
|
||||
];
|
||||
|
||||
const initialValues = {};
|
||||
const validationSchema = Yup.object({
|
||||
// splitSeparator: Yup.string().required('The separator is required')
|
||||
});
|
||||
export default function Reverse() {
|
||||
return <Box>Lorem ipsum</Box>;
|
||||
const [input, setInput] = useState<string>('');
|
||||
const [result, setResult] = useState<string>('');
|
||||
const compute = (optionsValues: typeof initialValues, input: any) => {
|
||||
const { splitOperatorType, splitSeparator, joinSeparator } = optionsValues;
|
||||
|
||||
setResult(
|
||||
reverseList(splitOperatorType, splitSeparator, joinSeparator, input)
|
||||
);
|
||||
};
|
||||
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={'Reversed list'} value={result} />}
|
||||
/>
|
||||
<ToolOptions
|
||||
compute={compute}
|
||||
getGroups={({ values, updateField }) => [
|
||||
{
|
||||
title: 'Splitter Mode',
|
||||
component: (
|
||||
<Box>
|
||||
{splitOperators.map(({ title, description, type }) => (
|
||||
<SimpleRadio
|
||||
key={type}
|
||||
onClick={() => updateField('splitOperatorType', type)}
|
||||
title={title}
|
||||
description={description}
|
||||
checked={values.splitOperatorType === type}
|
||||
/>
|
||||
))}
|
||||
</Box>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: 'Item Separator',
|
||||
component: (
|
||||
<Box>
|
||||
<TextFieldWithDesc
|
||||
description={'Set a delimiting symbol or regular expression.'}
|
||||
value={values.splitSeparator}
|
||||
onOwnChange={(val) => updateField('splitSeparator', val)}
|
||||
/>
|
||||
</Box>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: 'Output List Options',
|
||||
component: (
|
||||
<Box>
|
||||
<TextFieldWithDesc
|
||||
description={'Output list item separator.'}
|
||||
value={values.joinSeparator}
|
||||
onOwnChange={(val) => updateField('joinSeparator', val)}
|
||||
/>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
]}
|
||||
initialValues={initialValues}
|
||||
input={input}
|
||||
validationSchema={validationSchema}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
type SplitOperatorType = 'symbol' | 'regex';
|
||||
export type SplitOperatorType = 'symbol' | 'regex';
|
||||
|
||||
export function reverseList(
|
||||
splitOperatorType: SplitOperatorType,
|
||||
|
Reference in New Issue
Block a user