pixel-react 1.4.4 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- package/.yarn/install-state.gz +0 -0
- package/lib/StyleGuide/ColorPalette/ColorPalette.stories.d.ts +6 -0
- package/lib/StyleGuide/Typography/Typography.stories.d.ts +6 -0
- package/lib/components/Accordion/Accordion.stories.d.ts +6 -0
- package/lib/components/AddButton/AddButton.d.ts +5 -0
- package/lib/components/AddButton/AddButton.stories.d.ts +6 -0
- package/lib/components/AddButton/index.d.ts +1 -0
- package/lib/components/AddButton/types.d.ts +4 -0
- package/lib/components/AddResourceButton/AddButton.stories.d.ts +8 -0
- package/lib/components/AllProjectsDropdown/AllProjectsDropdown.stories.d.ts +7 -0
- package/lib/components/AppHeader/AppHeader.stories.d.ts +7 -0
- package/lib/components/AttachImage/AttachImage.stories.d.ts +7 -0
- package/lib/components/AttachmentButton/AttachmentButton.stories.d.ts +9 -0
- package/lib/components/Avatar/Avatar.stories.d.ts +10 -0
- package/lib/components/Button/Button.stories.d.ts +13 -0
- package/lib/components/Charts/BarChart/BarChart.stories.d.ts +6 -0
- package/lib/components/Charts/DashboardDonutChart/DashboardDonutChart.stories.d.ts +7 -0
- package/lib/components/Charts/DonutChart/DonutChart.stories.d.ts +6 -0
- package/lib/components/Charts/IconRadialChart/IconRadialChart.stories.d.ts +8 -0
- package/lib/components/Charts/LineChart/LineChart.stories.d.ts +7 -0
- package/lib/components/Charts/MultiRadialChart/MultiRadialChart.stories.d.ts +8 -0
- package/lib/components/Charts/PieChart/PieChart.stories.d.ts +7 -0
- package/lib/components/Charts/RadialChart/RadialChart.stories.d.ts +6 -0
- package/lib/components/Checkbox/Checkbox.stories.d.ts +8 -0
- package/lib/components/Chip/Chip.stories.d.ts +14 -0
- package/lib/components/ConnectingBranch/ConnectingBranch.stories.d.ts +6 -0
- package/lib/components/DatePicker/DatePicker.stories.d.ts +9 -0
- package/lib/components/DragAndDrop/DragAndDrop.stories.d.ts +6 -0
- package/lib/components/Drawer/Drawer.stories.d.ts +12 -0
- package/lib/components/EditTextField/EditTextField.stories.d.ts +10 -0
- package/lib/components/Editor/Editor.d.ts +1 -2
- package/lib/components/Editor/Editor.stories.d.ts +6 -0
- package/lib/components/Editor/types.d.ts +1 -5
- package/lib/components/Excel/ExcelFile.stories.d.ts +6 -0
- package/lib/components/ExcelFile/ChangeExcelStyles.d.ts +14 -0
- package/lib/components/ExcelFile/ColorBarselector/ColorBarSelector.d.ts +8 -0
- package/lib/components/ExcelFile/ContextMenu/ContextMenu.d.ts +4 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/ActiveCell.d.ts +7 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/Cell.d.ts +4 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/ColumnIndicator.d.ts +5 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/Copied.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/CornerIndicator.d.ts +5 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/DataEditor.d.ts +5 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/DataViewer.d.ts +8 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/FloatingRect.d.ts +10 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/HeaderRow.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/Row.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/RowIndicator.d.ts +5 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/Selected.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/Spreadsheet.d.ts +81 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/Table.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/actions.d.ts +130 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/areModelsEqual.d.ts +1 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/context.d.ts +8 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/engine.d.ts +22 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/formula.d.ts +17 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/index.d.ts +2 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-graph.d.ts +21 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-hash.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/engine/point-set.d.ts +24 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/index.d.ts +13 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/matrix.d.ts +67 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/point-range.d.ts +22 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/point.d.ts +11 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/reducer.d.ts +27 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/selection.d.ts +95 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/types.d.ts +215 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/use-dispatch.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/use-selector.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile/Excel/util.d.ts +45 -0
- package/lib/components/ExcelFile/ExcelFile/ExcelFile.d.ts +3 -0
- package/lib/components/ExcelFile/ExcelFile.stories.d.ts +6 -0
- package/lib/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.d.ts +15 -0
- package/lib/components/ExcelFile/ExcelToolBar/ExcelToolBar.d.ts +3 -0
- package/lib/components/ExcelFile/ImportExcelStyles.d.ts +24 -0
- package/lib/components/ExcelFile/Types.d.ts +176 -0
- package/lib/components/ExcelFile/index.d.ts +1 -0
- package/lib/components/ExpandableMenu/ExpandableMenu.stories.d.ts +7 -0
- package/lib/components/FF_Captcha/captcha.stories.d.ts +8 -0
- package/lib/components/FileDropzone/FileDropzone.stories.d.ts +8 -0
- package/lib/components/Form/Form.stories.d.ts +7 -0
- package/lib/components/GridLayout/GridLayout.stories.d.ts +8 -0
- package/lib/components/HighlightText/HighlightText.stories.d.ts +6 -0
- package/lib/components/Icon/Icon.stories.d.ts +8 -0
- package/lib/components/IconButton/IconButton.stories.d.ts +7 -0
- package/lib/components/IconRadioGroup/IconRadioGroup.stories.d.ts +7 -0
- package/lib/components/Input/Input.stories.d.ts +9 -0
- package/lib/components/InputWithDropdown/InputWithDropdown.stories.d.ts +9 -0
- package/lib/components/LabelEditTextField/LabelEditTextField.stories.d.ts +13 -0
- package/lib/components/LazyLoad/LazyLoad.stories.d.ts +6 -0
- package/lib/components/MachineInputField/MachineInputField.stories.d.ts +6 -0
- package/lib/components/MenuOption/MenuOption.stories.d.ts +16 -0
- package/lib/components/MiniModal/MiniModal.stories.d.ts +10 -0
- package/lib/components/Modal/Modal.stories.d.ts +7 -0
- package/lib/components/ModulesChip/ModuleChip.stories.d.ts +6 -0
- package/lib/components/MultiSelect/MultiSelect.stories.d.ts +12 -0
- package/lib/components/NLPInput/NlpInput.stories.d.ts +7 -0
- package/lib/components/Paper/Paper.stories.d.ts +11 -0
- package/lib/components/RadioButton/RadioButton.stories.d.ts +10 -0
- package/lib/components/RadioGroup/RadioGroup.stories.d.ts +9 -0
- package/lib/components/Search/Search.stories.d.ts +6 -0
- package/lib/components/Select/Select.stories.d.ts +14 -0
- package/lib/components/Select/components/Dropdown/Dropdown.d.ts +4 -0
- package/lib/components/Select/components/Dropdown/dropdownTypes.d.ts +17 -0
- package/lib/components/SequentialConnectingBranch/SequentialConnectingBranch.stories.d.ts +6 -0
- package/lib/components/StateDropdown/StateDropdown.stories.d.ts +10 -0
- package/lib/components/StatusButton/StatusButton.stories.d.ts +14 -0
- package/lib/components/StatusCard/StatusCard.stories.d.ts +11 -0
- package/lib/components/Table/Table.stories.d.ts +13 -0
- package/lib/components/TableTree/TableTree.stories.d.ts +7 -0
- package/lib/components/Tabs/Tabs.stories.d.ts +9 -0
- package/lib/components/TextArea/Textarea.stories.d.ts +9 -0
- package/lib/components/Toast/Toast.stories.d.ts +6 -0
- package/lib/components/Toastify/Toastify.stories.d.ts +6 -0
- package/lib/components/Toggle/Toggle.stories.d.ts +12 -0
- package/lib/components/Tooltip/Tooltip.stories.d.ts +15 -0
- package/lib/components/Typography/Typography.stories.d.ts +10 -0
- package/lib/components/VariableInput/VariableInput.stories.d.ts +6 -0
- package/lib/index.d.ts +32 -7
- package/lib/index.esm.js +5052 -224
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +5052 -223
- package/lib/index.js.map +1 -1
- package/lib/utils/checkEmpty/checkEmpty.stories.d.ts +6 -0
- package/lib/utils/compareArrays/compareArrays.stories.d.ts +6 -0
- package/lib/utils/compareObjects/compareObjects.stories.d.ts +6 -0
- package/lib/utils/debounce/debounce.stories.d.ts +6 -0
- package/lib/utils/ffID/ffID.stories.d.ts +6 -0
- package/lib/utils/find/findAndInsert.d.ts +7 -0
- package/lib/utils/find/findAndInsert.stories.d.ts +7 -0
- package/lib/utils/findAndInsert/findAndInsert.stories.d.ts +7 -0
- package/lib/utils/getEncryptedData/getEncryptedData.stories.d.ts +6 -0
- package/lib/utils/getExtension/getExtension.stories.d.ts +6 -0
- package/lib/utils/getSequentialPayload/getSequentialPayload.stories.d.ts +10 -0
- package/lib/utils/throttle/throttle.stories.d.ts +6 -0
- package/lib/utils/truncateText/truncateText.stories.d.ts +6 -0
- package/package.json +2 -2
- package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.tsx +2 -2
- package/src/components/Editor/Editor.tsx +224 -191
- package/src/components/Editor/types.ts +1 -5
- package/src/index.ts +3 -1
- package/lib/assets/fonts/Poppins-Bold.ttf +0 -0
- package/lib/assets/fonts/Poppins-Medium.ttf +0 -0
- package/lib/assets/fonts/Poppins-Regular.ttf +0 -0
- package/lib/assets/fonts/Poppins-SemiBold.ttf +0 -0
@@ -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,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,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;
|
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
|
+
"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={
|
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={
|
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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
45
|
-
|
36
|
+
const handleEditorDidMount: OnMount = (editor: any) => {
|
37
|
+
editorRef.current = editor;
|
46
38
|
|
47
|
-
|
48
|
-
|
49
|
-
|
39
|
+
editor.onDidChangeCursorPosition((e: any) => {
|
40
|
+
setCurrentLine(e.position.lineNumber);
|
41
|
+
});
|
50
42
|
|
51
|
-
|
52
|
-
|
53
|
-
|
43
|
+
editor.onDidChangeModelContent(() => {
|
44
|
+
const content = editor.getValue();
|
45
|
+
setValue(content);
|
54
46
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
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
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
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
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
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
|
-
|
127
|
-
|
128
|
-
|
129
|
-
setShowDropdown(false);
|
106
|
+
]);
|
107
|
+
setShowDropdown(false);
|
108
|
+
}
|
130
109
|
}
|
131
|
-
}
|
132
|
-
};
|
110
|
+
};
|
133
111
|
|
134
|
-
|
135
|
-
|
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
|
-
|
139
|
-
|
140
|
-
|
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
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
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
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
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
|
-
|
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
|
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
|
Binary file
|
Binary file
|