pixel-react-excel-sheet 1.0.38 → 1.0.39

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.
Files changed (149) hide show
  1. package/lib/components/Button/Button.d.ts +2 -2
  2. package/lib/components/Charts/DashboardDonutChart/types.d.ts +3 -0
  3. package/lib/components/Charts/LineChart/types.d.ts +1 -0
  4. package/lib/components/ChooseFile/ChooseFile.d.ts +3 -2
  5. package/lib/components/Comment/Comments.d.ts +1 -1
  6. package/lib/components/Comment/type.d.ts +3 -3
  7. package/lib/components/ConditionalDropdown/types.d.ts +4 -0
  8. package/lib/components/DatePicker/types.d.ts +2 -0
  9. package/lib/components/Drawer/Types.d.ts +3 -0
  10. package/lib/components/Excel/ExcelFile/ExcelFile.d.ts +11 -10
  11. package/lib/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.d.ts +10 -0
  12. package/lib/components/Excel/ExcelFile/ExcelFileComponents/DataViewer.d.ts +1 -1
  13. package/lib/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.d.ts +9 -0
  14. package/lib/components/Excel/ExcelFile/ExcelFileComponents/types.d.ts +0 -3
  15. package/lib/components/Excel/Types.d.ts +14 -10
  16. package/lib/components/FF_Captcha/Recaptcha.d.ts +2 -1
  17. package/lib/components/FF_Captcha/types.d.ts +11 -2
  18. package/lib/components/Input/types.d.ts +4 -0
  19. package/lib/components/LabelEditTextField/types.d.ts +2 -0
  20. package/lib/components/MobileSkin/MobileSkin.d.ts +5 -0
  21. package/lib/components/MobileSkin/MobileSkinInterface.d.ts +13 -0
  22. package/lib/components/MobileSkin/index.d.ts +1 -0
  23. package/lib/components/MobileSkin/types.d.ts +32 -0
  24. package/lib/components/Search/Search.d.ts +1 -1
  25. package/lib/components/Search/types.d.ts +1 -0
  26. package/lib/components/Select/components/types.d.ts +3 -2
  27. package/lib/components/Select/types.d.ts +10 -2
  28. package/lib/components/SequentialConnectingBranch/components/Branches/Branches.d.ts +1 -1
  29. package/lib/components/SequentialConnectingBranch/components/Branches/types.d.ts +1 -0
  30. package/lib/components/SequentialConnectingBranch/components/ConnectingBranches/ConnectingBranches.d.ts +1 -1
  31. package/lib/components/SequentialConnectingBranch/components/ConnectingBranches/types.d.ts +1 -0
  32. package/lib/components/SequentialConnectingBranch/types.d.ts +1 -0
  33. package/lib/components/TableTree/types.d.ts +4 -4
  34. package/lib/components/Tabs/types.d.ts +1 -0
  35. package/lib/index.d.ts +96 -40
  36. package/lib/index.esm.js +4812 -1669
  37. package/lib/index.esm.js.map +1 -1
  38. package/lib/index.js +4825 -1669
  39. package/lib/index.js.map +1 -1
  40. package/lib/tsconfig.tsbuildinfo +1 -1
  41. package/lib/utils/formData/ConvertFormDataToObject.d.ts +1 -0
  42. package/lib/utils/keyBoardActionUtil/UseKeyboardActions.d.ts +2 -0
  43. package/lib/utils/keyBoardActionUtil/types.d.ts +4 -0
  44. package/lib/validations/regex.d.ts +11 -1
  45. package/package.json +6 -1
  46. package/src/assets/Themes/BaseTheme.scss +3 -1
  47. package/src/assets/Themes/DarkTheme.scss +10 -1
  48. package/src/assets/icons/clear_cache.svg +5 -0
  49. package/src/assets/icons/external_user.svg +13 -0
  50. package/src/assets/icons/group_user.svg +12 -0
  51. package/src/assets/icons/single_user.svg +12 -0
  52. package/src/assets/icons/test_freshers_logo.svg +8 -0
  53. package/src/assets/icons/unfollow_icon.svg +3 -0
  54. package/src/components/AllProjectsDropdown/AllProjectsDropdown.scss +7 -45
  55. package/src/components/AllProjectsDropdown/AllProjectsDropdown.stories.tsx +5 -0
  56. package/src/components/AllProjectsDropdown/AllProjectsDropdown.tsx +76 -64
  57. package/src/components/Button/Button.scss +0 -1
  58. package/src/components/Button/Button.tsx +3 -4
  59. package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.stories.tsx +38 -6
  60. package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.tsx +10 -4
  61. package/src/components/Charts/DashboardDonutChart/types.ts +4 -1
  62. package/src/components/Charts/LineChart/LineChart.stories.tsx +27 -88
  63. package/src/components/Charts/LineChart/LineChart.tsx +138 -42
  64. package/src/components/Charts/LineChart/types.ts +1 -0
  65. package/src/components/Charts/MultiRadialChart/MultiRadialChart.scss +3 -3
  66. package/src/components/Charts/MultiRadialChart/MultiRadialChart.tsx +47 -43
  67. package/src/components/ChooseFile/ChooseFile.tsx +3 -4
  68. package/src/components/Comment/Comments.scss +0 -1
  69. package/src/components/Comment/Comments.stories.tsx +22 -4
  70. package/src/components/Comment/Comments.tsx +20 -1
  71. package/src/components/Comment/type.ts +3 -3
  72. package/src/components/ConditionalDropdown/ConditionalDropdown.stories.tsx +1 -0
  73. package/src/components/ConditionalDropdown/ConditionalDropdown.tsx +2 -1
  74. package/src/components/ConditionalDropdown/types.ts +4 -0
  75. package/src/components/DatePicker/DatePicker.scss +307 -2
  76. package/src/components/DatePicker/DatePicker.tsx +27 -19
  77. package/src/components/DatePicker/types.ts +4 -0
  78. package/src/components/Drawer/Drawer.stories.tsx +1 -1
  79. package/src/components/Drawer/Types.ts +4 -2
  80. package/src/components/Editor/Editor.scss +23 -18
  81. package/src/components/Editor/Editor.tsx +2 -2
  82. package/src/components/Excel/ExcelContextMenu/ExcelContextMenu.tsx +6 -3
  83. package/src/components/Excel/ExcelFile/ExcelFile.scss +45 -41
  84. package/src/components/Excel/ExcelFile/ExcelFile.tsx +68 -64
  85. package/src/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.tsx +29 -1
  86. package/src/components/Excel/ExcelFile/ExcelFileComponents/Cell.tsx +0 -36
  87. package/src/components/Excel/ExcelFile/ExcelFileComponents/DataViewer.tsx +1 -40
  88. package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.scss +3 -3
  89. package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.tsx +12 -1
  90. package/src/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.ts +8 -74
  91. package/src/components/Excel/ExcelFile/ExcelFileComponents/types.ts +0 -5
  92. package/src/components/Excel/ExcelFile.stories.tsx +112 -125
  93. package/src/components/Excel/ExcelToolBar/ExcelToolBar.tsx +10 -11
  94. package/src/components/Excel/Types.ts +17 -15
  95. package/src/components/FF_Captcha/Recaptcha.tsx +19 -9
  96. package/src/components/FF_Captcha/types.ts +12 -4
  97. package/src/components/Icon/Icon.stories.tsx +56 -8
  98. package/src/components/Icon/iconList.ts +13 -1
  99. package/src/components/Input/Input.stories.tsx +12 -0
  100. package/src/components/Input/Input.tsx +3 -1
  101. package/src/components/Input/types.ts +4 -0
  102. package/src/components/InputWithDropdown/types.ts +1 -1
  103. package/src/components/LabelEditTextField/LabelEditTextField.scss +4 -0
  104. package/src/components/LabelEditTextField/LabelEditTextField.stories.tsx +2 -1
  105. package/src/components/LabelEditTextField/LabelEditTextField.tsx +14 -10
  106. package/src/components/LabelEditTextField/types.ts +2 -0
  107. package/src/components/LazyLoad/LazyLoad.stories.tsx +1 -0
  108. package/src/components/LazyLoad/LazyLoading.tsx +10 -1
  109. package/src/components/MachineInputField/MachineInputField.scss +5 -1
  110. package/src/components/MachineInputField/MachineInputField.tsx +1 -0
  111. package/src/components/MobileSkin/MobileSkin.scss +67 -0
  112. package/src/components/MobileSkin/MobileSkin.stories.tsx +93 -0
  113. package/src/components/MobileSkin/MobileSkin.tsx +89 -0
  114. package/src/components/MobileSkin/MobileSkinInterface.ts +13 -0
  115. package/src/components/MobileSkin/index.ts +1 -0
  116. package/src/components/MobileSkin/types.ts +32 -0
  117. package/src/components/Modal/Modal.stories.tsx +7 -0
  118. package/src/components/Modal/Modal.tsx +17 -20
  119. package/src/components/Search/Search.scss +8 -0
  120. package/src/components/Search/Search.tsx +17 -6
  121. package/src/components/Search/types.ts +1 -0
  122. package/src/components/Select/Select.stories.tsx +85 -0
  123. package/src/components/Select/Select.tsx +10 -2
  124. package/src/components/Select/components/Dropdown.tsx +23 -15
  125. package/src/components/Select/components/types.ts +3 -2
  126. package/src/components/Select/types.ts +12 -2
  127. package/src/components/SequentialConnectingBranch/SequentialConnectingBranch.tsx +2 -0
  128. package/src/components/SequentialConnectingBranch/components/Branches/Branches.tsx +65 -57
  129. package/src/components/SequentialConnectingBranch/components/Branches/types.ts +1 -0
  130. package/src/components/SequentialConnectingBranch/components/ConnectingBranches/ConnectingBranches.tsx +2 -0
  131. package/src/components/SequentialConnectingBranch/components/ConnectingBranches/types.ts +1 -0
  132. package/src/components/SequentialConnectingBranch/types.ts +5 -1
  133. package/src/components/TableTree/Components/TableCell.tsx +3 -3
  134. package/src/components/TableTree/TableTree.scss +0 -7
  135. package/src/components/TableTree/TableTree.tsx +3 -22
  136. package/src/components/TableTree/types.ts +4 -4
  137. package/src/components/Tabs/Tabs.scss +19 -0
  138. package/src/components/Tabs/Tabs.tsx +9 -0
  139. package/src/components/Tabs/types.ts +1 -0
  140. package/src/index.ts +27 -0
  141. package/src/utils/formData/ConvertFormDataToObject.stories.tsx +27 -0
  142. package/src/utils/formData/ConvertFormDataToObject.ts +14 -0
  143. package/src/utils/getExtension/getExtension.stories.tsx +1 -0
  144. package/src/utils/keyBoardActionUtil/UseKeyboardAction.stories.tsx +53 -0
  145. package/src/utils/keyBoardActionUtil/UseKeyboardActions.tsx +20 -0
  146. package/src/utils/keyBoardActionUtil/types.ts +4 -0
  147. package/src/validations/regex.stories.tsx +63 -0
  148. package/src/validations/regex.ts +34 -0
  149. package/src/assets/images/photo.png +0 -0
