pixel-react-excel-sheet 1.0.31 → 1.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/Accordion/Accordion.d.ts +1 -1
- package/lib/components/Accordion/types.d.ts +4 -0
- package/lib/components/AllProjectsDropdown/types.d.ts +2 -0
- package/lib/components/Button/Button.d.ts +2 -2
- package/lib/components/Button/types.d.ts +17 -0
- package/lib/components/Charts/DashboardDonutChart/types.d.ts +2 -0
- package/lib/components/Charts/MultiRadialChart/types.d.ts +3 -0
- package/lib/components/ChooseFile/ChooseFile.d.ts +3 -0
- package/lib/components/ChooseFile/types.d.ts +68 -0
- package/lib/components/ConditionalDropdown/ConditionalDropdown.d.ts +1 -2
- package/lib/components/ConditionalDropdown/types.d.ts +4 -4
- package/lib/components/ConnectingBranch/ConnectingBranch.d.ts +2 -1
- package/lib/components/ConnectingBranch/data.d.ts +19 -33
- package/lib/components/ConnectingBranch/types.d.ts +10 -0
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/actions.d.ts +7 -1
- package/lib/components/FileDropzone/types.d.ts +12 -4
- package/lib/components/LabelEditTextField/types.d.ts +3 -1
- package/lib/components/MachineInputField/MachineInputField.d.ts +4 -1
- package/lib/components/ScriptSwitchButton/ScriptSwitchButton.d.ts +9 -0
- package/lib/components/ScriptSwitchButton/index.d.ts +1 -0
- package/lib/components/Select/types.d.ts +1 -1
- package/lib/components/StatusCard/types.d.ts +2 -0
- package/lib/components/TableTree/Components/TableCell.d.ts +1 -1
- package/lib/components/TableTree/Components/TableRow.d.ts +1 -1
- package/lib/components/TableTree/data.d.ts +115 -1
- package/lib/components/TableTree/types.d.ts +4 -0
- package/lib/components/TextArea/Textarea.d.ts +1 -1
- package/lib/components/TextArea/Types.d.ts +1 -0
- package/lib/components/ThemeProvider/types.d.ts +1 -1
- package/lib/index.d.ts +250 -75
- package/lib/index.esm.js +863 -489
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +909 -488
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/validateFile/validateFile.d.ts +2 -0
- package/lib/validations/regex.d.ts +46 -0
- package/package.json +2 -2
- package/src/StyleGuide/ColorPalette/colorPaletteList.ts +5 -0
- package/src/assets/Themes/BaseTheme.scss +2 -1
- package/src/assets/Themes/BlueTheme.scss +279 -0
- package/src/assets/Themes/DarkTheme.scss +2 -1
- package/src/assets/Themes/Theme.scss +5 -0
- package/src/assets/icons/failed_status_icon.svg +1 -1
- package/src/assets/icons/flaky_status_icon.svg +1 -1
- package/src/assets/icons/settings.svg +3 -0
- package/src/assets/icons/skipped_status_icon.svg +1 -1
- package/src/assets/icons/warning_status_icon.svg +1 -1
- package/src/components/Accordion/Accordion.stories.tsx +13 -0
- package/src/components/Accordion/Accordion.tsx +2 -1
- package/src/components/Accordion/types.ts +4 -0
- package/src/components/AllProjectsDropdown/types.ts +2 -0
- package/src/components/AppHeader/AppHeader.scss +6 -2
- package/src/components/AppHeader/AppHeader.tsx +4 -2
- package/src/components/Button/Button.scss +12 -0
- package/src/components/Button/Button.tsx +29 -11
- package/src/components/Button/types.ts +21 -0
- package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.scss +83 -30
- package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.stories.tsx +3 -0
- package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.tsx +39 -16
- package/src/components/Charts/DashboardDonutChart/types.ts +2 -0
- package/src/components/Charts/MultiRadialChart/MultiRadialChart.scss +0 -1
- package/src/components/Charts/MultiRadialChart/MultiRadialChart.stories.tsx +2 -1
- package/src/components/Charts/MultiRadialChart/MultiRadialChart.tsx +18 -4
- package/src/components/Charts/MultiRadialChart/types.ts +4 -1
- package/src/components/ChooseFile/ChooseFile.stories.tsx +190 -0
- package/src/components/ChooseFile/ChooseFile.tsx +46 -0
- package/src/components/ChooseFile/types.ts +78 -0
- package/src/components/ConditionalDropdown/ConditionalDropdown.stories.tsx +8 -5
- package/src/components/ConditionalDropdown/ConditionalDropdown.tsx +133 -135
- package/src/components/ConditionalDropdown/types.ts +8 -8
- package/src/components/ConnectingBranch/BranchComponents/MachineInstances.tsx +94 -79
- package/src/components/ConnectingBranch/ConnectingBranch.scss +183 -195
- package/src/components/ConnectingBranch/ConnectingBranch.stories.tsx +33 -1
- package/src/components/ConnectingBranch/ConnectingBranch.tsx +121 -107
- package/src/components/ConnectingBranch/{data.ts → data.tsx} +106 -17
- package/src/components/ConnectingBranch/types.ts +21 -0
- package/src/components/DatePicker/DatePicker.scss +310 -0
- package/src/components/Excel/ExcelFile/ExcelFile.tsx +4 -4
- package/src/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.tsx +22 -10
- package/src/components/Excel/ExcelFile/ExcelFileComponents/ColumnIndicator.tsx +2 -2
- package/src/components/Excel/ExcelFile/ExcelFileComponents/DataEditor.tsx +4 -1
- package/src/components/Excel/ExcelFile/ExcelFileComponents/FloatingRect.tsx +6 -1
- package/src/components/Excel/ExcelFile/ExcelFileComponents/RowIndicator.tsx +2 -2
- package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.scss +30 -11
- package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.tsx +65 -19
- package/src/components/Excel/ExcelFile/ExcelFileComponents/actions.ts +14 -0
- package/src/components/Excel/ExcelFile/ExcelFileComponents/reducer.ts +16 -0
- package/src/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.ts +77 -10
- package/src/components/Excel/ExcelToolBar/ExcelToolBar.tsx +6 -5
- package/src/components/FileDropzone/Dropzone.tsx +3 -0
- package/src/components/FileDropzone/FileDropzone.scss +18 -0
- package/src/components/FileDropzone/FileDropzone.stories.tsx +75 -7
- package/src/components/FileDropzone/FileDropzone.tsx +2 -0
- package/src/components/FileDropzone/RadioFilePreview.tsx +7 -3
- package/src/components/FileDropzone/types.ts +13 -4
- package/src/components/Icon/iconList.ts +4 -2
- package/src/components/InputWithDropdown/InputWithDropdown.tsx +1 -1
- package/src/components/LabelEditTextField/LabelEditTextField.scss +4 -0
- package/src/components/LabelEditTextField/LabelEditTextField.stories.tsx +8 -3
- package/src/components/LabelEditTextField/LabelEditTextField.tsx +42 -18
- package/src/components/LabelEditTextField/types.ts +3 -1
- package/src/components/MachineInputField/MachineInputField.tsx +67 -70
- package/src/components/NLPInput/components/NlpDropDown/NlpDropdown.scss +1 -1
- package/src/components/ScriptSwitchButton/ScriptSwitchButton.scss +33 -0
- package/src/components/ScriptSwitchButton/ScriptSwitchButton.stories.tsx +48 -0
- package/src/components/ScriptSwitchButton/ScriptSwitchButton.tsx +65 -0
- package/src/components/ScriptSwitchButton/index.ts +1 -0
- package/src/components/Search/Search.tsx +3 -1
- package/src/components/Select/Select.tsx +4 -4
- package/src/components/Select/types.ts +1 -1
- package/src/components/SequentialConnectingBranch/components/Branches/Branches.scss +1 -0
- package/src/components/SequentialConnectingBranch/components/Branches/Branches.tsx +2 -8
- package/src/components/StatusCard/StatusCard.scss +2 -1
- package/src/components/StatusCard/StatusCard.stories.tsx +59 -1
- package/src/components/StatusCard/StatusCard.tsx +10 -2
- package/src/components/StatusCard/types.ts +2 -0
- package/src/components/TableTree/Components/TableBody.tsx +20 -16
- package/src/components/TableTree/Components/TableCell.tsx +47 -31
- package/src/components/TableTree/Components/TableRow.tsx +4 -0
- package/src/components/TableTree/TableTree.scss +121 -109
- package/src/components/TableTree/data.ts +48 -2
- package/src/components/TableTree/types.ts +4 -0
- package/src/components/TextArea/Textarea.tsx +2 -0
- package/src/components/TextArea/Types.ts +3 -0
- package/src/components/ThemeProvider/types.ts +1 -1
- package/src/index.ts +97 -0
- package/src/utils/validateFile/validateFile.stories.tsx +49 -0
- package/src/utils/validateFile/validateFile.ts +39 -0
- package/src/validations/regex.stories.tsx +362 -0
- package/src/validations/regex.ts +194 -0
- package/src/components/SequentialConnectingBranch/components/AddBrowserModal/AddBrowserModal.scss +0 -51
- package/src/components/SequentialConnectingBranch/components/AddBrowserModal/AddBrowserModal.tsx +0 -107
- package/src/components/SequentialConnectingBranch/components/AddBrowserModal/types.ts +0 -5
- package/src/components/SequentialConnectingBranch/components/DatasetListModal/DatasetListModal.scss +0 -31
- package/src/components/SequentialConnectingBranch/components/DatasetListModal/DatasetListModal.tsx +0 -85
- package/src/components/SequentialConnectingBranch/components/DatasetListModal/types.ts +0 -4
- /package/src/assets/icons/{impactList.svg → impact_list.svg} +0 -0
package/src/index.ts
CHANGED
|
@@ -71,6 +71,8 @@ import FieldSet from './components/FieldSet';
|
|
|
71
71
|
import CreateVariableSlider from './components/CreateVariable/CreateVariableSlider';
|
|
72
72
|
import TableWithAccordion from './components/TableWithAccordion/TableWithAccordion';
|
|
73
73
|
import ProgressBar from './components/ProgressBar';
|
|
74
|
+
import ChooseFile from './components/ChooseFile/ChooseFile';
|
|
75
|
+
import ScriptSwitchButton from './components/ScriptSwitchButton';
|
|
74
76
|
|
|
75
77
|
// Utils imports
|
|
76
78
|
import { checkEmpty } from './utils/checkEmpty/checkEmpty';
|
|
@@ -100,6 +102,53 @@ import FormatString from './utils/FormatString/FormatString';
|
|
|
100
102
|
import ConditionalDropdown from './components/ConditionalDropdown/ConditionalDropdown';
|
|
101
103
|
import { hasDuplicateFile } from './utils/checkDuplicates/checkDuplicates';
|
|
102
104
|
import PhoneInputField from './components/PhoneInput';
|
|
105
|
+
import {
|
|
106
|
+
EMAIL_REGEX,
|
|
107
|
+
URL_REGEX,
|
|
108
|
+
PHONE_REGEX,
|
|
109
|
+
POSTAL_CODE_REGEX,
|
|
110
|
+
IPV4_REGEX,
|
|
111
|
+
IPV6_REGEX,
|
|
112
|
+
HEX_COLOR_REGEX,
|
|
113
|
+
PASSWORD_SIMPLE_REGEX,
|
|
114
|
+
PASSWORD_COMPLEX_REGEX,
|
|
115
|
+
ALPHABET_ONLY_REGEX,
|
|
116
|
+
NUMBERS_ONLY_REGEX,
|
|
117
|
+
ALPHANUMERIC_REGEX,
|
|
118
|
+
DATE_REGEX,
|
|
119
|
+
TIME_REGEX,
|
|
120
|
+
FILE_EXTENSION_REGEX,
|
|
121
|
+
MAC_ADDRESS_REGEX,
|
|
122
|
+
CREDIT_CARD_REGEX,
|
|
123
|
+
SSN_REGEX,
|
|
124
|
+
UUID_REGEX,
|
|
125
|
+
HTML_TAG_REGEX,
|
|
126
|
+
WHITESPACE_REGEX,
|
|
127
|
+
US_ZIP_CODE_REGEX,
|
|
128
|
+
USERNAME_REGEX,
|
|
129
|
+
INDIAN_PHONE_REGEX,
|
|
130
|
+
INDIAN_PIN_CODE_REGEX,
|
|
131
|
+
GSTIN_REGEX,
|
|
132
|
+
PAN_CARD_REGEX,
|
|
133
|
+
AADHAAR_REGEX,
|
|
134
|
+
VEHICLE_REGISTRATION_REGEX,
|
|
135
|
+
INDIAN_CURRENCY_REGEX,
|
|
136
|
+
INTERNATIONAL_PHONE_REGEX,
|
|
137
|
+
INDIAN_PASSPORT_REGEX,
|
|
138
|
+
DRIVING_LICENSE_REGEX,
|
|
139
|
+
USERNAME_SPECIAL_REGEX,
|
|
140
|
+
DECIMAL_NUMBER_REGEX,
|
|
141
|
+
HTML_ATTRIBUTE_REGEX,
|
|
142
|
+
RGB_COLOR_REGEX,
|
|
143
|
+
HSL_COLOR_REGEX,
|
|
144
|
+
BASE64_REGEX,
|
|
145
|
+
BINARY_NUMBER_REGEX,
|
|
146
|
+
HEXADECIMAL_NUMBER_REGEX,
|
|
147
|
+
ROMAN_NUMERALS_REGEX,
|
|
148
|
+
CURRENCY_GENERIC_REGEX,
|
|
149
|
+
LINKEDIN_PROFILE_REGEX,
|
|
150
|
+
TWITTER_HANDLE_REGEX,
|
|
151
|
+
} from './validations/regex';
|
|
103
152
|
|
|
104
153
|
export {
|
|
105
154
|
Button,
|
|
@@ -184,6 +233,9 @@ export {
|
|
|
184
233
|
PhoneInputField,
|
|
185
234
|
TableWithAccordion,
|
|
186
235
|
ProgressBar,
|
|
236
|
+
ChooseFile,
|
|
237
|
+
ScriptSwitchButton,
|
|
238
|
+
|
|
187
239
|
// utils exports
|
|
188
240
|
checkEmpty,
|
|
189
241
|
getExtension,
|
|
@@ -202,4 +254,49 @@ export {
|
|
|
202
254
|
useFileDropzone,
|
|
203
255
|
FormatString,
|
|
204
256
|
hasDuplicateFile,
|
|
257
|
+
EMAIL_REGEX,
|
|
258
|
+
URL_REGEX,
|
|
259
|
+
PHONE_REGEX,
|
|
260
|
+
POSTAL_CODE_REGEX,
|
|
261
|
+
IPV4_REGEX,
|
|
262
|
+
IPV6_REGEX,
|
|
263
|
+
HEX_COLOR_REGEX,
|
|
264
|
+
PASSWORD_SIMPLE_REGEX,
|
|
265
|
+
PASSWORD_COMPLEX_REGEX,
|
|
266
|
+
ALPHABET_ONLY_REGEX,
|
|
267
|
+
NUMBERS_ONLY_REGEX,
|
|
268
|
+
ALPHANUMERIC_REGEX,
|
|
269
|
+
DATE_REGEX,
|
|
270
|
+
TIME_REGEX,
|
|
271
|
+
FILE_EXTENSION_REGEX,
|
|
272
|
+
MAC_ADDRESS_REGEX,
|
|
273
|
+
CREDIT_CARD_REGEX,
|
|
274
|
+
SSN_REGEX,
|
|
275
|
+
UUID_REGEX,
|
|
276
|
+
HTML_TAG_REGEX,
|
|
277
|
+
WHITESPACE_REGEX,
|
|
278
|
+
US_ZIP_CODE_REGEX,
|
|
279
|
+
USERNAME_REGEX,
|
|
280
|
+
INDIAN_PHONE_REGEX,
|
|
281
|
+
INDIAN_PIN_CODE_REGEX,
|
|
282
|
+
GSTIN_REGEX,
|
|
283
|
+
PAN_CARD_REGEX,
|
|
284
|
+
AADHAAR_REGEX,
|
|
285
|
+
VEHICLE_REGISTRATION_REGEX,
|
|
286
|
+
INDIAN_CURRENCY_REGEX,
|
|
287
|
+
INTERNATIONAL_PHONE_REGEX,
|
|
288
|
+
INDIAN_PASSPORT_REGEX,
|
|
289
|
+
DRIVING_LICENSE_REGEX,
|
|
290
|
+
USERNAME_SPECIAL_REGEX,
|
|
291
|
+
DECIMAL_NUMBER_REGEX,
|
|
292
|
+
HTML_ATTRIBUTE_REGEX,
|
|
293
|
+
RGB_COLOR_REGEX,
|
|
294
|
+
HSL_COLOR_REGEX,
|
|
295
|
+
BASE64_REGEX,
|
|
296
|
+
BINARY_NUMBER_REGEX,
|
|
297
|
+
HEXADECIMAL_NUMBER_REGEX,
|
|
298
|
+
ROMAN_NUMERALS_REGEX,
|
|
299
|
+
CURRENCY_GENERIC_REGEX,
|
|
300
|
+
LINKEDIN_PROFILE_REGEX,
|
|
301
|
+
TWITTER_HANDLE_REGEX,
|
|
205
302
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
validateFileExtension,
|
|
4
|
+
validateZipFileExtension,
|
|
5
|
+
} from './validateFile';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Utils/validateFile',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const allowedFileTypes = {
|
|
12
|
+
'.txt': 'text/plain',
|
|
13
|
+
'.zip': 'application/zip',
|
|
14
|
+
'.jpg': 'image/jpeg',
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const ValidateFileExtension = () => {
|
|
18
|
+
const [result, setResult] = useState<string | boolean>('');
|
|
19
|
+
|
|
20
|
+
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
21
|
+
const isValid = validateFileExtension(event, allowedFileTypes);
|
|
22
|
+
setResult(isValid ? 'Valid file type' : 'Invalid file type');
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div>
|
|
27
|
+
<h3>Validate File Extension</h3>
|
|
28
|
+
<input type="file" onChange={handleFileChange} />
|
|
29
|
+
<p>Result: {result.toString()}</p>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const ValidateZipFileExtension = () => {
|
|
35
|
+
const [result, setResult] = useState<string | boolean>('');
|
|
36
|
+
|
|
37
|
+
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
38
|
+
const isValid = validateZipFileExtension(event);
|
|
39
|
+
setResult(isValid ? 'Valid ZIP file' : 'Invalid ZIP file');
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div>
|
|
44
|
+
<h3>Validate ZIP File Extension</h3>
|
|
45
|
+
<input type="file" onChange={handleFileChange} />
|
|
46
|
+
<p>Result: {result.toString()}</p>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const validateFileExtension = (
|
|
2
|
+
file: File | React.ChangeEvent<HTMLInputElement>,
|
|
3
|
+
allowedFileTypes: Record<string, string>
|
|
4
|
+
) => {
|
|
5
|
+
const selectedFile =
|
|
6
|
+
(file as React.ChangeEvent<HTMLInputElement>).target?.files?.[0] ||
|
|
7
|
+
(file as File);
|
|
8
|
+
const fileExtension =
|
|
9
|
+
'.' + selectedFile?.name?.split('.')?.pop()?.toLowerCase();
|
|
10
|
+
const fileType = selectedFile?.type;
|
|
11
|
+
if (
|
|
12
|
+
['.ipa', '.y4m', '.yml', '.md', '.pem', '.properties'].includes(
|
|
13
|
+
fileExtension
|
|
14
|
+
) &&
|
|
15
|
+
Object.keys(allowedFileTypes)?.includes(fileExtension)
|
|
16
|
+
) {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
return (
|
|
20
|
+
allowedFileTypes[fileExtension] &&
|
|
21
|
+
fileType === allowedFileTypes[fileExtension]
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const validateZipFileExtension = (
|
|
26
|
+
file: File | React.ChangeEvent<HTMLInputElement>
|
|
27
|
+
) => {
|
|
28
|
+
const selectedFile =
|
|
29
|
+
(file as React.ChangeEvent<HTMLInputElement>).target?.files?.[0] ||
|
|
30
|
+
(file as File);
|
|
31
|
+
// List of valid MIME types
|
|
32
|
+
const validMimeTypes = ['application/zip', 'application/x-zip-compressed'];
|
|
33
|
+
// Validating the file extension and MIME type
|
|
34
|
+
return (
|
|
35
|
+
selectedFile &&
|
|
36
|
+
validMimeTypes?.includes(selectedFile?.type) &&
|
|
37
|
+
selectedFile?.name?.toLowerCase()?.endsWith('.zip')
|
|
38
|
+
);
|
|
39
|
+
};
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
EMAIL_REGEX,
|
|
5
|
+
URL_REGEX,
|
|
6
|
+
PHONE_REGEX,
|
|
7
|
+
POSTAL_CODE_REGEX,
|
|
8
|
+
IPV4_REGEX,
|
|
9
|
+
IPV6_REGEX,
|
|
10
|
+
HEX_COLOR_REGEX,
|
|
11
|
+
PASSWORD_SIMPLE_REGEX,
|
|
12
|
+
PASSWORD_COMPLEX_REGEX,
|
|
13
|
+
ALPHABET_ONLY_REGEX,
|
|
14
|
+
NUMBERS_ONLY_REGEX,
|
|
15
|
+
ALPHANUMERIC_REGEX,
|
|
16
|
+
DATE_REGEX,
|
|
17
|
+
TIME_REGEX,
|
|
18
|
+
FILE_EXTENSION_REGEX,
|
|
19
|
+
MAC_ADDRESS_REGEX,
|
|
20
|
+
CREDIT_CARD_REGEX,
|
|
21
|
+
SSN_REGEX,
|
|
22
|
+
UUID_REGEX,
|
|
23
|
+
HTML_TAG_REGEX,
|
|
24
|
+
WHITESPACE_REGEX,
|
|
25
|
+
US_ZIP_CODE_REGEX,
|
|
26
|
+
USERNAME_REGEX,
|
|
27
|
+
INDIAN_PHONE_REGEX,
|
|
28
|
+
INDIAN_PIN_CODE_REGEX,
|
|
29
|
+
GSTIN_REGEX,
|
|
30
|
+
PAN_CARD_REGEX,
|
|
31
|
+
AADHAAR_REGEX,
|
|
32
|
+
VEHICLE_REGISTRATION_REGEX,
|
|
33
|
+
INDIAN_CURRENCY_REGEX,
|
|
34
|
+
INTERNATIONAL_PHONE_REGEX,
|
|
35
|
+
INDIAN_PASSPORT_REGEX,
|
|
36
|
+
DRIVING_LICENSE_REGEX,
|
|
37
|
+
USERNAME_SPECIAL_REGEX,
|
|
38
|
+
DECIMAL_NUMBER_REGEX,
|
|
39
|
+
HTML_ATTRIBUTE_REGEX,
|
|
40
|
+
RGB_COLOR_REGEX,
|
|
41
|
+
HSL_COLOR_REGEX,
|
|
42
|
+
BASE64_REGEX,
|
|
43
|
+
BINARY_NUMBER_REGEX,
|
|
44
|
+
HEXADECIMAL_NUMBER_REGEX,
|
|
45
|
+
ROMAN_NUMERALS_REGEX,
|
|
46
|
+
CURRENCY_GENERIC_REGEX,
|
|
47
|
+
LINKEDIN_PROFILE_REGEX,
|
|
48
|
+
TWITTER_HANDLE_REGEX,
|
|
49
|
+
} from './regex';
|
|
50
|
+
|
|
51
|
+
export default {
|
|
52
|
+
title: 'Regex/Validations',
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const Playground = () => {
|
|
56
|
+
const [input, setInput] = useState('');
|
|
57
|
+
const [result, setResult] = useState('');
|
|
58
|
+
const [selectedRegex, setSelectedRegex] = useState('');
|
|
59
|
+
|
|
60
|
+
const validators = [
|
|
61
|
+
{
|
|
62
|
+
name: 'EMAIL_REGEX',
|
|
63
|
+
regex: EMAIL_REGEX,
|
|
64
|
+
description: 'Validates an email address (e.g. user@example.com)',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: 'URL_REGEX',
|
|
68
|
+
regex: URL_REGEX,
|
|
69
|
+
description: 'Validates a URL (e.g. https://www.example.com)',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: 'PHONE_REGEX',
|
|
73
|
+
regex: PHONE_REGEX,
|
|
74
|
+
description: 'Validates a general phone number (e.g. (123) 456-7890)',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
name: 'POSTAL_CODE_REGEX',
|
|
78
|
+
regex: POSTAL_CODE_REGEX,
|
|
79
|
+
description: 'Validates postal code format',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'IPV4_REGEX',
|
|
83
|
+
regex: IPV4_REGEX,
|
|
84
|
+
description: 'Validates IPv4 addresses (e.g. 192.168.0.1)',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'IPV6_REGEX',
|
|
88
|
+
regex: IPV6_REGEX,
|
|
89
|
+
description:
|
|
90
|
+
'Validates IPv6 addresses (e.g. 2001:0db8:85a3:0000:0000:8a2e:0370:7334)',
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: 'HEX_COLOR_REGEX',
|
|
94
|
+
regex: HEX_COLOR_REGEX,
|
|
95
|
+
description: 'Validates hex color codes (e.g. #FFFFFF)',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'PASSWORD_SIMPLE_REGEX',
|
|
99
|
+
regex: PASSWORD_SIMPLE_REGEX,
|
|
100
|
+
description: 'Validates a simple password (e.g. password123)',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
name: 'PASSWORD_COMPLEX_REGEX',
|
|
104
|
+
regex: PASSWORD_COMPLEX_REGEX,
|
|
105
|
+
description: 'Validates a complex password (e.g. P@ssw0rd!',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'ALPHABET_ONLY_REGEX',
|
|
109
|
+
regex: ALPHABET_ONLY_REGEX,
|
|
110
|
+
description: 'Validates alphabets only (e.g. abc)',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'NUMBERS_ONLY_REGEX',
|
|
114
|
+
regex: NUMBERS_ONLY_REGEX,
|
|
115
|
+
description: 'Validates numbers only (e.g. 123)',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: 'ALPHANUMERIC_REGEX',
|
|
119
|
+
regex: ALPHANUMERIC_REGEX,
|
|
120
|
+
description: 'Validates alphanumeric values (e.g. abc123)',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: 'DATE_REGEX',
|
|
124
|
+
regex: DATE_REGEX,
|
|
125
|
+
description: 'Validates date in YYYY-MM-DD format (e.g. 2024-12-11)',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
name: 'TIME_REGEX',
|
|
129
|
+
regex: TIME_REGEX,
|
|
130
|
+
description: 'Validates time in HH:MM:SS format (e.g. 14:30:45)',
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: 'FILE_EXTENSION_REGEX',
|
|
134
|
+
regex: FILE_EXTENSION_REGEX,
|
|
135
|
+
description: 'Validates file extensions (e.g. .jpg, .png)',
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'MAC_ADDRESS_REGEX',
|
|
139
|
+
regex: MAC_ADDRESS_REGEX,
|
|
140
|
+
description: 'Validates MAC address (e.g. 00:14:22:01:23:45)',
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'CREDIT_CARD_REGEX',
|
|
144
|
+
regex: CREDIT_CARD_REGEX,
|
|
145
|
+
description: 'Validates credit card number (e.g. 1234 5678 9012 3456)',
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
name: 'SSN_REGEX',
|
|
149
|
+
regex: SSN_REGEX,
|
|
150
|
+
description: 'Validates Social Security Number (e.g. 123-45-6789)',
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
name: 'UUID_REGEX',
|
|
154
|
+
regex: UUID_REGEX,
|
|
155
|
+
description: 'Validates UUID (e.g. 123e4567-e89b-12d3-a456-426614174000)',
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: 'HTML_TAG_REGEX',
|
|
159
|
+
regex: HTML_TAG_REGEX,
|
|
160
|
+
description: 'Validates HTML tags (e.g. <div>, <span>)',
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: 'WHITESPACE_REGEX',
|
|
164
|
+
regex: WHITESPACE_REGEX,
|
|
165
|
+
description: 'Validates whitespace characters (e.g. spaces, tabs)',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: 'US_ZIP_CODE_REGEX',
|
|
169
|
+
regex: US_ZIP_CODE_REGEX,
|
|
170
|
+
description: 'Validates US ZIP code (e.g. 90210)',
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
name: 'USERNAME_REGEX',
|
|
174
|
+
regex: USERNAME_REGEX,
|
|
175
|
+
description: 'Validates username (e.g. user123)',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: 'INDIAN_PHONE_REGEX',
|
|
179
|
+
regex: INDIAN_PHONE_REGEX,
|
|
180
|
+
description: 'Validates Indian phone number (e.g. +91 9876543210)',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
name: 'INDIAN_PIN_CODE_REGEX',
|
|
184
|
+
regex: INDIAN_PIN_CODE_REGEX,
|
|
185
|
+
description: 'Validates Indian PIN code (e.g. 110001)',
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
name: 'GSTIN_REGEX',
|
|
189
|
+
regex: GSTIN_REGEX,
|
|
190
|
+
description: 'Validates GSTIN number (e.g. 07AACCB1234K1Z5)',
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: 'PAN_CARD_REGEX',
|
|
194
|
+
regex: PAN_CARD_REGEX,
|
|
195
|
+
description: 'Validates PAN card number (e.g. ABCDE1234F)',
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
name: 'AADHAAR_REGEX',
|
|
199
|
+
regex: AADHAAR_REGEX,
|
|
200
|
+
description: 'Validates Aadhaar number (e.g. 1234 5678 9012)',
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
name: 'VEHICLE_REGISTRATION_REGEX',
|
|
204
|
+
regex: VEHICLE_REGISTRATION_REGEX,
|
|
205
|
+
description: 'Validates vehicle registration number (e.g. DL 12 AB 1234)',
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
name: 'INDIAN_CURRENCY_REGEX',
|
|
209
|
+
regex: INDIAN_CURRENCY_REGEX,
|
|
210
|
+
description: 'Validates Indian currency format (e.g. ₹1234.56)',
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
name: 'INTERNATIONAL_PHONE_REGEX',
|
|
214
|
+
regex: INTERNATIONAL_PHONE_REGEX,
|
|
215
|
+
description:
|
|
216
|
+
'Validates international phone numbers (e.g. +44 20 7946 0958)',
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
name: 'INDIAN_PASSPORT_REGEX',
|
|
220
|
+
regex: INDIAN_PASSPORT_REGEX,
|
|
221
|
+
description: 'Validates Indian passport number (e.g. A1234567)',
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
name: 'DRIVING_LICENSE_REGEX',
|
|
225
|
+
regex: DRIVING_LICENSE_REGEX,
|
|
226
|
+
description: 'Validates driving license number (e.g. DL-123456789012)',
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
name: 'USERNAME_SPECIAL_REGEX',
|
|
230
|
+
regex: USERNAME_SPECIAL_REGEX,
|
|
231
|
+
description:
|
|
232
|
+
'Validates username with special characters (e.g. user_123@)',
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
name: 'DECIMAL_NUMBER_REGEX',
|
|
236
|
+
regex: DECIMAL_NUMBER_REGEX,
|
|
237
|
+
description: 'Validates decimal numbers (e.g. 123.45)',
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
name: 'HTML_ATTRIBUTE_REGEX',
|
|
241
|
+
regex: HTML_ATTRIBUTE_REGEX,
|
|
242
|
+
description: 'Validates HTML attribute value (e.g. class="my-class")',
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
name: 'RGB_COLOR_REGEX',
|
|
246
|
+
regex: RGB_COLOR_REGEX,
|
|
247
|
+
description: 'Validates RGB color format (e.g. rgb(255, 0, 0))',
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
name: 'HSL_COLOR_REGEX',
|
|
251
|
+
regex: HSL_COLOR_REGEX,
|
|
252
|
+
description: 'Validates HSL color format (e.g. hsl(0, 100%, 50%))',
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
name: 'BASE64_REGEX',
|
|
256
|
+
regex: BASE64_REGEX,
|
|
257
|
+
description: 'Validates base64 encoded string (e.g. aGVsbG8gd29ybGQ=)',
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
name: 'BINARY_NUMBER_REGEX',
|
|
261
|
+
regex: BINARY_NUMBER_REGEX,
|
|
262
|
+
description: 'Validates binary number (e.g. 1010)',
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: 'HEXADECIMAL_NUMBER_REGEX',
|
|
266
|
+
regex: HEXADECIMAL_NUMBER_REGEX,
|
|
267
|
+
description: 'Validates hexadecimal number (e.g. 1A3F)',
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
name: 'ROMAN_NUMERALS_REGEX',
|
|
271
|
+
regex: ROMAN_NUMERALS_REGEX,
|
|
272
|
+
description: 'Validates Roman numerals (e.g. IV, X, MM)',
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
name: 'CURRENCY_GENERIC_REGEX',
|
|
276
|
+
regex: CURRENCY_GENERIC_REGEX,
|
|
277
|
+
description: 'Validates generic currency format (e.g. $123.45)',
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
name: 'LINKEDIN_PROFILE_REGEX',
|
|
281
|
+
regex: LINKEDIN_PROFILE_REGEX,
|
|
282
|
+
description:
|
|
283
|
+
'Validates LinkedIn profile URL (e.g. https://www.linkedin.com/in/username)',
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
name: 'TWITTER_HANDLE_REGEX',
|
|
287
|
+
regex: TWITTER_HANDLE_REGEX,
|
|
288
|
+
description: 'Validates Twitter handle (e.g. @username)',
|
|
289
|
+
},
|
|
290
|
+
];
|
|
291
|
+
|
|
292
|
+
const validateInput = () => {
|
|
293
|
+
const validator = validators.find(
|
|
294
|
+
(validator) => validator.name === selectedRegex
|
|
295
|
+
);
|
|
296
|
+
if (validator && validator.regex) {
|
|
297
|
+
const isValid = validator.regex.test(input);
|
|
298
|
+
setResult(isValid ? 'Valid input' : 'Invalid input');
|
|
299
|
+
} else {
|
|
300
|
+
setResult('No validator selected');
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
const handleRegexChange = (e) => {
|
|
305
|
+
setSelectedRegex(e.target.value);
|
|
306
|
+
setResult('');
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
const selectedValidator = validators.find(
|
|
310
|
+
(validator) => validator.name === selectedRegex
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
return (
|
|
314
|
+
<div style={{ padding: '20px', fontFamily: 'Arial, sans-serif' }}>
|
|
315
|
+
<h1>Validation Regex Playground</h1>
|
|
316
|
+
|
|
317
|
+
<select
|
|
318
|
+
value={selectedRegex}
|
|
319
|
+
onChange={handleRegexChange}
|
|
320
|
+
style={{ padding: '10px', width: '300px', marginRight: '10px' }}
|
|
321
|
+
>
|
|
322
|
+
<option value="">Select Regex</option>
|
|
323
|
+
{validators.map((validator) => (
|
|
324
|
+
<option key={validator.name} value={validator.name}>
|
|
325
|
+
{validator.name}
|
|
326
|
+
</option>
|
|
327
|
+
))}
|
|
328
|
+
</select>
|
|
329
|
+
|
|
330
|
+
{selectedValidator && (
|
|
331
|
+
<>
|
|
332
|
+
<p>
|
|
333
|
+
<b>{selectedValidator.name}</b>
|
|
334
|
+
</p>
|
|
335
|
+
<p style={{ fontStyle: 'italic' }}>{selectedValidator.description}</p>
|
|
336
|
+
</>
|
|
337
|
+
)}
|
|
338
|
+
|
|
339
|
+
<div style={{ marginTop: '20px' }}>
|
|
340
|
+
<input
|
|
341
|
+
type="text"
|
|
342
|
+
placeholder="Enter input to test"
|
|
343
|
+
value={input}
|
|
344
|
+
onChange={(e) => setInput(e.target.value)}
|
|
345
|
+
style={{ padding: '10px', width: '300px', marginRight: '10px' }}
|
|
346
|
+
/>
|
|
347
|
+
<button onClick={validateInput} style={{ padding: '10px' }}>
|
|
348
|
+
Validate
|
|
349
|
+
</button>
|
|
350
|
+
</div>
|
|
351
|
+
|
|
352
|
+
<div
|
|
353
|
+
style={{
|
|
354
|
+
marginTop: '20px',
|
|
355
|
+
color: result === 'Valid input' ? 'green' : 'red',
|
|
356
|
+
}}
|
|
357
|
+
>
|
|
358
|
+
{result}
|
|
359
|
+
</div>
|
|
360
|
+
</div>
|
|
361
|
+
);
|
|
362
|
+
};
|