diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 57c0481..9d2dab7 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,11 +4,13 @@
-
+
-
-
+
+
+
+
@@ -45,44 +47,44 @@
- {
+ "keyToString": {
+ "ASKED_ADD_EXTERNAL_FILES": "true",
+ "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
+ "Playwright.JoinText Component.executor": "Run",
+ "Playwright.JoinText Component.should merge text pieces with specified join character.executor": "Run",
+ "RunOnceActivity.OpenProjectViewOnStart": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "Vitest.compute function (1).executor": "Run",
+ "Vitest.compute function.executor": "Run",
+ "Vitest.mergeText.executor": "Run",
+ "Vitest.mergeText.should merge lines and preserve blank lines when deleteBlankLines is false.executor": "Run",
+ "Vitest.mergeText.should merge lines, preserve blank lines and trailing spaces when both deleteBlankLines and deleteTrailingSpaces are false.executor": "Run",
+ "git-widget-placeholder": "main",
+ "ignore.virus.scanning.warn.message": "true",
+ "kotlin-language-version-configured": "true",
+ "last_opened_file_path": "C:/Users/HP/IdeaProjects/omni-tools/src/components/options",
+ "node.js.detected.package.eslint": "true",
+ "node.js.detected.package.tslint": "true",
+ "node.js.selected.package.eslint": "(autodetect)",
+ "node.js.selected.package.tslint": "(autodetect)",
+ "nodejs_package_manager_path": "npm",
+ "npm.dev.executor": "Run",
+ "npm.lint.executor": "Run",
+ "npm.prebuild.executor": "Run",
+ "npm.script:create:tool.executor": "Run",
+ "npm.test.executor": "Run",
+ "npm.test:e2e.executor": "Run",
+ "npm.test:e2e:run.executor": "Run",
+ "prettierjs.PrettierConfiguration.Package": "C:\\Users\\HP\\IdeaProjects\\omni-tools\\node_modules\\prettier",
+ "project.structure.last.edited": "Problems",
+ "project.structure.proportion": "0.0",
+ "project.structure.side.proportion": "0.2",
+ "settings.editor.selected.configurable": "settings.typescriptcompiler",
+ "ts.external.directory.path": "C:\\Users\\HP\\IdeaProjects\\omni-tools\\node_modules\\typescript\\lib",
+ "vue.rearranger.settings.migration": "true"
}
-}]]>
+}
@@ -641,7 +644,6 @@
-
@@ -666,7 +668,8 @@
-
+
+
diff --git a/src/components/options/SelectWithDesc.tsx b/src/components/options/SelectWithDesc.tsx
index 1b219fe..f0a5a23 100644
--- a/src/components/options/SelectWithDesc.tsx
+++ b/src/components/options/SelectWithDesc.tsx
@@ -24,7 +24,11 @@ const SelectWithDesc = ({
description: string;
}) => {
const handleChange = (event: SelectChangeEvent) => {
- onChange(event.target.value as T);
+ const newValue =
+ typeof selected === 'boolean'
+ ? event.target.value === 'true'
+ : event.target.value;
+ onChange(newValue as T);
};
return (
diff --git a/src/components/result/ToolTextResult.tsx b/src/components/result/ToolTextResult.tsx
index 2a5e596..9baf4cc 100644
--- a/src/components/result/ToolTextResult.tsx
+++ b/src/components/result/ToolTextResult.tsx
@@ -1,8 +1,9 @@
import { Box, TextField } from '@mui/material';
-import React, { useContext } from 'react';
+import React, { useContext, useEffect } from 'react';
import { CustomSnackBarContext } from '../../contexts/CustomSnackBarContext';
import InputHeader from '../InputHeader';
import ResultFooter from './ResultFooter';
+import { replaceSpecialCharacters } from '../../utils/string';
export default function ToolTextResult({
title = 'Result',
@@ -37,7 +38,7 @@ export default function ToolTextResult({
{
- it('should handle sorting alphabetically ignoring case', () => {
- const input = 'Apple,banana,apple,Orange,Banana,apple';
- const result = TopItemsList('symbol', 'alphabetic', 'count', ',', input, false, true, false);
- expect(result).toEqual(
- 'apple: 3\n' +
- 'banana: 2\n' +
- 'orange: 1'
- );
- });
+ it('should handle sorting alphabetically ignoring case', () => {
+ const input = 'Apple,banana,apple,Orange,Banana,apple';
+ const result = TopItemsList(
+ 'symbol',
+ 'alphabetic',
+ 'count',
+ ',',
+ input,
+ false,
+ true,
+ false
+ );
+ expect(result).toEqual('apple: 3\n' + 'banana: 2\n' + 'orange: 1');
+ });
- it('should handle sorting by count and not ignoring case', () => {
- const input = 'apple,banana,apple,orange,banana,apple,Banana';
- const result = TopItemsList('symbol', 'count', 'count', ',', input, false, false, false);
- expect(result).toEqual(
- 'apple: 3\n' +
- 'banana: 2\n' +
- 'orange: 1\n' +
- 'Banana: 1'
- );
- });
+ it('should handle sorting by count and not ignoring case', () => {
+ const input = 'apple,banana,apple,orange,banana,apple,Banana';
+ const result = TopItemsList(
+ 'symbol',
+ 'count',
+ 'count',
+ ',',
+ input,
+ false,
+ false,
+ false
+ );
+ expect(result).toEqual(
+ 'apple: 3\n' + 'banana: 2\n' + 'orange: 1\n' + 'Banana: 1'
+ );
+ });
- it('should handle regex split operator', () => {
- const input = 'apple123banana456apple789orange012banana345apple678';
- const result = TopItemsList('regex', 'count', 'count', '\\d+', input, false, false, false);
- expect(result).toEqual(
- 'apple: 3\n' +
- 'banana: 2\n' +
- 'orange: 1'
- );
- });
+ it('should handle regex split operator', () => {
+ const input = 'apple123banana456apple789orange012banana345apple678';
+ const result = TopItemsList(
+ 'regex',
+ 'count',
+ 'count',
+ '\\d+',
+ input,
+ false,
+ false,
+ false
+ );
+ expect(result).toEqual('apple: 3\n' + 'banana: 2\n' + 'orange: 1');
+ });
- it('should handle percentage display format', () => {
- const input = 'apple,banana,apple,orange,banana,apple';
- const result = TopItemsList('symbol', 'count', 'percentage', ',', input, false, false, false);
- expect(result).toEqual(
- 'apple: 3 (50.00%)\n' +
- 'banana: 2 (33.33%)\n' +
- 'orange: 1 (16.67%)'
- );
- });
+ it('should handle percentage display format', () => {
+ const input = 'apple,banana,apple,orange,banana,apple';
+ const result = TopItemsList(
+ 'symbol',
+ 'count',
+ 'percentage',
+ ',',
+ input,
+ false,
+ false,
+ false
+ );
+ expect(result).toEqual(
+ 'apple: 3 (50.00%)\n' + 'banana: 2 (33.33%)\n' + 'orange: 1 (16.67%)'
+ );
+ });
- it('should handle total display format', () => {
- const input = 'apple,banana,apple,orange,banana,apple';
- const result = TopItemsList('symbol', 'count', 'total', ',', input, false, false, false);
- expect(result).toEqual(
- 'apple: 3 (3 / 6)\n' +
- 'banana: 2 (2 / 6)\n' +
- 'orange: 1 (1 / 6)'
- );
- });
+ it('should handle total display format', () => {
+ const input = 'apple,banana,apple,orange,banana,apple';
+ const result = TopItemsList(
+ 'symbol',
+ 'count',
+ 'total',
+ ',',
+ input,
+ false,
+ false,
+ false
+ );
+ expect(result).toEqual(
+ 'apple: 3 (3 / 6)\n' + 'banana: 2 (2 / 6)\n' + 'orange: 1 (1 / 6)'
+ );
+ });
- it('should handle trimming and ignoring empty items', () => {
- const input = ' apple , banana , apple , orange , banana , apple ';
- const result = TopItemsList('symbol', 'count', 'count', ',', input, true, false, true);
- expect(result).toEqual(
- 'apple: 3\n' +
- 'banana: 2\n' +
- 'orange: 1'
- );
- });
-});
\ No newline at end of file
+ it('should handle trimming and ignoring empty items', () => {
+ const input = ' apple , banana , apple , orange , banana , apple ';
+ const result = TopItemsList(
+ 'symbol',
+ 'count',
+ 'count',
+ ',',
+ input,
+ true,
+ false,
+ true
+ );
+ expect(result).toEqual('apple: 3\n' + 'banana: 2\n' + 'orange: 1');
+ });
+});
diff --git a/src/pages/list/sort/index.tsx b/src/pages/list/sort/index.tsx
index d4d345a..0e5c063 100644
--- a/src/pages/list/sort/index.tsx
+++ b/src/pages/list/sort/index.tsx
@@ -124,7 +124,9 @@ export default function SplitText() {
{ label: 'Increasing order', value: true },
{ label: 'Decreasing order', value: false }
]}
- onChange={(value) => updateField('increasing', value)}
+ onChange={(value) => {
+ updateField('increasing', value);
+ }}
description={'Select a sorting order.'}
/>
{
+ return str
+ .replace(/\\n/g, '\n')
+ .replace(/\\t/g, '\t')
+ .replace(/\\r/g, '\r')
+ .replace(/\\b/g, '\b')
+ .replace(/\\f/g, '\f')
+ .replace(/\\v/g, '\v');
+};