@@ -8,7 +8,10 @@ export interface SequentialConnectingBranchProps {
8
8
  machineOptionsList?: Option[];
9
9
  onHandleSelect?: (option: Option) => void;
10
10
  onAddBrowserInstance?: (modalId: string) => void;
11
- onUpdateAddBrowserInstance: (modalId: string, machineInstance: ExecutionContext) => void;
11
+ onUpdateAddBrowserInstance: (
12
+ modalId: string,
13
+ machineInstance: ExecutionContext
14
+ ) => void;
12
15
  onDeleteBrowserInstance?: (id: string, runCount: number) => void;
13
16
  onAddRunBrowserInstance?: (machineInstanceId: string) => void;
14
17
  onDeleteMachineInstance?: () => void;
@@ -23,6 +26,7 @@ export interface SequentialConnectingBranchProps {
23
26
  addInstanceLabel?: string;
24
27
  scriptType?: string;
25
28
  projectType?: string;
29
+ readOnly?: boolean;
26
30
  }
27
31
 
28
32
  // Type for machine information
@@ -15,7 +15,7 @@ const renderSpaces = (
15
15
  <span
16
16
  key={i}
17
17
  className={`tree-table-space-block ${!line ? 'no-lines' : ''} ${
18
- isLast && i === level-1 ? 'last-node' : ''
18
+ isLast && i === level - 1 ? 'last-node' : ''
19
19
  }`}
20
20
  />
21
21
  ))}
