pixel-react 1.4.4 → 1.4.5

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 (145) 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/AllProjectsDropdown/AllProjectsDropdown.stories.d.ts +7 -0
  11. package/lib/components/AppHeader/AppHeader.stories.d.ts +7 -0
  12. package/lib/components/AttachImage/AttachImage.stories.d.ts +7 -0
  13. package/lib/components/AttachmentButton/AttachmentButton.stories.d.ts +9 -0
  14. package/lib/components/Avatar/Avatar.stories.d.ts +10 -0
  15. package/lib/components/Button/Button.stories.d.ts +13 -0
  16. package/lib/components/Charts/BarChart/BarChart.stories.d.ts +6 -0
  17. package/lib/components/Charts/DashboardDonutChart/DashboardDonutChart.stories.d.ts +7 -0
  18. package/lib/components/Charts/DonutChart/DonutChart.stories.d.ts +6 -0
  19. package/lib/components/Charts/IconRadialChart/IconRadialChart.stories.d.ts +8 -0
  20. package/lib/components/Charts/LineChart/LineChart.stories.d.ts +7 -0
  21. package/lib/components/Charts/MultiRadialChart/MultiRadialChart.stories.d.ts +8 -0
  22. package/lib/components/Charts/PieChart/PieChart.stories.d.ts +7 -0
  23. package/lib/components/Charts/RadialChart/RadialChart.stories.d.ts +6 -0
  24. package/lib/components/Checkbox/Checkbox.stories.d.ts +8 -0
  25. package/lib/components/Chip/Chip.stories.d.ts +14 -0
  26. package/lib/components/ConnectingBranch/ConnectingBranch.stories.d.ts +6 -0
  27. package/lib/components/DatePicker/DatePicker.stories.d.ts +9 -0
  28. package/lib/components/DragAndDrop/DragAndDrop.stories.d.ts +6 -0
  29. package/lib/components/Drawer/Drawer.stories.d.ts +12 -0
  30. package/lib/components/EditTextField/EditTextField.stories.d.ts +10 -0
  31. package/lib/components/Editor/Editor.d.ts +1 -2
  32. package/lib/components/Editor/Editor.stories.d.ts +6 -0
  33. package/lib/components/Editor/types.d.ts +1 -5
  34. package/lib/components/Excel/ExcelFile.stories.d.ts +6 -0
  35. package/lib/components/ExcelFile/ChangeExcelStyles.d.ts +14 -0
  36. package/lib/components/ExcelFile/ColorBarselector/ColorBarSelector.d.ts +8 -0
  37. package/lib/components/ExcelFile/ContextMenu/ContextMenu.d.ts +4 -0
  38. package/lib/components/ExcelFile/ExcelFile/Excel/ActiveCell.d.ts +7 -0
  39. package/lib/components/ExcelFile/ExcelFile/Excel/Cell.d.ts +4 -0
  40. package/lib/components/ExcelFile/ExcelFile/Excel/ColumnIndicator.d.ts +5 -0
  41. package/lib/components/ExcelFile/ExcelFile/Excel/Copied.d.ts +3 -0
  42. package/lib/components/ExcelFile/ExcelFile/Excel/CornerIndicator.d.ts +5 -0
  43. package/lib/components/ExcelFile/ExcelFile/Excel/DataEditor.d.ts +5 -0
  44. package/lib/components/ExcelFile/ExcelFile/Excel/DataViewer.d.ts +8 -0
  45. package/lib/components/ExcelFile/ExcelFile/Excel/FloatingRect.d.ts +10 -0
  46. package/lib/components/ExcelFile/ExcelFile/Excel/HeaderRow.d.ts +3 -0
  47. package/lib/components/ExcelFile/ExcelFile/Excel/Row.d.ts +3 -0
  48. package/lib/components/ExcelFile/ExcelFile/Excel/RowIndicator.d.ts +5 -0
  49. package/lib/components/ExcelFile/ExcelFile/Excel/Selected.d.ts +3 -0
  50. package/lib/components/ExcelFile/ExcelFile/Excel/Spreadsheet.d.ts +81 -0
  51. package/lib/components/ExcelFile/ExcelFile/Excel/Table.d.ts +3 -0
  52. package/lib/components/ExcelFile/ExcelFile/Excel/actions.d.ts +130 -0
  53. package/lib/components/ExcelFile/ExcelFile/Excel/areModelsEqual.d.ts +1 -0
  54. package/lib/components/ExcelFile/ExcelFile/Excel/context.d.ts +8 -0
  55. package/lib/components/ExcelFile/ExcelFile/Excel/engine/engine.d.ts +22 -0
  56. package/lib/components/ExcelFile/ExcelFile/Excel/engine/formula.d.ts +17 -0
  57. package/lib/components/ExcelFile/ExcelFile/Excel/engine/index.d.ts +2 -0
  58. package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-graph.d.ts +21 -0
  59. package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-hash.d.ts +3 -0
  60. package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-set.d.ts +24 -0
  61. package/lib/components/ExcelFile/ExcelFile/Excel/index.d.ts +13 -0
  62. package/lib/components/ExcelFile/ExcelFile/Excel/matrix.d.ts +67 -0
  63. package/lib/components/ExcelFile/ExcelFile/Excel/point-range.d.ts +22 -0
  64. package/lib/components/ExcelFile/ExcelFile/Excel/point.d.ts +11 -0
  65. package/lib/components/ExcelFile/ExcelFile/Excel/reducer.d.ts +27 -0
  66. package/lib/components/ExcelFile/ExcelFile/Excel/selection.d.ts +95 -0
  67. package/lib/components/ExcelFile/ExcelFile/Excel/types.d.ts +215 -0
  68. package/lib/components/ExcelFile/ExcelFile/Excel/use-dispatch.d.ts +3 -0
  69. package/lib/components/ExcelFile/ExcelFile/Excel/use-selector.d.ts +3 -0
  70. package/lib/components/ExcelFile/ExcelFile/Excel/util.d.ts +45 -0
  71. package/lib/components/ExcelFile/ExcelFile/ExcelFile.d.ts +3 -0
  72. package/lib/components/ExcelFile/ExcelFile.stories.d.ts +6 -0
  73. package/lib/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.d.ts +15 -0
  74. package/lib/components/ExcelFile/ExcelToolBar/ExcelToolBar.d.ts +3 -0
  75. package/lib/components/ExcelFile/ImportExcelStyles.d.ts +24 -0
  76. package/lib/components/ExcelFile/Types.d.ts +176 -0
  77. package/lib/components/ExcelFile/index.d.ts +1 -0
  78. package/lib/components/ExpandableMenu/ExpandableMenu.stories.d.ts +7 -0
  79. package/lib/components/FF_Captcha/captcha.stories.d.ts +8 -0
  80. package/lib/components/FileDropzone/FileDropzone.stories.d.ts +8 -0
  81. package/lib/components/Form/Form.stories.d.ts +7 -0
  82. package/lib/components/GridLayout/GridLayout.stories.d.ts +8 -0
  83. package/lib/components/HighlightText/HighlightText.stories.d.ts +6 -0
  84. package/lib/components/Icon/Icon.stories.d.ts +8 -0
  85. package/lib/components/IconButton/IconButton.stories.d.ts +7 -0
  86. package/lib/components/IconRadioGroup/IconRadioGroup.stories.d.ts +7 -0
  87. package/lib/components/Input/Input.stories.d.ts +9 -0
  88. package/lib/components/InputWithDropdown/InputWithDropdown.stories.d.ts +9 -0
  89. package/lib/components/LabelEditTextField/LabelEditTextField.stories.d.ts +13 -0
  90. package/lib/components/LazyLoad/LazyLoad.stories.d.ts +6 -0
  91. package/lib/components/MachineInputField/MachineInputField.stories.d.ts +6 -0
  92. package/lib/components/MenuOption/MenuOption.stories.d.ts +16 -0
  93. package/lib/components/MiniModal/MiniModal.stories.d.ts +10 -0
  94. package/lib/components/Modal/Modal.stories.d.ts +7 -0
  95. package/lib/components/ModulesChip/ModuleChip.stories.d.ts +6 -0
  96. package/lib/components/MultiSelect/MultiSelect.stories.d.ts +12 -0
  97. package/lib/components/NLPInput/NlpInput.stories.d.ts +7 -0
  98. package/lib/components/Paper/Paper.stories.d.ts +11 -0
  99. package/lib/components/RadioButton/RadioButton.stories.d.ts +10 -0
  100. package/lib/components/RadioGroup/RadioGroup.stories.d.ts +9 -0
  101. package/lib/components/Search/Search.stories.d.ts +6 -0
  102. package/lib/components/Select/Select.stories.d.ts +14 -0
  103. package/lib/components/Select/components/Dropdown/Dropdown.d.ts +4 -0
  104. package/lib/components/Select/components/Dropdown/dropdownTypes.d.ts +17 -0
  105. package/lib/components/SequentialConnectingBranch/SequentialConnectingBranch.stories.d.ts +6 -0
  106. package/lib/components/StateDropdown/StateDropdown.stories.d.ts +10 -0
  107. package/lib/components/StatusButton/StatusButton.stories.d.ts +14 -0
  108. package/lib/components/StatusCard/StatusCard.stories.d.ts +11 -0
  109. package/lib/components/Table/Table.stories.d.ts +13 -0
  110. package/lib/components/TableTree/TableTree.stories.d.ts +7 -0
  111. package/lib/components/Tabs/Tabs.stories.d.ts +9 -0
  112. package/lib/components/TextArea/Textarea.stories.d.ts +9 -0
  113. package/lib/components/Toast/Toast.stories.d.ts +6 -0
  114. package/lib/components/Toastify/Toastify.stories.d.ts +6 -0
  115. package/lib/components/Toggle/Toggle.stories.d.ts +12 -0
  116. package/lib/components/Tooltip/Tooltip.stories.d.ts +15 -0
  117. package/lib/components/Typography/Typography.stories.d.ts +10 -0
  118. package/lib/components/VariableInput/VariableInput.stories.d.ts +6 -0
  119. package/lib/index.d.ts +32 -7
  120. package/lib/index.esm.js +5052 -224
  121. package/lib/index.esm.js.map +1 -1
  122. package/lib/index.js +5052 -223
  123. package/lib/index.js.map +1 -1
  124. package/lib/utils/checkEmpty/checkEmpty.stories.d.ts +6 -0
  125. package/lib/utils/compareArrays/compareArrays.stories.d.ts +6 -0
  126. package/lib/utils/compareObjects/compareObjects.stories.d.ts +6 -0
  127. package/lib/utils/debounce/debounce.stories.d.ts +6 -0
  128. package/lib/utils/ffID/ffID.stories.d.ts +6 -0
  129. package/lib/utils/find/findAndInsert.d.ts +7 -0
  130. package/lib/utils/find/findAndInsert.stories.d.ts +7 -0
  131. package/lib/utils/findAndInsert/findAndInsert.stories.d.ts +7 -0
  132. package/lib/utils/getEncryptedData/getEncryptedData.stories.d.ts +6 -0
  133. package/lib/utils/getExtension/getExtension.stories.d.ts +6 -0
  134. package/lib/utils/getSequentialPayload/getSequentialPayload.stories.d.ts +10 -0
  135. package/lib/utils/throttle/throttle.stories.d.ts +6 -0
  136. package/lib/utils/truncateText/truncateText.stories.d.ts +6 -0
  137. package/package.json +2 -2
  138. package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.tsx +2 -2
  139. package/src/components/Editor/Editor.tsx +224 -191
  140. package/src/components/Editor/types.ts +1 -5
  141. package/src/index.ts +3 -1
  142. package/lib/assets/fonts/Poppins-Bold.ttf +0 -0
  143. package/lib/assets/fonts/Poppins-Medium.ttf +0 -0
  144. package/lib/assets/fonts/Poppins-Regular.ttf +0 -0
  145. package/lib/assets/fonts/Poppins-SemiBold.ttf +0 -0
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ title: string;
3
+ component: (value: any) => boolean;
4
+ };
5
+ export default _default;
6
+ export declare const Default: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ title: string;
3
+ component: (arr1: unknown[], arr2: unknown[]) => boolean;
4
+ };
5
+ export default _default;
6
+ export declare const Default: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ title: string;
3
+ component: (obj1: import("./compareObjects").AnyObject | null, obj2: import("./compareObjects").AnyObject | null) => boolean;
4
+ };
5
+ export default _default;
6
+ export declare const Default: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ title: string;
3
+ component: (func: (...args: any[]) => void, delay: number) => import("./debounce").DebouncedFunction;
4
+ };
5
+ export default _default;
6
+ export declare const Default: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { ffid } from './ffid';
3
+ declare const meta: Meta<typeof ffid>;
4
+ type Story = StoryObj;
5
+ export declare const Primary: Story;
6
+ export default meta;
@@ -0,0 +1,7 @@
1
+ export type AnyObject = {
2
+ id: number;
3
+ [key: string]: any;
4
+ };
5
+ export declare function findAndInsert<T extends AnyObject>(data: T[], key: keyof T, targetId: number, newEntry: T, insertPosition: 'above' | 'below' | 'replace', childrenKey?: string): {
6
+ updatedArray: T[];
7
+ } | null;
@@ -0,0 +1,7 @@
1
+ import { findAndInsert } from './findAndInsert';
2
+ declare const _default: {
3
+ title: string;
4
+ component: typeof findAndInsert;
5
+ };
6
+ export default _default;
7
+ export declare const InteractivePlayground: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,7 @@
1
+ import { findAndInsert } from './findAndInsert';
2
+ declare const _default: {
3
+ title: string;
4
+ component: typeof findAndInsert;
5
+ };
6
+ export default _default;
7
+ export declare const InteractivePlayground: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ title: string;
3
+ component: (data: string, publicKey: string) => string | false;
4
+ };
5
+ export default _default;
6
+ export declare const InteractivePlayground: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ title: string;
3
+ component: (value: string | File) => string | undefined;
4
+ };
5
+ export default _default;
6
+ export declare const Default: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { Meta, StoryObj } from '@storybook/react';
3
+ import { MachineExecutionInstanceDataSet } from './types';
4
+ declare const SequentialPayloadComponent: React.FC<{
5
+ machineInstances: MachineExecutionInstanceDataSet[];
6
+ }>;
7
+ declare const meta: Meta<typeof SequentialPayloadComponent>;
8
+ type Story = StoryObj<typeof SequentialPayloadComponent>;
9
+ export declare const Primary: Story;
10
+ export default meta;
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ title: string;
3
+ component: (func: (...args: any[]) => void, limit: number) => import("./throttle").ThrottledFunction;
4
+ };
5
+ export default _default;
6
+ export declare const Default: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ title: string;
3
+ component: (text: string, maxLength: number) => string;
4
+ };
5
+ export default _default;
6
+ export declare const Default: () => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "pixel-react",
3
3
  "description": "Great for pixel-perfect, design-focused components in React",
