pixel-react 1.4.3 → 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (263) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/lib/StyleGuide/ColorPalette/ColorPalette.stories.d.ts +6 -0
  3. package/lib/StyleGuide/Typography/Typography.stories.d.ts +6 -0
  4. package/lib/components/Accordion/Accordion.stories.d.ts +6 -0
  5. package/lib/components/AddButton/AddButton.d.ts +5 -0
  6. package/lib/components/AddButton/AddButton.stories.d.ts +6 -0
  7. package/lib/components/AddButton/index.d.ts +1 -0
  8. package/lib/components/AddButton/types.d.ts +4 -0
  9. package/lib/components/AddResourceButton/AddButton.stories.d.ts +8 -0
  10. package/lib/components/AddResourceButton/type.d.ts +1 -1
  11. package/lib/components/AllProjectsDropdown/AllProjectsDropdown.stories.d.ts +7 -0
  12. package/lib/components/AppHeader/AppHeader.stories.d.ts +7 -0
  13. package/lib/components/AttachImage/AttachImage.stories.d.ts +7 -0
  14. package/lib/components/AttachmentButton/AttachmentButton.stories.d.ts +9 -0
  15. package/lib/components/Avatar/Avatar.stories.d.ts +10 -0
  16. package/lib/components/Button/Button.stories.d.ts +13 -0
  17. package/lib/components/Charts/BarChart/BarChart.stories.d.ts +6 -0
  18. package/lib/components/Charts/DashboardDonutChart/DashboardDonutChart.stories.d.ts +7 -0
  19. package/lib/components/Charts/DonutChart/DonutChart.stories.d.ts +6 -0
  20. package/lib/components/Charts/IconRadialChart/IconRadialChart.stories.d.ts +8 -0
  21. package/lib/components/Charts/LineChart/LineChart.stories.d.ts +7 -0
  22. package/lib/components/Charts/MultiRadialChart/MultiRadialChart.stories.d.ts +8 -0
  23. package/lib/components/Charts/PieChart/PieChart.stories.d.ts +7 -0
  24. package/lib/components/Charts/RadialChart/RadialChart.stories.d.ts +6 -0
  25. package/lib/components/Checkbox/Checkbox.stories.d.ts +8 -0
  26. package/lib/components/Chip/Chip.stories.d.ts +14 -0
  27. package/lib/components/ConnectingBranch/ConnectingBranch.stories.d.ts +6 -0
  28. package/lib/components/DatePicker/DatePicker.stories.d.ts +9 -0
  29. package/lib/components/DragAndDrop/DragAndDrop.stories.d.ts +6 -0
  30. package/lib/components/Drawer/Drawer.stories.d.ts +12 -0
  31. package/lib/components/Drawer/Types.d.ts +4 -0
  32. package/lib/components/EditTextField/EditTextField.stories.d.ts +10 -0
  33. package/lib/components/Editor/Editor.d.ts +1 -2
  34. package/lib/components/Editor/Editor.stories.d.ts +6 -0
  35. package/lib/components/Editor/types.d.ts +1 -5
  36. package/lib/components/Excel/ExcelContextMenu/ExcelContextMenu.d.ts +13 -0
  37. package/lib/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.d.ts +0 -13
  38. package/lib/components/Excel/ExcelFile/ExcelFileComponents/actions.d.ts +29 -1
  39. package/lib/components/Excel/ExcelFile/ExcelFileComponents/engine/engine.d.ts +3 -9
  40. package/lib/components/Excel/ExcelFile/ExcelFileComponents/engine/formula.d.ts +2 -10
  41. package/lib/components/Excel/ExcelFile/ExcelFileComponents/engine/point-graph.d.ts +0 -1
  42. package/lib/components/Excel/ExcelFile/ExcelFileComponents/types.d.ts +27 -2
  43. package/lib/components/Excel/ExcelFile.stories.d.ts +6 -0
  44. package/lib/components/ExcelFile/ChangeExcelStyles.d.ts +14 -0
  45. package/lib/components/ExcelFile/ColorBarselector/ColorBarSelector.d.ts +8 -0
  46. package/lib/components/ExcelFile/ContextMenu/ContextMenu.d.ts +4 -0
  47. package/lib/components/ExcelFile/ExcelFile/Excel/ActiveCell.d.ts +7 -0
  48. package/lib/components/ExcelFile/ExcelFile/Excel/Cell.d.ts +4 -0
  49. package/lib/components/ExcelFile/ExcelFile/Excel/ColumnIndicator.d.ts +5 -0
  50. package/lib/components/ExcelFile/ExcelFile/Excel/Copied.d.ts +3 -0
  51. package/lib/components/ExcelFile/ExcelFile/Excel/CornerIndicator.d.ts +5 -0
  52. package/lib/components/ExcelFile/ExcelFile/Excel/DataEditor.d.ts +5 -0
  53. package/lib/components/ExcelFile/ExcelFile/Excel/DataViewer.d.ts +8 -0
  54. package/lib/components/ExcelFile/ExcelFile/Excel/FloatingRect.d.ts +10 -0
  55. package/lib/components/ExcelFile/ExcelFile/Excel/HeaderRow.d.ts +3 -0
  56. package/lib/components/ExcelFile/ExcelFile/Excel/Row.d.ts +3 -0
  57. package/lib/components/ExcelFile/ExcelFile/Excel/RowIndicator.d.ts +5 -0
  58. package/lib/components/ExcelFile/ExcelFile/Excel/Selected.d.ts +3 -0
  59. package/lib/components/ExcelFile/ExcelFile/Excel/Spreadsheet.d.ts +81 -0
  60. package/lib/components/ExcelFile/ExcelFile/Excel/Table.d.ts +3 -0
  61. package/lib/components/ExcelFile/ExcelFile/Excel/actions.d.ts +130 -0
  62. package/lib/components/ExcelFile/ExcelFile/Excel/areModelsEqual.d.ts +1 -0
  63. package/lib/components/ExcelFile/ExcelFile/Excel/context.d.ts +8 -0
  64. package/lib/components/ExcelFile/ExcelFile/Excel/engine/engine.d.ts +22 -0
  65. package/lib/components/ExcelFile/ExcelFile/Excel/engine/formula.d.ts +17 -0
  66. package/lib/components/ExcelFile/ExcelFile/Excel/engine/index.d.ts +2 -0
  67. package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-graph.d.ts +21 -0
  68. package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-hash.d.ts +3 -0
  69. package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-set.d.ts +24 -0
  70. package/lib/components/ExcelFile/ExcelFile/Excel/index.d.ts +13 -0
  71. package/lib/components/ExcelFile/ExcelFile/Excel/matrix.d.ts +67 -0
  72. package/lib/components/ExcelFile/ExcelFile/Excel/point-range.d.ts +22 -0
  73. package/lib/components/ExcelFile/ExcelFile/Excel/point.d.ts +11 -0
  74. package/lib/components/ExcelFile/ExcelFile/Excel/reducer.d.ts +27 -0
  75. package/lib/components/ExcelFile/ExcelFile/Excel/selection.d.ts +95 -0
  76. package/lib/components/ExcelFile/ExcelFile/Excel/types.d.ts +215 -0
  77. package/lib/components/ExcelFile/ExcelFile/Excel/use-dispatch.d.ts +3 -0
  78. package/lib/components/ExcelFile/ExcelFile/Excel/use-selector.d.ts +3 -0
  79. package/lib/components/ExcelFile/ExcelFile/Excel/util.d.ts +45 -0
  80. package/lib/components/ExcelFile/ExcelFile/ExcelFile.d.ts +3 -0
  81. package/lib/components/ExcelFile/ExcelFile.stories.d.ts +6 -0
  82. package/lib/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.d.ts +15 -0
  83. package/lib/components/ExcelFile/ExcelToolBar/ExcelToolBar.d.ts +3 -0
  84. package/lib/components/ExcelFile/ImportExcelStyles.d.ts +24 -0
  85. package/lib/components/ExcelFile/Types.d.ts +176 -0
  86. package/lib/components/ExcelFile/index.d.ts +1 -0
  87. package/lib/components/ExpandableMenu/ExpandableMenu.stories.d.ts +7 -0
  88. package/lib/components/FF_Captcha/captcha.stories.d.ts +8 -0
  89. package/lib/components/FileDropzone/FileDropzone.stories.d.ts +8 -0
  90. package/lib/components/Form/Form.stories.d.ts +7 -0
  91. package/lib/components/Form/Forms.d.ts +4 -2
  92. package/lib/components/GridLayout/GridLayout.stories.d.ts +8 -0
  93. package/lib/components/HighlightText/HighlightText.stories.d.ts +6 -0
  94. package/lib/components/Icon/Icon.stories.d.ts +8 -0
  95. package/lib/components/IconButton/IconButton.stories.d.ts +7 -0
  96. package/lib/components/IconRadioGroup/IconRadioGroup.stories.d.ts +7 -0
  97. package/lib/components/Input/Input.stories.d.ts +9 -0
  98. package/lib/components/InputWithDropdown/InputWithDropdown.d.ts +1 -1
  99. package/lib/components/InputWithDropdown/InputWithDropdown.stories.d.ts +9 -0
  100. package/lib/components/LabelEditTextField/LabelEditTextField.stories.d.ts +13 -0
  101. package/lib/components/LazyLoad/LazyLoad.stories.d.ts +6 -0
  102. package/lib/components/MachineInputField/MachineInputField.stories.d.ts +6 -0
  103. package/lib/components/MenuOption/MenuOption.d.ts +1 -1
  104. package/lib/components/MenuOption/MenuOption.stories.d.ts +16 -0
  105. package/lib/components/MenuOption/types.d.ts +49 -15
  106. package/lib/components/MiniModal/MiniModal.stories.d.ts +10 -0
  107. package/lib/components/Modal/Modal.stories.d.ts +7 -0
  108. package/lib/components/ModulesChip/ModuleChip.stories.d.ts +6 -0
  109. package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
  110. package/lib/components/MultiSelect/MultiSelect.stories.d.ts +12 -0
  111. package/lib/components/MultiSelect/MultiSelectTypes.d.ts +4 -5
  112. package/lib/components/MultiSelect/dropdownTypes.d.ts +2 -0
  113. package/lib/components/NLPInput/NlpInput.stories.d.ts +7 -0
  114. package/lib/components/Paper/Paper.stories.d.ts +11 -0
  115. package/lib/components/RadioButton/RadioButton.d.ts +1 -0
  116. package/lib/components/RadioButton/RadioButton.stories.d.ts +10 -0
  117. package/lib/components/RadioButton/radioButtonTypes.d.ts +3 -1
  118. package/lib/components/RadioGroup/RadioGroup.stories.d.ts +9 -0
  119. package/lib/components/Search/Search.stories.d.ts +6 -0
  120. package/lib/components/Select/Select.stories.d.ts +14 -0
  121. package/lib/components/Select/components/Dropdown/Dropdown.d.ts +4 -0
  122. package/lib/components/Select/components/Dropdown/dropdownTypes.d.ts +17 -0
  123. package/lib/components/Select/components/types.d.ts +4 -2
  124. package/lib/components/SequentialConnectingBranch/SequentialConnectingBranch.stories.d.ts +6 -0
  125. package/lib/components/StateDropdown/StateDropdown.stories.d.ts +10 -0
  126. package/lib/components/StatusButton/StatusButton.stories.d.ts +14 -0
  127. package/lib/components/StatusCard/StatusCard.stories.d.ts +11 -0
  128. package/lib/components/Table/Table.d.ts +1 -1
  129. package/lib/components/Table/Table.stories.d.ts +13 -0
  130. package/lib/components/TableTree/TableTree.stories.d.ts +7 -0
  131. package/lib/components/Tabs/Tabs.stories.d.ts +9 -0
  132. package/lib/components/TextArea/Textarea.stories.d.ts +9 -0
  133. package/lib/components/Toast/Toast.stories.d.ts +6 -0
  134. package/lib/components/Toastify/Toastify.stories.d.ts +6 -0
  135. package/lib/components/Toggle/Toggle.stories.d.ts +12 -0
  136. package/lib/components/ToggleSwitch/ToggleSwitch.d.ts +10 -0
  137. package/lib/components/ToggleSwitch/index.d.ts +1 -0
  138. package/lib/components/Tooltip/Tooltip.stories.d.ts +15 -0
  139. package/lib/components/Typography/Typography.stories.d.ts +10 -0
  140. package/lib/components/VariableInput/VariableInput.stories.d.ts +6 -0
  141. package/lib/index.d.ts +140 -29
  142. package/lib/index.esm.js +15628 -5724
  143. package/lib/index.esm.js.map +1 -1
  144. package/lib/index.js +15625 -5718
  145. package/lib/index.js.map +1 -1
  146. package/lib/tsconfig.tsbuildinfo +1 -1
  147. package/lib/utils/checkEmpty/checkEmpty.stories.d.ts +6 -0
  148. package/lib/utils/compareArrays/compareArrays.stories.d.ts +6 -0
  149. package/lib/utils/compareObjects/compareObjects.stories.d.ts +6 -0
  150. package/lib/utils/debounce/debounce.stories.d.ts +6 -0
  151. package/lib/utils/ffID/ffID.stories.d.ts +6 -0
  152. package/lib/utils/find/findAndInsert.d.ts +7 -0
  153. package/lib/utils/find/findAndInsert.stories.d.ts +7 -0
  154. package/lib/utils/findAndInsert/findAndInsert.stories.d.ts +7 -0
  155. package/lib/utils/getEncryptedData/getEncryptedData.stories.d.ts +6 -0
  156. package/lib/utils/getExtension/getExtension.stories.d.ts +6 -0
  157. package/lib/utils/getSequentialPayload/getSequentialPayload.stories.d.ts +10 -0
  158. package/lib/utils/throttle/throttle.stories.d.ts +6 -0
  159. package/lib/utils/truncateText/truncateText.stories.d.ts +6 -0
  160. package/package.json +12 -12
  161. package/src/StyleGuide/ColorPalette/colorPaletteList.ts +10 -0
  162. package/src/assets/Themes/BaseTheme.scss +17 -23
  163. package/src/assets/Themes/DarkTheme.scss +25 -38
  164. package/src/assets/icons/apk_file_type.svg +4 -0
  165. package/src/assets/icons/compressed_file_type.svg +4 -0
  166. package/src/assets/icons/csv_file_type.svg +4 -0
  167. package/src/assets/icons/excel_corner_menu.svg +3 -0
  168. package/src/assets/icons/formula_icon.svg +3 -0
  169. package/src/assets/icons/gif_file_type.svg +4 -0
  170. package/src/assets/icons/html_file_type.svg +4 -0
  171. package/src/assets/icons/ipk_file_type.svg +4 -0
  172. package/src/assets/icons/jpg_file_type.svg +4 -0
  173. package/src/assets/icons/json_file_type.svg +4 -0
  174. package/src/assets/icons/pdf_file_type.svg +4 -0
  175. package/src/assets/icons/png_file_type.svg +4 -0
  176. package/src/assets/icons/quick_run_setting_icon.svg +5 -0
  177. package/src/assets/icons/run_automation_scripts_icon.svg +33 -0
  178. package/src/assets/icons/run_manual_testcase_icon.svg +4 -0
  179. package/src/assets/icons/search.svg +2 -2
  180. package/src/assets/icons/txt_file_type.svg +4 -0
  181. package/src/assets/icons/xls_file_type.svg +4 -0
  182. package/src/assets/icons/xlsx_file_type.svg +4 -0
  183. package/src/assets/icons/xml_file_type.svg +4 -0
  184. package/src/components/AddResourceButton/AddButton.tsx +7 -7
  185. package/src/components/AddResourceButton/type.ts +1 -1
  186. package/src/components/AttachmentButton/AttachmentButton.scss +1 -1
  187. package/src/components/AttachmentButton/AttachmentButton.stories.tsx +1 -0
  188. package/src/components/Button/Button.scss +22 -20
  189. package/src/components/Button/Button.tsx +8 -1
  190. package/src/components/Drawer/Drawer.scss +4 -3
  191. package/src/components/Drawer/Drawer.tsx +14 -18
  192. package/src/components/Drawer/Types.ts +4 -0
  193. package/src/components/Editor/Editor.tsx +224 -193
  194. package/src/components/Editor/types.ts +1 -5
  195. package/src/components/Excel/ExcelContextMenu/ExcelContextMenu.scss +39 -0
  196. package/src/components/Excel/ExcelContextMenu/ExcelContextMenu.tsx +51 -0
  197. package/src/components/Excel/ExcelFile/ExcelFile.tsx +7 -8
  198. package/src/components/Excel/ExcelFile/ExcelFileComponents/Cell.tsx +35 -0
  199. package/src/components/Excel/ExcelFile/ExcelFileComponents/ColumnIndicator.tsx +44 -7
  200. package/src/components/Excel/ExcelFile/ExcelFileComponents/CornerIndicator.tsx +8 -1
  201. package/src/components/Excel/ExcelFile/ExcelFileComponents/RowIndicator.tsx +45 -6
  202. package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.scss +37 -2
  203. package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.tsx +69 -24
  204. package/src/components/Excel/ExcelFile/ExcelFileComponents/actions.ts +59 -0
  205. package/src/components/Excel/ExcelFile/ExcelFileComponents/engine/engine.ts +18 -65
  206. package/src/components/Excel/ExcelFile/ExcelFileComponents/engine/formula.ts +5 -110
  207. package/src/components/Excel/ExcelFile/ExcelFileComponents/engine/point-graph.ts +0 -2
  208. package/src/components/Excel/ExcelFile/ExcelFileComponents/reducer.ts +105 -1
  209. package/src/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.ts +670 -673
  210. package/src/components/Excel/ExcelFile/ExcelFileComponents/types.ts +38 -2
  211. package/src/components/Excel/ExcelToolBar/ExcelToolBar.tsx +0 -4
  212. package/src/components/FileDropzone/FileDropzone.scss +4 -2
  213. package/src/components/FileDropzone/FileDropzone.tsx +1 -1
  214. package/src/components/FileDropzone/FilePreview.tsx +3 -1
  215. package/src/components/Form/Form.scss +2 -0
  216. package/src/components/Form/Form.stories.tsx +195 -6
  217. package/src/components/Form/Forms.tsx +15 -8
  218. package/src/components/Icon/iconList.ts +46 -0
  219. package/src/components/IconRadioGroup/IconRadioGroup.scss +3 -0
  220. package/src/components/IconRadioGroup/IconRadioGroup.tsx +20 -17
  221. package/src/components/Input/Input.scss +14 -15
  222. package/src/components/Input/Input.stories.tsx +2 -1
  223. package/src/components/InputWithDropdown/InputWithDropdown.scss +12 -13
  224. package/src/components/InputWithDropdown/InputWithDropdown.stories.tsx +3 -2
  225. package/src/components/InputWithDropdown/InputWithDropdown.tsx +22 -19
  226. package/src/components/MenuOption/MenuOption.scss +11 -10
  227. package/src/components/MenuOption/MenuOption.stories.tsx +51 -232
  228. package/src/components/MenuOption/MenuOption.tsx +131 -52
  229. package/src/components/MenuOption/types.ts +55 -14
  230. package/src/components/MiniModal/MiniModal.stories.tsx +2 -3
  231. package/src/components/MultiSelect/Dropdown.tsx +11 -12
  232. package/src/components/MultiSelect/MultiSelect.scss +1 -0
  233. package/src/components/MultiSelect/MultiSelect.stories.tsx +45 -10
  234. package/src/components/MultiSelect/MultiSelect.tsx +29 -13
  235. package/src/components/MultiSelect/MultiSelectTypes.ts +7 -5
  236. package/src/components/MultiSelect/dropdownTypes.ts +2 -0
  237. package/src/components/RadioButton/RadioButton.scss +3 -1
  238. package/src/components/RadioButton/RadioButton.tsx +3 -1
  239. package/src/components/RadioButton/radioButtonTypes.tsx +5 -1
  240. package/src/components/Search/Search.scss +25 -6
  241. package/src/components/Search/Search.tsx +45 -24
  242. package/src/components/Select/Select.scss +12 -12
  243. package/src/components/Select/Select.stories.tsx +2 -0
  244. package/src/components/Select/Select.tsx +11 -5
  245. package/src/components/Select/components/Dropdown.scss +2 -0
  246. package/src/components/Select/components/Dropdown.tsx +19 -4
  247. package/src/components/Select/components/types.ts +4 -2
  248. package/src/components/StatusButton/StatusButton.tsx +26 -20
  249. package/src/components/Table/Table.scss +1 -3
  250. package/src/components/Table/Table.stories.tsx +1 -0
  251. package/src/components/Table/Table.tsx +7 -3
  252. package/src/components/ToggleSwitch/ToggleSwitch.scss +59 -0
  253. package/src/components/ToggleSwitch/ToggleSwitch.stories.tsx +52 -0
  254. package/src/components/ToggleSwitch/ToggleSwitch.tsx +30 -0
  255. package/src/components/ToggleSwitch/index.ts +1 -0
  256. package/src/hooks/useFileDropzone.tsx +1 -0
  257. package/src/index.ts +7 -3
  258. package/lib/assets/fonts/Poppins-Bold.ttf +0 -0
  259. package/lib/assets/fonts/Poppins-Medium.ttf +0 -0
  260. package/lib/assets/fonts/Poppins-Regular.ttf +0 -0
  261. package/lib/assets/fonts/Poppins-SemiBold.ttf +0 -0
  262. package/src/components/Excel/ContextMenu/ContextMenu.scss +0 -99
  263. package/src/components/Excel/ContextMenu/ContextMenu.tsx +0 -103
