diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 322cfcc..e6db41c 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,8 +4,11 @@
-
+
+
+
+
@@ -161,10 +164,10 @@
+
-
@@ -202,14 +205,7 @@
-
-
-
- 1719186106818
-
-
-
- 1719186106818
+
@@ -595,7 +591,15 @@
1720558690147
-
+
+
+ 1720564711406
+
+
+
+ 1720564711406
+
+
@@ -639,7 +643,6 @@
-
@@ -664,7 +667,8 @@
-
+
+
diff --git a/src/pages/list/find-unique/find-unique.service.test.ts b/src/pages/list/find-unique/find-unique.service.test.ts
index 192387e..769335f 100644
--- a/src/pages/list/find-unique/find-unique.service.test.ts
+++ b/src/pages/list/find-unique/find-unique.service.test.ts
@@ -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',
diff --git a/src/pages/list/find-unique/index.tsx b/src/pages/list/find-unique/index.tsx
index 12c1977..225e08f 100644
--- a/src/pages/list/find-unique/index.tsx
+++ b/src/pages/list/find-unique/index.tsx
@@ -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 Lorem ipsum;
+ const [input, setInput] = useState('');
+ const [result, setResult] = useState('');
+ 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 (
+
+
+ }
+ result={}
+ />
+ [
+ {
+ title: 'Input List Delimiter',
+ component: (
+
+ {splitOperators.map(({ title, description, type }) => (
+ updateField('splitOperatorType', type)}
+ title={title}
+ description={description}
+ checked={values.splitOperatorType === type}
+ />
+ ))}
+ updateField('splitSeparator', val)}
+ />
+
+ )
+ },
+ {
+ title: 'Output List Delimiter',
+ component: (
+
+ updateField('joinSeparator', value)}
+ />
+ updateField('trimItems', value)}
+ />
+ updateField('deleteEmptyItems', value)}
+ />
+
+ )
+ },
+ {
+ title: 'Unique Item Options',
+ component: (
+
+ updateField('absolutelyUnique', value)}
+ />
+
+ )
+ }
+ ]}
+ initialValues={initialValues}
+ input={input}
+ validationSchema={validationSchema}
+ />
+
+ );
}
diff --git a/src/pages/list/find-unique/service.ts b/src/pages/list/find-unique/service.ts
index af62371..99a6e96 100644
--- a/src/pages/list/find-unique/service.ts
+++ b/src/pages/list/find-unique/service.ts
@@ -21,7 +21,7 @@ function uniqueListBuilder(
return Object.keys(dict);
}
-export function TopItemsList(
+export function findUniqueCompute(
splitOperatorType: SplitOperatorType,
splitSeparator: string,
joinSeparator: string = '\n',