@@ -51,7 +51,7 @@ const TableCell = React.memo(
51
51
  {col.isTree && select === 'checkbox' && (
52
52
  <Checkbox
53
53
  checked={selected.includes(node.id)}
54
- onChange={() => onCheckBoxChange('checkbox', node)}
54
+ onChange={(e) => onCheckBoxChange(e, node)}
55
55
  />
56
56
  )}
57
57
  {col.isTree && select === 'radio' && (
@@ -59,7 +59,7 @@ const TableCell = React.memo(
59
59
  name={node.title}
60
60
  checked={selected.includes(node.id)}
61
61
  value={node.id}
62
- onChange={() => onCheckBoxChange('radio', node)}
62
+ onChange={(e) => onCheckBoxChange(e, node)}
63
63
  />
64
64
  )}
65
65
  {prepareData(node, col)}
@@ -199,13 +199,6 @@
199
199
  transition: transform 0.3s ease;
200
200
  }
201
201
 
202
- tr:after {
203
- content: ' ';
204
- display: block;
205
- visibility: hidden;
206
- clear: both;
207
- }
208
-
209
202
  .tree-table-space-container {
210
203
  display: inline-flex;
211
204
  // flex-direction: row-reverse;
@@ -4,7 +4,6 @@ import { TreeTableProps } from './types';
4
4
  import TableHead from './Components/TableHead';
5
5
  import TableBody from './Components/TableBody';
6
6
  import { useIntersectionObserver } from '../../hooks/useIntersectionObserver';
7
- import getAllChildIds from './Utils/getAllChildIds';
8
7
  import functionCheck from '../../utils/functionCheck/functionCheck';
9
8
 
10
9
  const TreeTable: React.FC<TreeTableProps> = ({
@@ -41,28 +40,10 @@ const TreeTable: React.FC<TreeTableProps> = ({
41
40
  );
42
41
 
43
42
  const handleCheckBoxChange = useCallback(
44
- (type: string, node: any) => {
45
- const nodeId = node.id;
46
-
47
- if (type === 'radio') {
48
- onChange?.('true', [nodeId]);
49
- } else {
50
- let updatedSelected = [...selected];
51
-
52
- if (!updatedSelected.includes(nodeId)) {
53
- const childIds = getAllChildIds(nodeId, treeData);
54
- updatedSelected = [...new Set([...updatedSelected, ...childIds])]; // Add children
55
- } else {
56
- const childIds = getAllChildIds(nodeId, treeData);
57
- updatedSelected = updatedSelected.filter(
58
- (id) => !childIds.includes(id)
59
- );
60
- }
61
-
62
- onChange?.('true', updatedSelected);
63
- }
43
+ (e: any, node: any) => {
44
+ onChange?.(e, node);
64
45
  },
65
- [selected, treeData, onChange]
46
+ [onChange]
66
47
  );
67
48
 
68
49
  const handleRowClick = useCallback(
@@ -15,7 +15,7 @@ export interface TableCellProps {
15
15
  level: number;
16
16
  selected: string[];
17
17
  select: string | null;
18
- onCheckBoxChange: (type: string, node: any) => void;
18
+ onCheckBoxChange: (e: any, node: string[] | any) => void;
19
19
  onToggleExpand: (node: any) => void;
20
20
  parentSiblings: boolean[];
21
21
  isLast: boolean | undefined;
@@ -32,7 +32,7 @@ export interface TableBodyProps {
32
32
  select: string | null;
33
33
  onRowClick: (e: any, node: any) => void;
34
34
  onToggleExpand: (node: any) => void;
35
- onCheckBoxChange: (type: string, node: any) => void;
35
+ onCheckBoxChange: (e: any, node: string[] | any) => void;
36
36
  }
37
37
 
38
38
  export interface TableRowProps {
@@ -43,7 +43,7 @@ export interface TableRowProps {
43
43
  select: string | null;
44
44
  onRowClick: (e: any, node: any) => void;
45
45
  onToggleExpand: (node: any) => void;
46
- onCheckBoxChange: (type: string, node: any) => void;
46
+ onCheckBoxChange: (e: any, node: string[] | any) => void;
47
47
  parentSiblings: boolean[];
48
48
  isLast: boolean | undefined;
49
49
  }
@@ -65,7 +65,7 @@ export interface TreeTableProps {
65
65
  columnsData: Column[];
66
66
  selected?: string[];
67
67
  select?: 'radio' | 'checkbox' | 'none';
68
- onChange?: (e: any, node: string[]) => void;
68
+ onChange?: (e: any, node: string[] | any) => void;
69
69
  onClick?: (e: React.MouseEvent<HTMLDivElement>, row: TreeNode) => void;
70
70
  onExpand?: (_isExpanded: boolean, node: string) => void;
71
71
  loadMore?: (_direction?: string) => void;
@@ -13,6 +13,7 @@
13
13
 
14
14
  .ff-tab-button {
15
15
  &--default {
16
+ position: relative;
16
17
  border: none;
17
18
  background: none;
18
19
  padding: 0 4px;
@@ -129,4 +130,22 @@
129
130
  .ff-tab-content {
130
131
  width: inherit;
131
132
  }
133
+ .ff-defaultStatus {
134
+ position: absolute;
135
+ top: 2px;
136
+ right: 0px;
137
+ width: 6px;
138
+ height: 6px;
139
+ background-color: transparent;
140
+ border-radius: 50%;
141
+
142
+ &.ff-successStatus {
143
+ background-color: var(--confirm-tick-icon-color);
144
+ box-shadow: 0px 1px 1px 0px var(--toggle-strip-shadow);
145
+ }
146
+ &.ff-dangerStatus {
147
+ background-color: var(--delete-text-color);
148
+ box-shadow: 0px 1px 1px 0px var(--toggle-strip-shadow);
149
+ }
150
+ }
132
151
  }
@@ -58,6 +58,15 @@ const Tabs = ({
58
58
  'ff-tab-bar--active': activeTabId === tab.id,
59
59
  })}
60
60
  ></div>
61
+ <span
62
+ className={`ff-defaultStatus ${
63
+ tab.status === 'success'
64
+ ? 'ff-successStatus'
65
+ : tab.status === 'error'
66
+ ? 'ff-dangerStatus'
67
+ : ''
68
+ }`}
69
+ ></span>
61
70
  </button>
62
71
  ))}
63
72
  </div>
@@ -27,6 +27,7 @@ export interface TabsProps {
27
27
  component?: JSX.Element;
28
28
  disabled?: boolean;
29
29
  count?: number | string;
30
+ status?: 'success' | 'error' | 'transparent';
30
31
  }[];
31
32
  /**
32
33
  * Defines the styling variant of the tabs.
package/src/index.ts CHANGED
@@ -74,6 +74,7 @@ import ProgressBar from './components/ProgressBar';
74
74
  import ChooseFile from './components/ChooseFile/ChooseFile';
75
75
  import ScriptSwitchButton from './components/ScriptSwitchButton';
76
76
 
77
+ import MobileSkin from './components/MobileSkin';
77
78
  // Utils imports
78
79
  import { checkEmpty } from './utils/checkEmpty/checkEmpty';
79
80
  import {
@@ -97,11 +98,13 @@ import { saveFileFromBlob } from './utils/downloadFile/saveFileFromBlob';
97
98
  import { capitalize } from './utils/capitalize/capitalize';
98
99
  import Comments from './components/Comment/Comments';
99
100
  import useFileDropzone from './hooks/useFileDropzone';
101
+ import useClickOutside from './hooks/useClickOutside';
100
102
  import PopUpModal from './components/PopUpModal/PopUpModal';
101
103
  import FormatString from './utils/FormatString/FormatString';
102
104
  import ConditionalDropdown from './components/ConditionalDropdown/ConditionalDropdown';
103
105
  import { hasDuplicateFile } from './utils/checkDuplicates/checkDuplicates';
104
106
  import PhoneInputField from './components/PhoneInput';
107
+ import { useKeyboardActions } from './utils/keyBoardActionUtil/UseKeyboardActions';
105
108
  import {
106
109
  EMAIL_REGEX,
107
110
  URL_REGEX,
@@ -115,6 +118,7 @@ import {
115
118
  ALPHABET_ONLY_REGEX,
116
119
  NUMBERS_ONLY_REGEX,
117
120
  ALPHANUMERIC_REGEX,
121
+ ALPHANUMERIC_WITH_ROUND_BRACES_REGEX,
118
122
  DATE_REGEX,
119
123
  TIME_REGEX,
120
124
  FILE_EXTENSION_REGEX,
@@ -148,6 +152,15 @@ import {
148
152
  CURRENCY_GENERIC_REGEX,
149
153
  LINKEDIN_PROFILE_REGEX,
150
154
  TWITTER_HANDLE_REGEX,
155
+ UNIT_REGEX,
156
+ NUMBER_REGEX,
157
+ MEMORY_VALIDATION_REGEX,
158
+ STEP_GROUP_NAME_REGEX,
159
+ NLP_DESCRIPTION_REGEX,
160
+ FILE_NAME_REGEX,
161
+ ELEMENTS_TRAILING_SPACE_REGEX,
162
+ ELEMENTS_WHITE_SPACE_REGEX,
163
+ PARAMETER_ALPHANUMERIC_REGEX,
151
164
  } from './validations/regex';
152
165
 
153
166
  export {
@@ -235,6 +248,7 @@ export {
235
248
  ProgressBar,
236
249
  ChooseFile,
237
250
  ScriptSwitchButton,
251
+ MobileSkin,
238
252
 
239
253
  // utils exports
240
254
  checkEmpty,
@@ -252,8 +266,11 @@ export {
252
266
  saveFileFromBlob,
253
267
  capitalize,
254
268
  useFileDropzone,
269
+ useClickOutside,
255
270
  FormatString,
256
271
  hasDuplicateFile,
272
+ useKeyboardActions,
273
+
257
274
  EMAIL_REGEX,
258
275
  URL_REGEX,
259
276
  PHONE_REGEX,
@@ -266,6 +283,7 @@ export {
266
283
  ALPHABET_ONLY_REGEX,
267
284
  NUMBERS_ONLY_REGEX,
268
285
  ALPHANUMERIC_REGEX,
286
+ ALPHANUMERIC_WITH_ROUND_BRACES_REGEX,
269
287
  DATE_REGEX,
270
288
  TIME_REGEX,
271
289
  FILE_EXTENSION_REGEX,
@@ -299,4 +317,13 @@ export {
299
317
  CURRENCY_GENERIC_REGEX,
300
318
  LINKEDIN_PROFILE_REGEX,
301
319
  TWITTER_HANDLE_REGEX,
320
+ UNIT_REGEX,
321
+ NUMBER_REGEX,
322
+ MEMORY_VALIDATION_REGEX,
323
+ STEP_GROUP_NAME_REGEX,
324
+ NLP_DESCRIPTION_REGEX,
325
+ FILE_NAME_REGEX,
326
+ ELEMENTS_TRAILING_SPACE_REGEX,
327
+ ELEMENTS_WHITE_SPACE_REGEX,
328
+ PARAMETER_ALPHANUMERIC_REGEX,
302
329
  };
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ import { convertFormDataToObject } from './ConvertFormDataToObject';
3
+
4
+ export default {
5
+ title: 'Utils/convertFormDataToObject',
6
+ component: convertFormDataToObject,
7
+ };
8
+
9
+ export const Default = () => {
10
+ const formData = new FormData();
11
+ formData.append('username', 'Md Imran');
12
+ formData.append('email', 'im@xyz.com');
13
+ formData.append('age', '23');
14
+
15
+ const result = convertFormDataToObject(formData);
16
+
17
+ return (
18
+ <div>
19
+ <h3>Test convertFormDataToObject</h3>
20
+ <pre>
21
+ Convertion to an Array to show existing FormData:
22
+ {JSON.stringify(Array.from(formData.entries()), null, 2)}
23
+ </pre>
24
+ <pre>Result: {JSON.stringify(result, null, 2)}</pre>
25
+ </div>
26
+ );
27
+ };
@@ -0,0 +1,14 @@
1
+ export const convertFormDataToObject = (formData: FormData): Record<string, any> => {
2
+ const obj: Record<string, any> = {};
3
+ formData.forEach((value, key) => {
4
+ if (obj[key]) {
5
+ // If the key already exists, convert it to an array
6
+ obj[key] = Array.isArray(obj[key])
7
+ ? [...obj[key], value]
8
+ : [obj[key], value];
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ });
13
+ return obj;
14
+ };
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { getExtension } from './getExtension';
2
3
 
3
4
  export default {
@@ -0,0 +1,53 @@
1
+ import React, { useState } from 'react';
2
+ import { Meta, StoryObj } from '@storybook/react';
3
+ import { useKeyboardActions } from './UseKeyboardActions';
4
+
5
+ // A demonstration component to showcase the `useKeyboardAction` utility
6
+ const UseKeyboardActionComponent: React.FC = () => {
7
+ const [message, setMessage] = useState<string>(
8
+ 'Press Escape or Enter to see actions.'
9
+ );
10
+
11
+ // Registering keyboard actions using the `useKeyboardAction` utility
12
+ useKeyboardActions([
13
+ {
14
+ key: 'Escape',
15
+ action: () => setMessage('Escape key was pressed.'),
16
+ },
17
+ {
18
+ key: 'Enter',
19
+ action: () => setMessage('Enter key was pressed.'),
20
+ },
21
+ {
22
+ key: 'ArrowUp',
23
+ action: () => setMessage('ArrowUp key was pressed.'),
24
+ },
25
+ ]);
26
+
27
+ return (
28
+ <div
29
+ style={{ textAlign: 'center', padding: '20px', border: '1px solid #ddd' }}
30
+ >
31
+ <h3>Keyboard Action Utility</h3>
32
+ <p>{message}</p>
33
+ <p>Try pressing Escape, Enter, or ArrowUp keys.</p>
34
+ </div>
35
+ );
36
+ };
37
+
38
+ // Meta configuration for the story
39
+ const meta: Meta<typeof UseKeyboardActionComponent> = {
40
+ title: 'Utils/UseKeyboardAction',
41
+ component: UseKeyboardActionComponent,
42
+ parameters: {
43
+ layout: 'centered',
44
+ },
45
+ tags: ['autodocs'],
46
+ };
47
+
48
+ export default meta;
49
+
50
+ type Story = StoryObj<typeof UseKeyboardActionComponent>;
51
+
52
+ // Default story for the component
53
+ export const Primary: Story = {};
@@ -0,0 +1,20 @@
1
+ import { useEffect } from "react";
2
+ import { KeyboardAction } from "./types";
3
+
4
+ export const useKeyboardActions = (actions: KeyboardAction[]) => {
5
+ useEffect(() => {
6
+ const handleKeyDown = (event: KeyboardEvent) => {
7
+ actions.forEach(({ key, action }) => {
8
+ if (event.key === key) {
9
+ action();
10
+ }
11
+ });
12
+ };
13
+
14
+ window.addEventListener('keydown', handleKeyDown);
15
+
16
+ return () => {
17
+ window.removeEventListener('keydown', handleKeyDown);
18
+ };
19
+ }, [actions]);
20
+ };
@@ -0,0 +1,4 @@
1
+ export type KeyboardAction = {
2
+ key: string;
3
+ action: () => void;
4
+ };
@@ -13,6 +13,7 @@ import {
13
13
  ALPHABET_ONLY_REGEX,
14
14
  NUMBERS_ONLY_REGEX,
15
15
  ALPHANUMERIC_REGEX,
16
+ ALPHANUMERIC_WITH_ROUND_BRACES_REGEX,
16
17
  DATE_REGEX,
17
18
  TIME_REGEX,
18
19
  FILE_EXTENSION_REGEX,
@@ -46,6 +47,15 @@ import {
46
47
  CURRENCY_GENERIC_REGEX,
47
48
  LINKEDIN_PROFILE_REGEX,
48
49
  TWITTER_HANDLE_REGEX,
50
+ NUMBER_REGEX,
51
+ UNIT_REGEX,
52
+ MEMORY_VALIDATION_REGEX,
53
+ STEP_GROUP_NAME_REGEX,
54
+ NLP_DESCRIPTION_REGEX,
55
+ FILE_NAME_REGEX,
56
+ ELEMENTS_TRAILING_SPACE_REGEX,
57
+ ELEMENTS_WHITE_SPACE_REGEX,
58
+ PARAMETER_ALPHANUMERIC_REGEX,
49
59
  } from './regex';
50
60
 
51
61
  export default {
@@ -119,6 +129,12 @@ export const Playground = () => {
119
129
  regex: ALPHANUMERIC_REGEX,
120
130
  description: 'Validates alphanumeric values (e.g. abc123)',
121
131
  },
132
+
133
+ {
134
+ name: 'ALPHANUMERIC_WITH_ROUND_BRACES_REGEX',
135
+ regex: ALPHANUMERIC_WITH_ROUND_BRACES_REGEX,
136
+ description: 'Validates alphanumeric values with Underscore and RoundBraces Inclusive (e.g. abc123()_)',
137
+ },
122
138
  {
123
139
  name: 'DATE_REGEX',
124
140
  regex: DATE_REGEX,
@@ -287,8 +303,55 @@ export const Playground = () => {
287
303
  regex: TWITTER_HANDLE_REGEX,
288
304
  description: 'Validates Twitter handle (e.g. @username)',
289
305
  },
306
+ {
307
+ name: 'NUMBER_REGEX',
308
+ regex: NUMBER_REGEX,
309
+ description: 'Validates a number (integer or float)',
310
+ },
311
+ {
312
+ name: 'UNIT_REGEX',
313
+ regex: UNIT_REGEX,
314
+ description: 'Validates a string of letters (unit)',
315
+ },
316
+ {
317
+ name: 'MEMORY_VALIDATION_REGEX',
318
+ regex: MEMORY_VALIDATION_REGEX,
319
+ description: 'Regular expression to match a number with an optional unit (GB, MB, or KB)',
320
+ },{
321
+ name: 'STEP_GROUP_NAME_REGEX',
322
+ regex: STEP_GROUP_NAME_REGEX,
323
+ description:
324
+ 'Step group name accept only ( ,) ,-,_ special characters(e.g,step-group_one(test))',
325
+ },
326
+ {
327
+ name: 'NLP_DESCRIPTION_REGEX',
328
+ regex: NLP_DESCRIPTION_REGEX,
329
+ description:
330
+ 'NLP Description should allow _ and $ only (e.g ,$nlpName_test)',
331
+ },
332
+ {
333
+ name: 'FILE_NAME_REGEX',
334
+ regex: FILE_NAME_REGEX,
335
+ description: `It should include a valid file extension (e.g.,'.txt', '.jpg') without special characters like '@' or multiple dots after the extension.`,
336
+ },
337
+ {
338
+ name: 'ELEMENTS_TRAILING_SPACE_REGEX',
339
+ regex: ELEMENTS_TRAILING_SPACE_REGEX,
340
+ description: `Element Name should not have space in the initial and end.`,
341
+ },
342
+ {
343
+ name: 'ELEMENTS_WHITE_SPACE_REGEX',
344
+ regex: ELEMENTS_WHITE_SPACE_REGEX,
345
+ description: `Elements name should not have only white space.`,
346
+ },
347
+ {
348
+ name: 'PARAMETER_ALPHANUMERIC_REGEX,',
349
+ regex: PARAMETER_ALPHANUMERIC_REGEX,
350
+ description: `Parameter name should be alphanumeric.`,
351
+ },
290
352
  ];
291
353
 
354
+
292
355
  const validateInput = () => {
293
356
  const validator = validators.find(
294
357
  (validator) => validator.name === selectedRegex
@@ -38,6 +38,9 @@ const NUMBERS_ONLY_REGEX = /^\d+$/;
38
38
  // Alphanumeric Validation
39
39
  const ALPHANUMERIC_REGEX = /^[A-Za-z0-9]+$/;
40
40
 
41
+ //Alphanumeric Validation With Round Braces and Underscore Inclusive (Used to validate Manual and Automation Script Names )
42
+ const ALPHANUMERIC_WITH_ROUND_BRACES_REGEX = /^[a-zA-Z0-9-_() ]*$/;
43
+
41
44
  // Date Validation (YYYY-MM-DD)
42
45
  const DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
43
46
 
@@ -145,6 +148,27 @@ const LINKEDIN_PROFILE_REGEX =
145
148
  // Twitter Handle Validation
146
149
  const TWITTER_HANDLE_REGEX = /^@?([a-zA-Z0-9_]{1,15})$/;
147
150
 
151
+ //Match a number (integer or float)
152
+ const NUMBER_REGEX = /([0-9\.]+)/;
153
+
154
+ //Match a string of letters (unit)
155
+ const UNIT_REGEX = /[a-zA-Z]+/;
156
+
157
+ //Regular expression to match a number with an optional unit (GB, MB, or KB)
158
+ const MEMORY_VALIDATION_REGEX = /^(\d+\.?\d*)\s*(GB|MB|KB)?$/i;
159
+ const STEP_GROUP_NAME_REGEX = /^[a-zA-Z0-9()\-_ ]+$/;
160
+
161
+ const NLP_DESCRIPTION_REGEX = /^[a-zA-Z0-9_$\s]*$/;
162
+
163
+ const FILE_NAME_REGEX = /\.([^.@]+)$/;
164
+
165
+ const ELEMENTS_TRAILING_SPACE_REGEX = /^\S.*\S$/;
166
+
167
+ const ELEMENTS_WHITE_SPACE_REGEX = /.*\S.*/;
168
+
169
+ const PARAMETER_ALPHANUMERIC_REGEX =
170
+ /^[-_A-Za-z0-9 ]*$|^[-_A-Za-z0-9 ][A-Za-z0-9 ]*[-_A-Za-z-_]$/;
171
+
148
172
  export {
149
173
  EMAIL_REGEX,
150
174
  URL_REGEX,
@@ -158,6 +182,7 @@ export {
158
182
  ALPHABET_ONLY_REGEX,
159
183
  NUMBERS_ONLY_REGEX,
160
184
  ALPHANUMERIC_REGEX,
185
+ ALPHANUMERIC_WITH_ROUND_BRACES_REGEX,
161
186
  DATE_REGEX,
162
187
  TIME_REGEX,
163
188
  FILE_EXTENSION_REGEX,
@@ -191,4 +216,13 @@ export {
191
216
  CURRENCY_GENERIC_REGEX,
192
217
  LINKEDIN_PROFILE_REGEX,
193
218
  TWITTER_HANDLE_REGEX,
219
+ UNIT_REGEX,
220
+ NUMBER_REGEX,
221
+ MEMORY_VALIDATION_REGEX,
222
+ STEP_GROUP_NAME_REGEX,
223
+ NLP_DESCRIPTION_REGEX,
224
+ FILE_NAME_REGEX,
225
+ ELEMENTS_TRAILING_SPACE_REGEX,
226
+ ELEMENTS_WHITE_SPACE_REGEX,
227
+ PARAMETER_ALPHANUMERIC_REGEX,
194
228
  };
Binary file