@@ -1,4 +1,4 @@
1
- import { useState, useRef } from 'react';
1
+ import { useState, useRef, useContext, useEffect } from 'react';
2
2
  import './MenuOption.scss';
3
3
  import Icon from '../Icon';
4
4
  import classNames from 'classnames';
@@ -9,8 +9,10 @@ import {
9
9
  MenuOptionProps,
10
10
  OptionClick,
11
11
  } from './types';
12
- import useClickOutside from '../../hooks/useClickOutside';
13
12
  import Typography from '../Typography';
13
+ import { createPortal } from 'react-dom';
14
+ import { ThemeContext } from '../ThemeProvider/ThemeProvider';
15
+ import useClickOutside from '../../hooks/useClickOutside';
14
16
 
15
17
  const Option = ({ option, onClick }: OptionProps) => (
16
18
  <div
@@ -19,7 +21,14 @@ const Option = ({ option, onClick }: OptionProps) => (
19
21
  })}
20
22
  onClick={() => !option.disable && onClick(option)}
21
23
  >
22
- {option.icon && <Icon name={option.icon} height={16} width={16} />}
24
+ {option.icon && (
25
+ <Icon
26
+ name={option.icon}
27
+ color={option.iconColor}
28
+ height={16}
29
+ width={16}
30
+ />
31
+ )}
23
32
  <Typography
