mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-19 14:09:31 +02:00
feat: find unique ui
This commit is contained in:
30
.idea/workspace.xml
generated
30
.idea/workspace.xml
generated
@@ -4,8 +4,11 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="fix: misc">
|
||||
<list default="true" id="b30e2810-c4c1-4aad-b134-794e52cc1c7d" name="Changes" comment="fix: style">
|
||||
<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/find-unique.service.test.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/list/find-unique/find-unique.service.test.ts" 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/find-unique/service.ts" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/list/find-unique/service.ts" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -161,10 +164,10 @@
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="npm.dev" />
|
||||
<item itemvalue="npm.lint" />
|
||||
<item itemvalue="npm.test:e2e" />
|
||||
<item itemvalue="Playwright.JoinText Component.should merge text pieces with specified join character" />
|
||||
<item itemvalue="npm.test" />
|
||||
<item itemvalue="npm.lint" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
@@ -202,14 +205,7 @@
|
||||
<workItem from="1719496624579" duration="6148000" />
|
||||
<workItem from="1720542757452" duration="5355000" />
|
||||
<workItem from="1720557527691" duration="3245000" />
|
||||
</task>
|
||||
<task id="LOCAL-00042" summary="ci: fix">
|
||||
<option name="closed" value="true" />
|
||||
<created>1719186106818</created>
|
||||
<option name="number" value="00042" />
|
||||
<option name="presentableId" value="LOCAL-00042" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1719186106818</updated>
|
||||
<workItem from="1720564427492" duration="1153000" />
|
||||
</task>
|
||||
<task id="LOCAL-00043" summary="fix: create-tool.mjs">
|
||||
<option name="closed" value="true" />
|
||||
@@ -595,7 +591,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1720558690147</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="91" />
|
||||
<task id="LOCAL-00091" summary="fix: style">
|
||||
<option name="closed" value="true" />
|
||||
<created>1720564711406</created>
|
||||
<option name="number" value="00091" />
|
||||
<option name="presentableId" value="LOCAL-00091" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1720564711406</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="92" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -639,7 +643,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: ToolFileInput.tsx" />
|
||||
<MESSAGE value="fix: generate numbers" />
|
||||
<MESSAGE value="fix: merging branches" />
|
||||
<MESSAGE value="feat: make responsive" />
|
||||
@@ -664,7 +667,8 @@
|
||||
<MESSAGE value="feat: sort list" />
|
||||
<MESSAGE value="feat: find most popular ui" />
|
||||
<MESSAGE value="fix: misc" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="fix: misc" />
|
||||
<MESSAGE value="fix: style" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="fix: style" />
|
||||
</component>
|
||||
<component name="XSLT-Support.FileAssociations.UIState">
|
||||
<expand />
|
||||
|
@@ -1,11 +1,11 @@
|
||||
import { expect, describe, it } from 'vitest';
|
||||
|
||||
import { TopItemsList } from './service';
|
||||
import { findUniqueCompute } from './service';
|
||||
|
||||
describe('TopItemsList Function', () => {
|
||||
test('should return unique items ignoring case sensitivity', () => {
|
||||
const input = 'apple,banana,Apple,orange,Banana,apple';
|
||||
const result = TopItemsList(
|
||||
const result = findUniqueCompute(
|
||||
'symbol',
|
||||
',',
|
||||
'\n',
|
||||
@@ -20,7 +20,7 @@ describe('TopItemsList Function', () => {
|
||||
|
||||
test('should return unique items considering case sensitivity', () => {
|
||||
const input = 'apple,banana,Apple,orange,Banana,apple';
|
||||
const result = TopItemsList(
|
||||
const result = findUniqueCompute(
|
||||
'symbol',
|
||||
',',
|
||||
'\n',
|
||||
@@ -35,7 +35,7 @@ describe('TopItemsList Function', () => {
|
||||
|
||||
test('should return all unique items ignoring case sensitivity', () => {
|
||||
const input = 'apple,banana,Apple,orange,Banana,apple';
|
||||
const result = TopItemsList(
|
||||
const result = findUniqueCompute(
|
||||
'symbol',
|
||||
',',
|
||||
'\n',
|
||||
@@ -50,7 +50,7 @@ describe('TopItemsList Function', () => {
|
||||
|
||||
test('should return all unique items considering case sensitivity', () => {
|
||||
const input = 'apple,banana,Apple,orange,Banana,apple';
|
||||
const result = TopItemsList(
|
||||
const result = findUniqueCompute(
|
||||
'symbol',
|
||||
',',
|
||||
'\n',
|
||||
@@ -65,7 +65,7 @@ describe('TopItemsList Function', () => {
|
||||
|
||||
test('should handle empty items deletion', () => {
|
||||
const input = 'apple,,banana, ,orange';
|
||||
const result = TopItemsList(
|
||||
const result = findUniqueCompute(
|
||||
'symbol',
|
||||
',',
|
||||
'\n',
|
||||
@@ -80,7 +80,7 @@ describe('TopItemsList Function', () => {
|
||||
|
||||
test('should handle trimming items', () => {
|
||||
const input = ' apple , banana , orange ';
|
||||
const result = TopItemsList(
|
||||
const result = findUniqueCompute(
|
||||
'symbol',
|
||||
',',
|
||||
'\n',
|
||||
@@ -95,7 +95,7 @@ describe('TopItemsList Function', () => {
|
||||
|
||||
test('should handle regex split', () => {
|
||||
const input = 'apple banana orange';
|
||||
const result = TopItemsList(
|
||||
const result = findUniqueCompute(
|
||||
'regex',
|
||||
'\\s+',
|
||||
'\n',
|
||||
|
@@ -1,11 +1,156 @@
|
||||
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 { SplitOperatorType, findUniqueCompute } from './service';
|
||||
import ToolInputAndResult from '../../../components/ToolInputAndResult';
|
||||
import SimpleRadio from '../../../components/options/SimpleRadio';
|
||||
import TextFieldWithDesc from '../../../components/options/TextFieldWithDesc';
|
||||
import CheckboxWithDesc from '../../../components/options/CheckboxWithDesc';
|
||||
import SelectWithDesc from '../../../components/options/SelectWithDesc';
|
||||
|
||||
const initialValues = {
|
||||
splitOperatorType: 'symbol' as SplitOperatorType,
|
||||
splitSeparator: ',',
|
||||
joinSeparator: '\\n',
|
||||
deleteEmptyItems: true,
|
||||
caseSensitive: false,
|
||||
trimItems: true,
|
||||
absolutelyUnique: 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.'
|
||||
}
|
||||
];
|
||||
|
||||
const initialValues = {};
|
||||
const validationSchema = Yup.object({
|
||||
// splitSeparator: Yup.string().required('The separator is required')
|
||||
});
|
||||
export default function FindUnique() {
|
||||
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,
|
||||
deleteEmptyItems,
|
||||
trimItems,
|
||||
caseSensitive,
|
||||
absolutelyUnique
|
||||
} = optionsValues;
|
||||
|
||||
setResult(
|
||||
findUniqueCompute(
|
||||
splitOperatorType,
|
||||
splitSeparator,
|
||||
joinSeparator,
|
||||
input,
|
||||
deleteEmptyItems,
|
||||
trimItems,
|
||||
caseSensitive,
|
||||
absolutelyUnique
|
||||
)
|
||||
);
|
||||
};
|
||||
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={'Unique items'} value={result} />}
|
||||
/>
|
||||
<ToolOptions
|
||||
compute={compute}
|
||||
getGroups={({ values, updateField }) => [
|
||||
{
|
||||
title: 'Input List Delimiter',
|
||||
component: (
|
||||
<Box>
|
||||
{splitOperators.map(({ title, description, type }) => (
|
||||
<SimpleRadio
|
||||
key={type}
|
||||
onClick={() => updateField('splitOperatorType', type)}
|
||||
title={title}
|
||||
description={description}
|
||||
checked={values.splitOperatorType === type}
|
||||
/>
|
||||
))}
|
||||
<TextFieldWithDesc
|
||||
description={'Set a delimiting symbol or regular expression.'}
|
||||
value={values.splitSeparator}
|
||||
onOwnChange={(val) => updateField('splitSeparator', val)}
|
||||
/>
|
||||
</Box>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: 'Output List Delimiter',
|
||||
component: (
|
||||
<Box>
|
||||
<TextFieldWithDesc
|
||||
value={values.joinSeparator}
|
||||
onOwnChange={(value) => updateField('joinSeparator', value)}
|
||||
/>
|
||||
<CheckboxWithDesc
|
||||
title={'Trim top list items'}
|
||||
description={
|
||||
'Remove leading and trailing spaces before comparing items'
|
||||
}
|
||||
checked={values.trimItems}
|
||||
onChange={(value) => updateField('trimItems', value)}
|
||||
/>
|
||||
<CheckboxWithDesc
|
||||
title={'Skip empty items'}
|
||||
description={
|
||||
"Don't include the empty list items in the output."
|
||||
}
|
||||
checked={values.deleteEmptyItems}
|
||||
onChange={(value) => updateField('deleteEmptyItems', value)}
|
||||
/>
|
||||
</Box>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: 'Unique Item Options',
|
||||
component: (
|
||||
<Box>
|
||||
<CheckboxWithDesc
|
||||
title={'Find Absolutely Unique Items'}
|
||||
description={
|
||||
'Display only those items of the list that exist in a single copy.'
|
||||
}
|
||||
checked={values.absolutelyUnique}
|
||||
onChange={(value) => updateField('absolutelyUnique', value)}
|
||||
/>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
]}
|
||||
initialValues={initialValues}
|
||||
input={input}
|
||||
validationSchema={validationSchema}
|
||||
/>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ function uniqueListBuilder(
|
||||
return Object.keys(dict);
|
||||
}
|
||||
|
||||
export function TopItemsList(
|
||||
export function findUniqueCompute(
|
||||
splitOperatorType: SplitOperatorType,
|
||||
splitSeparator: string,
|
||||
joinSeparator: string = '\n',
|
||||
|
Reference in New Issue
Block a user