4
- "version": "1.4.4",
4
+ "version": "1.4.5",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",
7
7
  "types": "lib/index.d.ts",
@@ -29,6 +29,7 @@
29
29
  "@types/react": "^18.3.12",
30
30
  "@types/react-dom": "^18.3.1",
31
31
  "@types/react-google-recaptcha": "^2.1.9",
32
+ "@types/js-beautify": "^1.14.3",
32
33
  "chromatic": "^11.16.5",
33
34
  "postcss": "^8.4.35",
34
35
  "react": "^18.2.0",
@@ -66,7 +67,6 @@
66
67
  "date-fns-tz": "^3.2.0",
67
68
  "js-beautify": "^1.15.1",
68
69
  "jsencrypt": "^3.3.2",
69
- "prettier": "^3.3.3",
70
70
  "react-archer": "^4.4.0",
71
71
  "react-day-picker": "^9.2.1",
72
72
  "react-google-recaptcha": "^3.1.0",
@@ -141,7 +141,7 @@ const DashboardDonutChart: React.FC<DashboardDonutChartProps> = ({
141
141
  {legendData.map((item, index) => (
142
142
  <div className="ff-legend-item" key={index}>
143
143
  <Typography
144
- fontSize={20}
144
+ fontSize={22}
145
145
  fontWeight="semi-bold"
146
146
  className="ff-legend-value"
147
147
  color={
@@ -152,7 +152,7 @@ const DashboardDonutChart: React.FC<DashboardDonutChartProps> = ({
152
152
  >
153
153
  {item.value} {showUnit && unit?.toUpperCase()}
154
154
  </Typography>
155
- <Typography fontSize={10} className="ff-legend-key">
155
+ <Typography fontSize={12} className="ff-legend-key">
156
156
  {item.key}
157
157
  </Typography>
158
158
  </div>
@@ -1,215 +1,248 @@
1
- import React, { useRef, useState, useEffect } from 'react';
2
- import MonacoEditor, { OnMount } from '@monaco-editor/react';
3
1
  import {
4
- dropdownPositionType,
5
- EditorProps,
6
- option,
7
- DyanamicObj,
8
- } from './types';
9
- import Icon from '../Icon';
2
+ useRef,
3
+ useState,
4
+ useEffect,
5
+ forwardRef,
6
+ useImperativeHandle,
7
+ } from 'react';
8
+ import MonacoEditor, { OnMount } from '@monaco-editor/react';
9
+ import { js as beautifyJS, html as beautifyHTML } from 'js-beautify';
10
+ import { dropdownPositionType, EditorProps, DyanamicObj } from './types';
10
11
  import './Editor.scss';
11
- import Select from '../Select';
12
- import Button from '../Button';
13
12
  import VariableDropdown from './VariableDropdown';
14
- import Drawer from '../Drawer';
15
- import FileDropzone from '../FileDropzone';
16
- import Tooltip from '../Tooltip';
17
- import { optionsList } from './constants';
18
13
 
19
- const Editor: React.FC<EditorProps> = ({
20
- width,
21
- height,
22
- showToolbar,
23
- readOnly,
24
- value = '',
25
- handleChange,
26
- setValue,
27
- variableOptionsList = [],
28
- language = 'javascript',
29
- theme = 'light',
30
- }) => {
31
- const editorRef = useRef<Parameters<OnMount>[0] | null>(null);
32
- const decorationsRef = useRef<string[]>([]);
33
- const [contentType, setContentType] = useState<string>(language);
34
- const [currentLine, setCurrentLine] = useState<number>(0);
35
- const [showDropdown, setShowDropdown] = useState<boolean>(false);
36
- const [showDrawer, setShowDrawer] = useState<boolean>(false);
37
- const [selectedOption, setSelectedOption] = useState<option>({
38
- label: 'JSON',
39
- value: 'json',
40
- });
41
- const [dropdownPosition, setDropdownPosition] =
42
- useState<dropdownPositionType>({ top: 0, left: 0 });
14
+ const Editor = forwardRef<any, EditorProps>(
15
+ (
16
+ {
17
+ width,
18
+ height,
19
+ readOnly,
20
+ value = '',
21
+ handleChange,
22
+ setValue,
23
+ variableOptionsList = [],
24
+ language = 'json',
25
+ theme = 'light',
26
+ },
27
+ ref
28
+ ) => {
29
+ const editorRef = useRef<Parameters<OnMount>[0] | null>(null);
30
+ const decorationsRef = useRef<string[]>([]);
31
+ const [currentLine, setCurrentLine] = useState<number>(0);
32
+ const [showDropdown, setShowDropdown] = useState<boolean>(false);
33
+ const [dropdownPosition, setDropdownPosition] =
34
+ useState<dropdownPositionType>({ top: 0, left: 0 });
43
35
 
44
- const handleEditorDidMount: OnMount = (editor: any) => {
45
- editorRef.current = editor;
36
+ const handleEditorDidMount: OnMount = (editor: any) => {
37
+ editorRef.current = editor;
46
38
 
47
- editor.onDidChangeCursorPosition((e: any) => {
48
- setCurrentLine(e.position.lineNumber);
49
- });
39
+ editor.onDidChangeCursorPosition((e: any) => {
40
+ setCurrentLine(e.position.lineNumber);
41
+ });
50
42
 
51
- editor.onDidChangeModelContent(() => {
52
- const content = editor.getValue();
53
- setValue(content);
43
+ editor.onDidChangeModelContent(() => {
44
+ const content = editor.getValue();
45
+ setValue(content);
54
46
 
55
- const position = editor.getPosition();
56
- const model = editor.getModel();
57
- if (position && model) {
58
- const currentLineContent = model.getLineContent(position.lineNumber);
59
- if (currentLineContent[position.column - 2] === '$') {
60
- const visiblePosition = editor.getScrolledVisiblePosition(position);
61
- if (visiblePosition) {
62
- setDropdownPosition({
63
- top: visiblePosition.top,
64
- left: visiblePosition.left,
65
- });
66
- setShowDropdown(true);
47
+ const position = editor.getPosition();
48
+ const model = editor.getModel();
49
+ if (position && model) {
50
+ const currentLineContent = model.getLineContent(position.lineNumber);
51
+ if (currentLineContent[position.column - 2] === '$') {
52
+ const visiblePosition = editor.getScrolledVisiblePosition(position);
53
+ if (visiblePosition) {
54
+ setDropdownPosition({
55
+ top: visiblePosition.top,
56
+ left: visiblePosition.left,
57
+ });
58
+ setShowDropdown(true);
59
+ }
60
+ } else {
61
+ setShowDropdown(false);
67
62
  }
68
- } else {
69
- setShowDropdown(false);
70
63
  }
71
- }
72
- });
73
- };
64
+ });
65
+ };
74
66
 
75
- useEffect(() => {
76
- if (editorRef.current && currentLine) {
77
- // Define decoration for the current line
78
- const decorations = [
79
- {
80
- range: {
81
- startLineNumber: currentLine,
82
- startColumn: 1,
83
- endLineNumber: currentLine,
84
- endColumn: 1,
85
- },
86
- options: {
87
- isWholeLine: true,
88
- className: 'current-line-background', // Custom CSS class for background color
67
+ useEffect(() => {
68
+ if (editorRef.current && currentLine) {
69
+ const decorations = [
70
+ {
71
+ range: {
72
+ startLineNumber: currentLine,
73
+ startColumn: 1,
74
+ endLineNumber: currentLine,
75
+ endColumn: 1,
76
+ },
77
+ options: {
78
+ isWholeLine: true,
79
+ className: 'current-line-background',
80
+ },
89
81
  },
90
- },
91
- ];
92
-
93
- // Apply decorations
94
- decorationsRef.current = editorRef.current.deltaDecorations(
95
- decorationsRef.current,
96
- decorations
97
- );
98
- }
99
- }, [currentLine]);
82
+ ];
100
83
 
101
- const handleBeautify = () => {
102
- let beautifiedContent = value;
103
- if (contentType === 'json') {
104
- try {
105
- beautifiedContent = JSON.stringify(JSON.parse(value), null, 2);
106
- } catch (e) {
107
- alert('Invalid JSON format');
84
+ decorationsRef.current = editorRef.current.deltaDecorations(
85
+ decorationsRef.current,
86
+ decorations
87
+ );
108
88
  }
109
- }
110
- setValue(beautifiedContent);
111
- };
89
+ }, [currentLine]);
112
90
 
113
- const handleSelectSuggestion = (suggestion: string, type: string) => {
114
- if (editorRef.current) {
115
- const editor = editorRef.current;
116
- const position = editor.getPosition();
117
- if (position) {
118
- editor.executeEdits('', [
119
- {
120
- range: {
121
- startLineNumber: position.lineNumber,
122
- startColumn: position.column,
123
- endLineNumber: position.lineNumber,
124
- endColumn: position.column,
91
+ const handleSelectSuggestion = (suggestion: string, type: string) => {
92
+ if (editorRef.current) {
93
+ const editor = editorRef.current;
94
+ const position = editor.getPosition();
95
+ if (position) {
96
+ editor.executeEdits('', [
97
+ {
98
+ range: {
99
+ startLineNumber: position.lineNumber,
100
+ startColumn: position.column,
101
+ endLineNumber: position.lineNumber,
102
+ endColumn: position.column,
103
+ },
104
+ text: `{${type}_${suggestion}}`,
125
105
  },
126
- text: `{${type}_${suggestion}}`,
127
- },
128
- ]);
129
- setShowDropdown(false);
106
+ ]);
107
+ setShowDropdown(false);
108
+ }
130
109
  }
131
- }
132
- };
110
+ };
133
111
 
134
- const handleFileUpload = () => {
135
- setShowDrawer(true);
136
- };
112
+ const handleSelectVariable = (option: DyanamicObj) => {
113
+ handleSelectSuggestion(
114
+ option?.name,
115
+ option?.type === 'GLOBAL'
116
+ ? 'GV'
117
+ : option?.type === 'LOCAL'
118
+ ? 'LV'
119
+ : 'PEV'
120
+ );
121
+ };
137
122
 
138
- const onDropdownChangeHandler = (option: option) => {
139
- setContentType(option.value);
140
- setSelectedOption(option);
141
- };
123
+ const mapLanguageToContentType = (language: string | undefined): string => {
124
+ switch (language) {
125
+ case 'javascript':
126
+ case 'typescript':
127
+ return 'javascript';
128
+ case 'json':
129
+ return 'json';
130
+ case 'html':
131
+ return 'html';
132
+ case 'xml':
133
+ return 'xml';
134
+ default:
135
+ return 'plain text';
136
+ }
137
+ };
142
138
 
143
- const handleSelectVariable = (option: DyanamicObj) => {
144
- handleSelectSuggestion(
145
- option?.name,
146
- option?.type === 'GLOBAL' ? 'GV' : option?.type === 'LOCAL' ? 'LV' : 'PEV'
147
- );
148
- };
139
+ const beautifyContent = (content: string, language: string): string => {
140
+ switch (language) {
141
+ case 'json':
142
+ return beautifyJS(content, {
143
+ indent_size: 4,
144
+ indent_char: ' ',
145
+ max_preserve_newlines: 5,
146
+ preserve_newlines: true,
147
+ keep_array_indentation: true,
148
+ break_chained_methods: true,
149
+ brace_style: 'collapse',
150
+ space_before_conditional: true,
151
+ unescape_strings: true,
152
+ jslint_happy: true,
153
+ end_with_newline: true,
154
+ wrap_line_length: 0,
155
+ comma_first: true,
156
+ e4x: true,
157
+ indent_empty_lines: true,
158
+ });
159
+ case 'javascript':
160
+ return beautifyJS(content, {
161
+ indent_size: 4,
162
+ indent_char: ' ',
163
+ max_preserve_newlines: 5,
164
+ preserve_newlines: true,
165
+ keep_array_indentation: true,
166
+ break_chained_methods: true,
167
+ brace_style: 'collapse',
168
+ space_before_conditional: true,
169
+ unescape_strings: true,
170
+ jslint_happy: true,
171
+ end_with_newline: true,
172
+ wrap_line_length: 0,
173
+ comma_first: true,
174
+ e4x: true,
175
+ indent_empty_lines: true,
176
+ });
177
+ case 'html':
178
+ return beautifyHTML(content, {
179
+ indent_size: 4,
180
+ indent_char: ' ',
181
+ max_preserve_newlines: 5,
182
+ preserve_newlines: true,
183
+ end_with_newline: true,
184
+ wrap_line_length: 0,
185
+ indent_empty_lines: true,
186
+ });
187
+ case 'xml':
188
+ return beautifyHTML(content, {
189
+ indent_size: 4,
190
+ indent_char: ' ',
191
+ max_preserve_newlines: 5,
192
+ preserve_newlines: true,
193
+ end_with_newline: true,
194
+ wrap_line_length: 0,
195
+ indent_empty_lines: true,
196
+ });
197
+ case 'plain text':
198
+ return content;
199
+ default:
200
+ return content;
201
+ }
202
+ };
149
203
 
150
- return (
151
- <div style={{ width, height }} className="ff-editor-container">
152
- {showToolbar && (
153
- <div className="ff-top-toolbar">
154
- <Tooltip title="Beautify">
155
- <Icon name="beautify_icon" hoverEffect onClick={handleBeautify} />
156
- </Tooltip>
157
- <Select
158
- labelAccessor="label"
159
- valueAccessor="value"
160
- optionsList={optionsList}
161
- selectedOption={selectedOption}
162
- showBorder={true}
163
- onChange={onDropdownChangeHandler}
164
- showLabel={true}
165
- height={24}
166
- width={98}
167
- />
168
- <Button
169
- onClick={handleFileUpload}
170
- variant="secondary"
171
- label="Choose File"
172
- />
173
- </div>
174
- )}
175
- <MonacoEditor
176
- height="90%"
177
- width="100%"
178
- language={contentType}
179
- value={value}
180
- options={{
181
- lineNumbers: 'on',
182
- wordWrap: 'on',
183
- autoClosingBrackets: 'always',
184
- scrollBeyondLastLine: false,
185
- readOnly,
186
- fontFamily: 'font-poppins',
187
- theme,
188
- }}
189
- onMount={handleEditorDidMount}
190
- onChange={(newValue, event) => handleChange(newValue, event)}
191
- />
192
- {showDrawer && (
193
- <Drawer
194
- title="Choose File"
195
- isOpen={showDrawer}
196
- onClose={() => setShowDrawer(false)}
197
- >
198
- <FileDropzone
199
- buttonLabel="Upload"
200
- accept={['.json', '.js', '.html']}
201
- />
202
- </Drawer>
203
- )}
204
- {showDropdown && dropdownPosition && (
205
- <VariableDropdown
206
- optionsList={variableOptionsList}
207
- onSelectVariable={handleSelectVariable}
208
- dropdownPosition={dropdownPosition}
204
+ // Expose editorRef and helper functions to parent via forwarded ref
205
+ useImperativeHandle(ref, () => ({
206
+ getEditorInstance: () => editorRef.current,
207
+ beautify: () => {
208
+ if (editorRef.current) {
209
+ const content = editorRef.current.getValue();
210
+ const lang = editorRef.current.getModel()?.getLanguageId();
211
+ const language = mapLanguageToContentType(lang);
212
+ const beautifiedContent = beautifyContent(content, language);
213
+ editorRef.current.setValue(beautifiedContent);
214
+ }
215
+ },
216
+ }));
217
+
218
+ return (
219
+ <div style={{ width, height }} className="ff-editor-container">
220
+ <MonacoEditor
221
+ height="90%"
222
+ width="100%"
223
+ language={language}
224
+ value={value}
225
+ options={{
226
+ lineNumbers: 'on',
227
+ wordWrap: 'on',
228
+ autoClosingBrackets: 'always',
229
+ scrollBeyondLastLine: false,
230
+ readOnly,
231
+ }}
232
+ onMount={handleEditorDidMount}
233
+ onChange={(newValue, event) => handleChange(newValue, event)}
234
+ theme={theme}
209
235
  />
210
- )}
211
- </div>
212
- );
213
- };
236
+ {showDropdown && dropdownPosition && (
237
+ <VariableDropdown
238
+ optionsList={variableOptionsList}
239
+ onSelectVariable={handleSelectVariable}
240
+ dropdownPosition={dropdownPosition}
241
+ />
242
+ )}
243
+ </div>
244
+ );
245
+ }
246
+ );
214
247
 
215
248
  export default Editor;
@@ -5,7 +5,7 @@ export interface EditorProps {
5
5
  /**
6
6
  * Editor Content Type
7
7
  */
8
- language?: 'javascript' | 'html' | 'json' | 'plaintext' | 'xml';
8
+ language: 'javascript' | 'html' | 'json' | 'plain text' | 'xml';
9
9
 
10
10
  /**
11
11
  *
@@ -18,10 +18,6 @@ export interface EditorProps {
18
18
  */
19
19
  height: string;
20
20
 
21
- /**
22
- * Show toolbar
23
- */
24
- showToolbar?: boolean;
25
21
 
26
22
  /**
27
23
  * read only
package/src/index.ts CHANGED
@@ -52,6 +52,7 @@ import SequentialConnectingBranch from './components/SequentialConnectingBranch'
52
52
  import AttachmentButton from './components/AttachmentButton';
53
53
  import { Toastify, toast } from './components/Toastify/Toastify';
54
54
  import ToggleSwitch from './components/ToggleSwitch/ToggleSwitch';
55
+ import Avatar from './components/Avatar/Avatar';
55
56
 
56
57
  import LabelEditTextField from './components/LabelEditTextField';
57
58
  import EditTextField from './components/EditTextField';
@@ -81,7 +82,7 @@ import MultiRadialChart from './components/Charts/MultiRadialChart';
81
82
  import Editor from './components/Editor/Editor';
82
83
  import { getSequentialPayload } from './utils/getSequentialPayload/getSequentialPayload';
83
84
  import ConnectingBranch from './components/ConnectingBranch/ConnectingBranch';
84
- import { saveFileFromBlob } from './utils/downloadFile/saveFileFromBlob'
85
+ import { saveFileFromBlob } from './utils/downloadFile/saveFileFromBlob';
85
86
 
86
87
  export {
87
88
  Button,
@@ -153,6 +154,7 @@ export {
153
154
  EditTextField,
154
155
  AttachImage,
155
156
  ToggleSwitch,
157
+ Avatar,
156
158
  // utils exports
157
159
  checkEmpty,
158
160
  getExtension,
Binary file
Binary file