24
33
  as="label"
25
34
  color={option.icon === 'delete' ? 'var(--delete-text-color)' : ''}
@@ -29,13 +38,72 @@ const Option = ({ option, onClick }: OptionProps) => (
29
38
  </div>
30
39
  );
31
40
 
32
- const OptionCard = ({ options, onClick, styles }: OptionCardProps) => {
33
- return (
34
- <div className="ff-option-card" style={styles}>
35
- {options.map((opt) => (
36
- <Option key={opt.label} option={opt} onClick={onClick} />
37
- ))}
38
- </div>
41
+ const OptionCard = ({
42
+ options,
43
+ onClick,
44
+ menuPosition,
45
+ menuRef,
46
+ closeDropdown,
47
+ zIndex,
48
+ dropdownPosition,
49
+ }: OptionCardProps) => {
50
+ const themeContext = useContext(ThemeContext);
51
+ const currentTheme = themeContext?.currentTheme;
52
+ const [optionsHeight, setOptionsHeight] = useState(0);
53
+ const optionCardRef = useRef<HTMLDivElement>(null);
54
+
55
+ useEffect(() => {
56
+ if (optionCardRef?.current) {
57
+ const rect = optionCardRef?.current?.getBoundingClientRect();
58
+ setOptionsHeight(rect?.height);
59
+ }
60
+ }, []);
61
+
62
+ useClickOutside(menuRef, closeDropdown, [optionCardRef]);
63
+
64
+ const style = (() => {
65
+ switch (dropdownPosition) {
66
+ case 'top':
67
+ return {
68
+ top: menuPosition.top - optionsHeight - 7,
69
+ left: menuPosition.rightSpaceAvailable + 12,
70
+ };
71
+ case 'down':
72
+ return {
73
+ top: menuPosition.bottom,
74
+ left: menuPosition.rightSpaceAvailable + 12,
75
+ };
76
+ case 'left':
77
+ return {
78
+ top: menuPosition.top,
79
+ right: menuPosition.rightSpaceAvailable + 35,
80
+ };
81
+ case 'right':
82
+ return {
83
+ top: menuPosition.top,
84
+ left: menuPosition.rightSpaceAvailable + 35,
85
+ };
86
+ default:
87
+ return {
88
+ top: menuPosition.bottom,
89
+ left: menuPosition.rightSpaceAvailable + 12,
90
+ };
91
+ }
92
+ })();
93
+
94
+ return createPortal(
95
+ <div
96
+ className={classNames('ff-option-card', currentTheme)}
97
+ ref={optionCardRef}
98
+ style={{ ...style, zIndex }}
99
+ >
100
+ <div className="ff-option-wrapper">
101
+ {options.map((opt) => (
102
+ <Option key={opt.label} option={opt} onClick={onClick} />
103
+ ))}
104
+ </div>
105
+ </div>,
106
+ document.body
39
107
  );
40
108
  };
41
109
 
@@ -45,18 +113,27 @@ const MenuOption = ({
45
113
  tooltipTitle,
46
114
  tooltipPlacement = 'bottom',
47
115
  options = [],
48
- dropdownPlacement = 'down',
49
116
  onClick = () => {},
50
117
  onOptionClick = () => {},
51
118
  iconButtonSize = 20,
52
119
  iconButtonBorderRadius = 7,
53
120
  iconSize = 16,
54
121
  variant = 'light',
55
- zIndex=1000,
122
+ zIndex = 99,
123
+ dropdownPlacement = 'down',
56
124
  }: MenuOptionProps) => {
57
125
  const [isClicked, setIsClicked] = useState(false);
58
126
  const menuRef = useRef<HTMLDivElement>(null);
59
-
127
+ const [menuPosition, setMenuPosition] = useState({
128
+ top: 0,
129
+ bottom: 0,
130
+ height: 0,
131
+ fromBottom: 0,
132
+ rightSpaceAvailable: 0,
133
+ });
134
+ useEffect(() => {
135
+ calculateDims();
136
+ });
60
137
  const closeDropDown = () => setIsClicked(false);
61
138
 
62
139
  const onIconClickHandler = () => {
@@ -69,59 +146,61 @@ const MenuOption = ({
69
146
  closeDropDown();
70
147
  };
71
148
 
72
- const dropdownPositionStyles = () => {
73
- switch (dropdownPlacement) {
74
- case 'top':
75
- return { bottom: '100%', left: -2 ,zIndex};
76
- case 'left':
77
- return { top: -2, right: '100%' ,zIndex};
78
- case 'right':
79
- return { top: -2, left: '100%' ,zIndex};
80
- case 'down':
81
- default:
82
- return { top: '100%', left: -2 ,zIndex};
149
+ const calculateDims = () => {
150
+ if (menuRef?.current) {
151
+ const rect = menuRef.current.getBoundingClientRect();
152
+
153
+ setMenuPosition({
154
+ top: rect.top,
155
+ height: rect.height,
156
+ rightSpaceAvailable: document.body.clientWidth - rect.right,
157
+ bottom: rect.bottom,
158
+ fromBottom: window.innerHeight - rect.bottom,
159
+ });
83
160
  }
84
161
  };
85
162
 
86
- useClickOutside(menuRef, closeDropDown);
87
-
88
163
  return (
89
164
  <div className="ff-menu-option-container" ref={menuRef}>
90
165
  <Tooltip title={tooltipTitle} placement={tooltipPlacement}>
91
166
  <div className="ff-icon-label">
92
- <div
93
- className={classNames('ff-menuicon-container', {
94
- 'ff-menuicon-container-clicked': isClicked,
95
- dark: variant === 'dark',
96
- })}
97
- onClick={onIconClickHandler}
98
- style={{
99
- width: `${iconButtonSize}px`,
100
- height: `${iconButtonSize}px`,
101
- borderRadius: `${iconButtonBorderRadius}px`,
102
- display: 'flex',
103
- flexDirection: 'column',
104
- }}
105
- >
106
- <Icon
107
- height={iconSize}
108
- width={iconSize}
109
- name={iconName}
110
- color={
111
- isClicked === (variant === 'dark')
112
- ? 'var(--menu-option-icon-clicked)'
113
- : 'var(--menu-option-icon-color)'
114
- }
115
- />
167
+ <div
168
+ className={classNames('ff-menuicon-container', {
169
+ 'ff-menuicon-container-clicked': isClicked,
170
+ dark: variant === 'dark',
171
+ })}
172
+ onClick={onIconClickHandler}
173
+ style={{
174
+ width: `${iconButtonSize}px`,
175
+ height: `${iconButtonSize}px`,
176
+ borderRadius: `${iconButtonBorderRadius}px`,
177
+ display: 'flex',
178
+ flexDirection: 'column',
179
+ }}
180
+ >
181
+ <Icon
182
+ height={iconSize}
183
+ width={iconSize}
184
+ name={iconName}
185
+ color={
186
+ isClicked === (variant === 'dark')
187
+ ? 'var(--menu-option-icon-clicked)'
188
+ : 'var(--menu-option-icon-color)'
189
+ }
190
+ />
116
191
  </div>
117
- {labelName && <Typography as="label">{labelName} </Typography>}
192
+ {labelName && <Typography as="label">{labelName}</Typography>}
118
193
  </div>
119
194
  </Tooltip>
120
195
  {isClicked && (
121
196
  <OptionCard
122
197
  options={options}
123
198
  onClick={handleOptionClick}
124
- styles={dropdownPositionStyles()}
199
+ menuPosition={menuPosition}
200
+ menuRef={menuRef}
201
+ closeDropdown={closeDropDown}
202
+ zIndex={zIndex}
203
+ dropdownPosition={dropdownPlacement}
125
204
  />
126
205
  )}
127
206
  </div>
@@ -11,17 +11,21 @@ interface OptionClick {
11
11
  * @type {Array<string> | string}
12
12
  * @required
13
13
  */
14
- value: Array<string> | string;
14
+ value: any;
15
15
  }
16
16
 
17
17
  interface OptionType extends OptionClick {
18
18
  /**
19
19
  * The name of the icon associated with the option.
20
20
  * @type {string}
21
- * @required
21
+ * @optional
22
22
  */
23
23
  icon?: string;
24
24
 
25
+ iconColor?: string;
26
+
27
+ name?: string;
28
+
25
29
  /**
26
30
  * Indicates whether the option is disabled.
27
31
  * @type {boolean}
@@ -40,11 +44,11 @@ interface OptionCardProps {
40
44
 
41
45
  /**
42
46
  * Callback function triggered when an option is clicked.
43
- * @param {any} data - The data associated with the clicked option.
47
+ * @param {OptionClick} data - The data associated with the clicked option.
44
48
  * @type {function}
45
49
  * @required
46
50
  */
47
- onClick: (data?: any) => void;
51
+ onClick: (data: OptionClick) => void;
48
52
 
49
53
  /**
50
54
  * Optional styles applied to the card.
@@ -52,6 +56,41 @@ interface OptionCardProps {
52
56
  * @optional
53
57
  */
54
58
  styles?: React.CSSProperties;
59
+
60
+ /**
61
+ * The z-index of the option card.
62
+ * @type {number}
63
+ * @optional
64
+ */
65
+ zIndex?: number;
66
+
67
+ /**
68
+ * The position of the menu relative to the triggering element.
69
+ * @type {dropdownPosition}
70
+ * @required
71
+ */
72
+ menuPosition: any;
73
+
74
+ /**
75
+ * Reference to the menu DOM element.
76
+ * @type {React.RefObject<HTMLElement>}
77
+ * @required
78
+ */
79
+ menuRef: React.RefObject<HTMLElement>;
80
+
81
+ /**
82
+ * Callback function to close the dropdown.
83
+ * @type {() => void}
84
+ * @required
85
+ */
86
+ closeDropdown: () => void;
87
+
88
+ /**
89
+ * Placement of the dropdown menu relative to the icon.
90
+ * @type {dropdownPosition}
91
+ * @optional
92
+ */
93
+ dropdownPosition?: 'top' | 'down' | 'left' | 'right';
55
94
  }
56
95
 
57
96
  interface MenuOptionProps {
@@ -100,35 +139,34 @@ interface MenuOptionProps {
100
139
 
101
140
  /**
102
141
  * The placement of the dropdown menu relative to the icon.
103
- * @type {'top' | 'left' | 'right' | 'bottom'}
142
+ * @type {dropdownPosition}
104
143
  * @optional
105
144
  */
106
- dropdownPlacement?: string | 'top' | 'left' | 'right' | 'down';
145
+ dropdownPlacement?: 'top' | 'down' | 'left' | 'right';
107
146
 
108
- /**
147
+ /**
109
148
  * The variant of the menu option, either 'dark' or 'light'.
110
149
  * @type {'dark' | 'light'}
111
150
  * @default 'light'
112
151
  * @optional
113
152
  */
114
-
115
153
  variant?: 'dark' | 'light';
116
-
154
+
117
155
  /**
118
156
  * Callback function triggered when the icon is clicked.
119
- * @type {function}
157
+ * @type {() => void}
120
158
  * @optional
121
159
  */
122
-
123
160
  onClick?: () => void;
124
161
 
125
162
  /**
126
163
  * Callback function triggered when an option is clicked.
127
164
  * @param {OptionClick} option - The option that was clicked.
128
- * @type {function}
165
+ * @type {(option: OptionClick) => void}
129
166
  * @optional
130
167
  */
131
168
  onOptionClick?: (option: OptionClick) => void;
169
+
132
170
  /**
133
171
  * The size of the icon button.
134
172
  * @type {number}
@@ -144,13 +182,16 @@ interface MenuOptionProps {
144
182
  iconSize?: number;
145
183
 
146
184
  /**
147
- * The border radius of the icon.
185
+ * The border radius of the icon button.
148
186
  * @type {number}
149
187
  * @default 7
150
188
  */
151
189
  iconButtonBorderRadius?: number;
190
+
152
191
  /**
153
192
  * Providing z-index for the options card.
193
+ * @type {number}
194
+ * @optional
154
195
  */
155
196
  zIndex?: number;
156
197
  }
@@ -166,7 +207,7 @@ interface OptionProps {
166
207
  /**
167
208
  * Callback function triggered when the option is clicked.
168
209
  * @param {OptionClick} option - The clicked option.
169
- * @type {function}
210
+ * @type {(option: OptionClick) => void}
170
211
  * @required
171
212
  */
172
213
  onClick: (option: OptionClick) => void;
@@ -42,7 +42,7 @@ const BasicModalComponent = () => {
42
42
  <div className="ff-mini-modal-buttons-flex ff-mini-modal-gap-10">
43
43
  <Button
44
44
  onClick={() => openModal(1)}
45
- id='112233'
45
+ id="112233"
46
46
  ref={btnRef1}
47
47
  label="122"
48
48
  variant={currentModal === 1 ? 'primary' : 'secondary'}
@@ -241,7 +241,6 @@ export const BasicModal: Story = {
241
241
  };
242
242
 
243
243
  export const CustomModalWithArrow = () => {
244
- const btnRef1 = useRef<HTMLButtonElement>(null);
245
244
  const btnRef2 = useRef<HTMLButtonElement>(null);
246
245
  const btnRef3 = useRef<HTMLButtonElement>(null);
247
246
  const btnRef4 = useRef<HTMLButtonElement>(null);
@@ -263,7 +262,7 @@ export const CustomModalWithArrow = () => {
263
262
 
264
263
  {currentModal === 1 && (
265
264
  <MiniModal
266
- anchorRef='1a2b'
265
+ anchorRef="1a2b"
267
266
  modalProperties={{ width: 300, height: 250 }}
268
267
  headerProps={
269
268
  <>
@@ -9,6 +9,7 @@ import Typography from '../Typography';
9
9
  import Checkbox from '../Checkbox';
10
10
  import Tooltip from '../Tooltip';
11
11
  import { truncateText } from '../../utils/truncateText/truncateText';
12
+ import { getLabel } from '../../utils/getSelectOptionValue/getSelectOptionValue';
12
13
 
13
14
  const Dropdown = forwardRef<HTMLDivElement, DropdownProps>(
14
15
  (
@@ -19,12 +20,15 @@ const Dropdown = forwardRef<HTMLDivElement, DropdownProps>(
19
20
  dropdownPosition = {},
20
21
  zIndex,
21
22
  withSelectButton,
23
+ labelAccessor,
22
24
  },
23
25
  ref
24
26
  ) => {
25
27
  const filteredOptions = options
26
28
  ? options.filter((option) =>
27
- option.label?.toLowerCase().includes(searchedKeyword.toLowerCase())
29
+ getLabel(option, labelAccessor)
30
+ ?.toLowerCase()
31
+ .includes(searchedKeyword.toLowerCase())
28
32
  )
29
33
  : [];
30
34
  const { verticalMargin, optionHeight, maxDropdownHeight } =
@@ -56,12 +60,7 @@ const Dropdown = forwardRef<HTMLDivElement, DropdownProps>(
56
60
 
57
61
  return topPosition;
58
62
  }, [filteredOptions.length, withSelectButton, dropdownPosition]);
59
- const renderOption = (optionLabel: string | undefined) => {
60
- if (typeof optionLabel === 'string') {
61
- return truncateText(optionLabel, 25);
62
- }
63
- return optionLabel;
64
- };
63
+
65
64
  const themeContext = useContext(ThemeContext);
66
65
  const currentTheme = themeContext?.currentTheme;
67
66
  return (
@@ -91,7 +90,7 @@ const Dropdown = forwardRef<HTMLDivElement, DropdownProps>(
91
90
  <div
92
91
  role="option"
93
92
  className={`dropdown-option-container`}
94
- key={info.label}
93
+ key={getLabel(info, labelAccessor)}
95
94
  onClick={() =>
96
95
  !info?.isDisabled && handleOptionChange(info, !info.isChecked)
97
96
  }
@@ -104,14 +103,14 @@ const Dropdown = forwardRef<HTMLDivElement, DropdownProps>(
104
103
  <Tooltip
105
104
  zIndex={zIndex + 1}
106
105
  title={
107
- info.label && info.label.length > 25
108
- ? info.label
109
- : undefined
106
+ getLabel(info, labelAccessor).length > 25
107
+ ? getLabel(info, labelAccessor)
108
+ : ''
110
109
  }
111
110
  children={
112
111
  <Typography
113
112
  className="dropdown-option-label"
114
- children={`${renderOption(info.label)}`}
113
+ children={truncateText(getLabel(info, labelAccessor), 25)}
115
114
  />
116
115
  }
117
116
  />
@@ -90,6 +90,7 @@
90
90
  border: 0.5px solid #f1ebf2;
91
91
  padding: 0 1px 0 4px;
92
92
  gap: 4px;
93
+ height: 16px;
93
94
  border-radius: 15px;
94
95
  .ff-multiselect-chip-label {
95
96
  @extend .fontXs;
@@ -2,6 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react';
2
2
  import MultiSelect from './MultiSelect';
3
3
  import { useEffect, useState } from 'react';
4
4
  import { Option } from './MultiSelectTypes';
5
+ import React from 'react';
5
6
 
6
7
  const meta: Meta<typeof MultiSelect> = {
7
8
  title: 'Components/MultiSelect',
@@ -31,21 +32,54 @@ export const Default: Story = {
31
32
  { label: 'Cherry', value: 'cherry' },
32
33
  { label: 'Date', value: 'date' },
33
34
  { label: 'Grape', value: 'grape' },
34
- // { label: 'Kiwi', value: 'kiwi' },
35
- // { label: 'Mango', value: 'mango' },
36
- // { label: 'Orange', value: 'orange' },
37
- // { label: 'Peach', value: 'peach' },
38
- // { label: 'Strawberry', value: 'strawberry' },
35
+ { label: 'Kiwi', value: 'kiwi' },
36
+ { label: 'Mango', value: 'mango' },
37
+ { label: 'Orange', value: 'orange' },
38
+ { label: 'Peach', value: 'peach' },
39
+ { label: 'Strawberry', value: 'strawberry' },
39
40
  ],
40
- // selectedOptions: [{ label: 'Apple', value: 'apple' }],
41
41
  },
42
42
  };
43
43
 
44
- export const Default2: Story = {
45
- args: {
46
- ...defaultArgs,
44
+ export const NameAccessor: Story = {
45
+ render: () => {
46
+ const [options, setOptions] = useState<Option[]>([]);
47
+ const [selectedOptions, setSelectedOptions] = useState<Option[]>([
48
+ { name: 'Apple', fruit: 'apple' },
49
+ ]);
50
+ const onChange = (options: Option[]) => {
51
+ setSelectedOptions(options);
52
+ };
53
+ useEffect(() => {
54
+ setOptions([
55
+ { name: 'Apple', fruit: 'apple' },
56
+ { name: 'Banana', fruit: 'banana' },
57
+ {
58
+ name: 'CherryCherryCherryCherryCherryCherryCherryCherryCherryCherry',
59
+ fruit: 'cherry',
60
+ },
61
+ { name: 'Date', fruit: 'date' },
62
+ { name: 'Kiwi', fruit: 'kiwi' },
63
+ { name: 'Mango', fruit: 'mango' },
64
+ { name: 'Orange', fruit: 'orange' },
65
+ { name: 'Peach', fruit: 'peach' },
66
+ { name: 'Strawberry', fruit: 'strawberry' },
67
+ ]);
68
+ }, []);
69
+ return (
70
+ <MultiSelect
71
+ labelAccessor="name"
72
+ label={'Fruits'}
73
+ required
74
+ options={options}
75
+ selectedOptions={selectedOptions}
76
+ onChange={onChange}
77
+ valueAccessor="fruit"
78
+ />
79
+ );
47
80
  },
48
81
  };
82
+
49
83
  export const Default3: Story = {
50
84
  args: {
51
85
  ...defaultArgs,
@@ -85,6 +119,7 @@ export const EmailGroup: Story = {
85
119
  onChange={onChange}
86
120
  acceptNewOption={true}
87
121
  displayCount={true}
122
+ labelAccessor="label"
88
123
  />
89
124
  );
90
125
  },
@@ -158,6 +193,7 @@ export const Labels: Story = {
158
193
  return (
159
194
  <div style={{ width: '250px' }}>
160
195
  <MultiSelect
196
+ required
161
197
  label={'Labels'}
162
198
  variant="labels"
163
199
  options={options}
@@ -199,7 +235,6 @@ export const Machines: Story = {
199
235
  const [selectedOptions, setSelectedOptions] = useState<Option[]>([]);
200
236
 
201
237
  const handleSelectChange = (machines: Option[]) => {
202
- console.log('Updated machines:', machines);
203
238
  setSelectedOptions(machines);
204
239
  };
205
240