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.
- package/lib/components/Button/Button.d.ts +2 -2
- package/lib/components/Charts/DashboardDonutChart/types.d.ts +3 -0
- package/lib/components/Charts/LineChart/types.d.ts +1 -0
- package/lib/components/ChooseFile/ChooseFile.d.ts +3 -2
- package/lib/components/Comment/Comments.d.ts +1 -1
- package/lib/components/Comment/type.d.ts +3 -3
- package/lib/components/ConditionalDropdown/types.d.ts +4 -0
- package/lib/components/DatePicker/types.d.ts +2 -0
- package/lib/components/Drawer/Types.d.ts +3 -0
- package/lib/components/Excel/ExcelFile/ExcelFile.d.ts +11 -10
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.d.ts +10 -0
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/DataViewer.d.ts +1 -1
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.d.ts +9 -0
- package/lib/components/Excel/ExcelFile/ExcelFileComponents/types.d.ts +0 -3
- package/lib/components/Excel/Types.d.ts +14 -10
- package/lib/components/FF_Captcha/Recaptcha.d.ts +2 -1
- package/lib/components/FF_Captcha/types.d.ts +11 -2
- package/lib/components/Input/types.d.ts +4 -0
- package/lib/components/LabelEditTextField/types.d.ts +2 -0
- package/lib/components/MobileSkin/MobileSkin.d.ts +5 -0
- package/lib/components/MobileSkin/MobileSkinInterface.d.ts +13 -0
- package/lib/components/MobileSkin/index.d.ts +1 -0
- package/lib/components/MobileSkin/types.d.ts +32 -0
- package/lib/components/Search/Search.d.ts +1 -1
- package/lib/components/Search/types.d.ts +1 -0
- package/lib/components/Select/components/types.d.ts +3 -2
- package/lib/components/Select/types.d.ts +10 -2
- package/lib/components/SequentialConnectingBranch/components/Branches/Branches.d.ts +1 -1
- package/lib/components/SequentialConnectingBranch/components/Branches/types.d.ts +1 -0
- package/lib/components/SequentialConnectingBranch/components/ConnectingBranches/ConnectingBranches.d.ts +1 -1
- package/lib/components/SequentialConnectingBranch/components/ConnectingBranches/types.d.ts +1 -0
- package/lib/components/SequentialConnectingBranch/types.d.ts +1 -0
- package/lib/components/TableTree/types.d.ts +4 -4
- package/lib/components/Tabs/types.d.ts +1 -0
- package/lib/index.d.ts +96 -40
- package/lib/index.esm.js +4812 -1669
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +4825 -1669
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/formData/ConvertFormDataToObject.d.ts +1 -0
- package/lib/utils/keyBoardActionUtil/UseKeyboardActions.d.ts +2 -0
- package/lib/utils/keyBoardActionUtil/types.d.ts +4 -0
- package/lib/validations/regex.d.ts +11 -1
- package/package.json +6 -1
- package/src/assets/Themes/BaseTheme.scss +3 -1
- package/src/assets/Themes/DarkTheme.scss +10 -1
- package/src/assets/icons/clear_cache.svg +5 -0
- package/src/assets/icons/external_user.svg +13 -0
- package/src/assets/icons/group_user.svg +12 -0
- package/src/assets/icons/single_user.svg +12 -0
- package/src/assets/icons/test_freshers_logo.svg +8 -0
- package/src/assets/icons/unfollow_icon.svg +3 -0
- package/src/components/AllProjectsDropdown/AllProjectsDropdown.scss +7 -45
- package/src/components/AllProjectsDropdown/AllProjectsDropdown.stories.tsx +5 -0
- package/src/components/AllProjectsDropdown/AllProjectsDropdown.tsx +76 -64
- package/src/components/Button/Button.scss +0 -1
- package/src/components/Button/Button.tsx +3 -4
- package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.stories.tsx +38 -6
- package/src/components/Charts/DashboardDonutChart/DashboardDonutChart.tsx +10 -4
- package/src/components/Charts/DashboardDonutChart/types.ts +4 -1
- package/src/components/Charts/LineChart/LineChart.stories.tsx +27 -88
- package/src/components/Charts/LineChart/LineChart.tsx +138 -42
- package/src/components/Charts/LineChart/types.ts +1 -0
- package/src/components/Charts/MultiRadialChart/MultiRadialChart.scss +3 -3
- package/src/components/Charts/MultiRadialChart/MultiRadialChart.tsx +47 -43
- package/src/components/ChooseFile/ChooseFile.tsx +3 -4
- package/src/components/Comment/Comments.scss +0 -1
- package/src/components/Comment/Comments.stories.tsx +22 -4
- package/src/components/Comment/Comments.tsx +20 -1
- package/src/components/Comment/type.ts +3 -3
- package/src/components/ConditionalDropdown/ConditionalDropdown.stories.tsx +1 -0
- package/src/components/ConditionalDropdown/ConditionalDropdown.tsx +2 -1
- package/src/components/ConditionalDropdown/types.ts +4 -0
- package/src/components/DatePicker/DatePicker.scss +307 -2
- package/src/components/DatePicker/DatePicker.tsx +27 -19
- package/src/components/DatePicker/types.ts +4 -0
- package/src/components/Drawer/Drawer.stories.tsx +1 -1
- package/src/components/Drawer/Types.ts +4 -2
- package/src/components/Editor/Editor.scss +23 -18
- package/src/components/Editor/Editor.tsx +2 -2
- package/src/components/Excel/ExcelContextMenu/ExcelContextMenu.tsx +6 -3
- package/src/components/Excel/ExcelFile/ExcelFile.scss +45 -41
- package/src/components/Excel/ExcelFile/ExcelFile.tsx +68 -64
- package/src/components/Excel/ExcelFile/ExcelFileComponents/ActiveCell.tsx +29 -1
- package/src/components/Excel/ExcelFile/ExcelFileComponents/Cell.tsx +0 -36
- package/src/components/Excel/ExcelFile/ExcelFileComponents/DataViewer.tsx +1 -40
- package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.scss +3 -3
- package/src/components/Excel/ExcelFile/ExcelFileComponents/Spreadsheet.tsx +12 -1
- package/src/components/Excel/ExcelFile/ExcelFileComponents/reducerFunctions.ts +8 -74
- package/src/components/Excel/ExcelFile/ExcelFileComponents/types.ts +0 -5
- package/src/components/Excel/ExcelFile.stories.tsx +112 -125
- package/src/components/Excel/ExcelToolBar/ExcelToolBar.tsx +10 -11
- package/src/components/Excel/Types.ts +17 -15
- package/src/components/FF_Captcha/Recaptcha.tsx +19 -9
- package/src/components/FF_Captcha/types.ts +12 -4
- package/src/components/Icon/Icon.stories.tsx +56 -8
- package/src/components/Icon/iconList.ts +13 -1
- package/src/components/Input/Input.stories.tsx +12 -0
- package/src/components/Input/Input.tsx +3 -1
- package/src/components/Input/types.ts +4 -0
- package/src/components/InputWithDropdown/types.ts +1 -1
- package/src/components/LabelEditTextField/LabelEditTextField.scss +4 -0
- package/src/components/LabelEditTextField/LabelEditTextField.stories.tsx +2 -1
- package/src/components/LabelEditTextField/LabelEditTextField.tsx +14 -10
- package/src/components/LabelEditTextField/types.ts +2 -0
- package/src/components/LazyLoad/LazyLoad.stories.tsx +1 -0
- package/src/components/LazyLoad/LazyLoading.tsx +10 -1
- package/src/components/MachineInputField/MachineInputField.scss +5 -1
- package/src/components/MachineInputField/MachineInputField.tsx +1 -0
- package/src/components/MobileSkin/MobileSkin.scss +67 -0
- package/src/components/MobileSkin/MobileSkin.stories.tsx +93 -0
- package/src/components/MobileSkin/MobileSkin.tsx +89 -0
- package/src/components/MobileSkin/MobileSkinInterface.ts +13 -0
- package/src/components/MobileSkin/index.ts +1 -0
- package/src/components/MobileSkin/types.ts +32 -0
- package/src/components/Modal/Modal.stories.tsx +7 -0
- package/src/components/Modal/Modal.tsx +17 -20
- package/src/components/Search/Search.scss +8 -0
- package/src/components/Search/Search.tsx +17 -6
- package/src/components/Search/types.ts +1 -0
- package/src/components/Select/Select.stories.tsx +85 -0
- package/src/components/Select/Select.tsx +10 -2
- package/src/components/Select/components/Dropdown.tsx +23 -15
- package/src/components/Select/components/types.ts +3 -2
- package/src/components/Select/types.ts +12 -2
- package/src/components/SequentialConnectingBranch/SequentialConnectingBranch.tsx +2 -0
- package/src/components/SequentialConnectingBranch/components/Branches/Branches.tsx +65 -57
- package/src/components/SequentialConnectingBranch/components/Branches/types.ts +1 -0
- package/src/components/SequentialConnectingBranch/components/ConnectingBranches/ConnectingBranches.tsx +2 -0
- package/src/components/SequentialConnectingBranch/components/ConnectingBranches/types.ts +1 -0
- package/src/components/SequentialConnectingBranch/types.ts +5 -1
- package/src/components/TableTree/Components/TableCell.tsx +3 -3
- package/src/components/TableTree/TableTree.scss +0 -7
- package/src/components/TableTree/TableTree.tsx +3 -22
- package/src/components/TableTree/types.ts +4 -4
- package/src/components/Tabs/Tabs.scss +19 -0
- package/src/components/Tabs/Tabs.tsx +9 -0
- package/src/components/Tabs/types.ts +1 -0
- package/src/index.ts +27 -0
- package/src/utils/formData/ConvertFormDataToObject.stories.tsx +27 -0
- package/src/utils/formData/ConvertFormDataToObject.ts +14 -0
- package/src/utils/getExtension/getExtension.stories.tsx +1 -0
- package/src/utils/keyBoardActionUtil/UseKeyboardAction.stories.tsx +53 -0
- package/src/utils/keyBoardActionUtil/UseKeyboardActions.tsx +20 -0
- package/src/utils/keyBoardActionUtil/types.ts +4 -0
- package/src/validations/regex.stories.tsx +63 -0
- package/src/validations/regex.ts +34 -0
- package/src/assets/images/photo.png +0 -0
|
@@ -27,6 +27,8 @@ const CustomDatePicker: React.FC<DatePickerProps> = ({
|
|
|
27
27
|
error,
|
|
28
28
|
helperText = '',
|
|
29
29
|
dateOnly = false,
|
|
30
|
+
className,
|
|
31
|
+
zIndex = 10,
|
|
30
32
|
}) => {
|
|
31
33
|
const [timeValue, setTimeValue] = useState<string>('');
|
|
32
34
|
const [selectedDate, setSelectedDate] = useState<Date | undefined>();
|
|
@@ -36,17 +38,21 @@ const CustomDatePicker: React.FC<DatePickerProps> = ({
|
|
|
36
38
|
new Date()
|
|
37
39
|
);
|
|
38
40
|
const [view, setView] = useState<string>('days');
|
|
41
|
+
|
|
42
|
+
const selectedDateRef = useRef<Date | undefined>(undefined);
|
|
39
43
|
const [startYear, setStartYear] = useState(() => {
|
|
40
44
|
const currentYear =
|
|
41
45
|
selectedMonth?.getFullYear() ?? new Date().getFullYear();
|
|
42
46
|
return currentYear - (currentYear % 12); // Set to the first year in the 12-year range
|
|
43
47
|
});
|
|
44
|
-
|
|
45
|
-
'top' | 'bottom'
|
|
46
|
-
>('bottom');
|
|
48
|
+
|
|
47
49
|
const pickerRef = useRef<HTMLDivElement>(null); // Ref to track the picker
|
|
48
50
|
const containerRef = useRef<HTMLDivElement>(null);
|
|
49
51
|
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
selectedDateRef.current = selectedDate;
|
|
54
|
+
}, [selectedDate]);
|
|
55
|
+
|
|
50
56
|
useEffect(() => {
|
|
51
57
|
if (value) {
|
|
52
58
|
setTimeValue(formatTimeStr(value));
|
|
@@ -79,30 +85,32 @@ const CustomDatePicker: React.FC<DatePickerProps> = ({
|
|
|
79
85
|
const adjustPosition = () => {
|
|
80
86
|
if (containerRef.current && pickerRef.current) {
|
|
81
87
|
const relativeRect = containerRef.current.getBoundingClientRect();
|
|
82
|
-
const
|
|
88
|
+
const pickerHeight = pickerRef.current.offsetHeight;
|
|
89
|
+
const spacing = 5; // spacing in pixels
|
|
83
90
|
|
|
84
91
|
const spaceBelow = window.innerHeight - relativeRect.bottom;
|
|
85
92
|
const spaceAbove = relativeRect.top;
|
|
86
93
|
|
|
87
|
-
|
|
88
|
-
if (
|
|
89
|
-
|
|
90
|
-
spaceAbove >= absoluteRect.height
|
|
91
|
-
) {
|
|
92
|
-
setDatePickerPosition('top');
|
|
93
|
-
} else {
|
|
94
|
-
setDatePickerPosition('bottom');
|
|
94
|
+
let top = relativeRect.bottom + window.scrollY + spacing; // Default position to below
|
|
95
|
+
if (spaceBelow < pickerHeight && spaceAbove >= pickerHeight) {
|
|
96
|
+
top = relativeRect.top + window.scrollY - pickerHeight - spacing; // Place above
|
|
95
97
|
}
|
|
98
|
+
|
|
99
|
+
// Horizontal position: align to container with optional adjustments
|
|
100
|
+
const left = relativeRect.left + window.scrollX;
|
|
101
|
+
|
|
102
|
+
pickerRef.current.style.top = `${top}px`;
|
|
103
|
+
pickerRef.current.style.left = `${left}px`;
|
|
96
104
|
}
|
|
97
105
|
};
|
|
98
106
|
|
|
99
|
-
// Initial
|
|
107
|
+
// Initial adjustment
|
|
100
108
|
adjustPosition();
|
|
101
109
|
|
|
102
|
-
//
|
|
110
|
+
// Recalculate on resize
|
|
103
111
|
window.addEventListener('resize', adjustPosition);
|
|
104
112
|
return () => window.removeEventListener('resize', adjustPosition);
|
|
105
|
-
}, []);
|
|
113
|
+
}, [isPickerOpen]);
|
|
106
114
|
|
|
107
115
|
const calendarStyle = {
|
|
108
116
|
'--rdp-day-width': calendarWidth ? `${calendarWidth / 7 - 4}px` : undefined,
|
|
@@ -143,7 +151,8 @@ const CustomDatePicker: React.FC<DatePickerProps> = ({
|
|
|
143
151
|
};
|
|
144
152
|
|
|
145
153
|
const handleSave = () => {
|
|
146
|
-
|
|
154
|
+
console.log('selectedDate1', selectedDateRef.current);
|
|
155
|
+
onChange(selectedDateRef.current);
|
|
147
156
|
resetAndCloseDatePicker();
|
|
148
157
|
};
|
|
149
158
|
|
|
@@ -370,7 +379,7 @@ const CustomDatePicker: React.FC<DatePickerProps> = ({
|
|
|
370
379
|
};
|
|
371
380
|
|
|
372
381
|
return (
|
|
373
|
-
<div className=
|
|
382
|
+
<div className={`ff-date-picker ${className}`} ref={containerRef}>
|
|
374
383
|
<div className="ff-datepicker-input-container">
|
|
375
384
|
<div className="ff-input-with-icon ff-date-input-field">
|
|
376
385
|
<Icon
|
|
@@ -423,8 +432,7 @@ const CustomDatePicker: React.FC<DatePickerProps> = ({
|
|
|
423
432
|
className="ff-date-picker-container"
|
|
424
433
|
ref={pickerRef}
|
|
425
434
|
style={{
|
|
426
|
-
|
|
427
|
-
bottom: datePickerPosition === 'top' ? '110%' : 'auto',
|
|
435
|
+
zIndex,
|
|
428
436
|
}}
|
|
429
437
|
>
|
|
430
438
|
<div className="ff-calendar-container">
|
|
@@ -158,6 +158,8 @@ export interface DrawerProps {
|
|
|
158
158
|
* Custom overflow for the drawer
|
|
159
159
|
*/
|
|
160
160
|
overflow?: string;
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
/**
|
|
162
|
+
* Callback function returns a boolean value when the drawer is collapsed.
|
|
163
|
+
*/
|
|
164
|
+
onCollapse?: (value: boolean) => void;
|
|
163
165
|
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
border-bottom: 1px dashed var(--ff-editor-border-color);
|
|
7
|
-
border-left: 1px solid var(--ff-editor-border-color);
|
|
1
|
+
@mixin folding-icon-styles($color: var(--base-bg-color), $zIndex: 999999, $opacity: 1) {
|
|
2
|
+
color: $color !important;
|
|
3
|
+
fill: $color !important;
|
|
4
|
+
z-index: $zIndex !important;
|
|
5
|
+
opacity: $opacity !important;
|
|
8
6
|
}
|
|
9
7
|
|
|
10
8
|
/* Style for the line number gutter */
|
|
11
9
|
.monaco-editor .margin {
|
|
12
10
|
background-color: var(--ff-editor-gutter-color) !important;
|
|
13
|
-
width: 32px !important;
|
|
14
11
|
}
|
|
15
12
|
|
|
16
13
|
/* Style for the line numbers */
|
|
@@ -34,10 +31,6 @@
|
|
|
34
31
|
width: 100% !important;
|
|
35
32
|
}
|
|
36
33
|
|
|
37
|
-
.monaco-scrollable-element {
|
|
38
|
-
left: 32px !important;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
34
|
.monaco-editor .current-line-background {
|
|
42
35
|
background-color: var(--ff-editor-line-bg) !important;
|
|
43
36
|
}
|
|
@@ -46,11 +39,23 @@
|
|
|
46
39
|
display: flex;
|
|
47
40
|
flex-direction: column;
|
|
48
41
|
gap: 10px;
|
|
49
|
-
.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
.monaco-editor {
|
|
43
|
+
border-radius: 6px;
|
|
44
|
+
border-top: 1px solid var(--ff-editor-border-color);
|
|
45
|
+
border-right: 1px dashed var(--ff-editor-border-color);
|
|
46
|
+
border-bottom: 1px dashed var(--ff-editor-border-color);
|
|
47
|
+
border-left: 1px solid var(--ff-editor-border-color);
|
|
48
|
+
}
|
|
49
|
+
.monaco-editor .cldr.codicon.codicon-folding-collapsed,
|
|
50
|
+
.monaco-editor .cldr.codicon.codicon-folding-expanded,
|
|
51
|
+
.monaco-editor .cldr.codicon.codicon-folding-manual-collapsed,
|
|
52
|
+
.monaco-editor .cldr.codicon.codicon-folding-manual-expanded {
|
|
53
|
+
@include folding-icon-styles()
|
|
54
|
+
}
|
|
55
|
+
.monaco-editor .cldr.codicon.codicon-folding-expanded {
|
|
56
|
+
@include folding-icon-styles()
|
|
57
|
+
}
|
|
58
|
+
.cldr.codicon.codicon-folding-manual-collapsed {
|
|
59
|
+
@include folding-icon-styles()
|
|
55
60
|
}
|
|
56
61
|
}
|
|
@@ -218,8 +218,8 @@ const Editor = forwardRef<any, EditorProps>(
|
|
|
218
218
|
return (
|
|
219
219
|
<div style={{ width, height }} className="ff-editor-container">
|
|
220
220
|
<MonacoEditor
|
|
221
|
-
height=
|
|
222
|
-
width=
|
|
221
|
+
height={height}
|
|
222
|
+
width={width}
|
|
223
223
|
language={language}
|
|
224
224
|
value={value}
|
|
225
225
|
options={{
|
|
@@ -5,14 +5,17 @@ import { ContextMenuState } from '../ExcelFile/ExcelFileComponents/types';
|
|
|
5
5
|
|
|
6
6
|
type ExcelContextMenuProps = {
|
|
7
7
|
contextMenu: ContextMenuState;
|
|
8
|
-
position:{ x: number; y: number }
|
|
8
|
+
position: { x: number; y: number };
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
-
const ExcelContextMenu: React.FC<ExcelContextMenuProps> = ({
|
|
11
|
+
const ExcelContextMenu: React.FC<ExcelContextMenuProps> = ({
|
|
12
|
+
contextMenu,
|
|
13
|
+
position,
|
|
14
|
+
}) => {
|
|
12
15
|
return (
|
|
13
16
|
<div
|
|
14
17
|
className="ff-excel-menu"
|
|
15
|
-
style={{ left:position.x, top:position.y }}
|
|
18
|
+
style={{ left: position.x, top: position.y }}
|
|
16
19
|
>
|
|
17
20
|
{contextMenu.options.map((option) => (
|
|
18
21
|
<div
|
|
@@ -1,55 +1,59 @@
|
|
|
1
|
-
.ff-excel
|
|
1
|
+
.ff-excel {
|
|
2
2
|
position: relative;
|
|
3
|
-
top: 0;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.ff-excel-sheet-bar {
|
|
7
|
-
position: static;
|
|
8
|
-
max-width: 100%;
|
|
9
|
-
margin-left: 60px;
|
|
10
|
-
display: flex;
|
|
11
|
-
height: 36px;
|
|
12
|
-
align-items: center;
|
|
13
|
-
color: var(--brand2-color);
|
|
14
|
-
box-shadow: 0px 0px 4px -1px var(--toggle-strip-shadow);
|
|
15
3
|
|
|
16
|
-
.ff-excel-
|
|
4
|
+
.ff-excel-sheet {
|
|
17
5
|
position: relative;
|
|
18
|
-
background-color: var(--tab-bg-color);
|
|
19
|
-
display: flex;
|
|
20
|
-
align-items: center;
|
|
21
|
-
justify-content: center;
|
|
22
|
-
width: 40px;
|
|
23
6
|
top: 0;
|
|
24
|
-
left: 0px;
|
|
25
|
-
height: 100%;
|
|
26
|
-
|
|
27
|
-
.ff-excel-add-sheet-icon {
|
|
28
|
-
padding: 8px 10px;
|
|
29
|
-
}
|
|
30
7
|
}
|
|
31
8
|
|
|
32
|
-
.ff-excel-
|
|
33
|
-
|
|
9
|
+
.ff-excel-sheet-bar {
|
|
10
|
+
position: static;
|
|
11
|
+
max-width: 100%;
|
|
12
|
+
margin-left: 60px;
|
|
34
13
|
display: flex;
|
|
35
|
-
|
|
14
|
+
height: 36px;
|
|
36
15
|
align-items: center;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
cursor: pointer;
|
|
16
|
+
color: var(--brand2-color);
|
|
17
|
+
box-shadow: 0px 0px 4px -1px var(--toggle-strip-shadow);
|
|
18
|
+
|
|
19
|
+
.ff-excel-add-sheet-set {
|
|
20
|
+
position: relative;
|
|
21
|
+
background-color: var(--tab-bg-color);
|
|
44
22
|
display: flex;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
width: 40px;
|
|
26
|
+
top: 0;
|
|
27
|
+
left: 0px;
|
|
28
|
+
height: 100%;
|
|
29
|
+
|
|
30
|
+
.ff-excel-add-sheet-icon {
|
|
31
|
+
padding: 8px 10px;
|
|
48
32
|
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.ff-excel-tab-container {
|
|
36
|
+
height: 36px;
|
|
37
|
+
display: flex;
|
|
38
|
+
overflow-x: auto;
|
|
39
|
+
align-items: center;
|
|
40
|
+
scrollbar-width: none;
|
|
41
|
+
|
|
42
|
+
.ff-excel-tab-list {
|
|
43
|
+
margin-top: 2px;
|
|
44
|
+
padding: 10px 9px;
|
|
45
|
+
min-width: max-content;
|
|
46
|
+
cursor: pointer;
|
|
47
|
+
display: flex;
|
|
48
|
+
background-color: var(--hover-color);
|
|
49
|
+
&.active {
|
|
50
|
+
background-color: var(--excel-sheet-button-color);
|
|
51
|
+
}
|
|
49
52
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
+
&:focus {
|
|
54
|
+
outline: none;
|
|
55
|
+
text-decoration: none;
|
|
56
|
+
}
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
59
|
}
|
|
@@ -17,36 +17,36 @@ import { checkEmpty } from '../../../utils/checkEmpty/checkEmpty';
|
|
|
17
17
|
|
|
18
18
|
interface ExcelFileProps {
|
|
19
19
|
/** The Excel data containing sheets and their content */
|
|
20
|
-
excelData:
|
|
21
|
-
sheets: WorkSheet[];
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
heightType?: string;
|
|
20
|
+
excelData: WorkSheet[];
|
|
25
21
|
|
|
26
22
|
/** Optional: Provide context menu options for actions like right-click */
|
|
27
23
|
contextOption?: {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
open: boolean;
|
|
25
|
+
options: {
|
|
26
|
+
label: string;
|
|
27
|
+
value: string;
|
|
28
|
+
iconName: string;
|
|
29
|
+
action: () => void;
|
|
30
|
+
}[];
|
|
31
|
+
};
|
|
32
32
|
|
|
33
33
|
/** Controls whether the toolbar is shown, disabled, or hidden */
|
|
34
34
|
toolbar?: 'show' | 'disable' | 'hide';
|
|
35
35
|
|
|
36
36
|
/** Callback function to save the Excel data */
|
|
37
37
|
onSave?: (saveData: any) => void;
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
contextHeightPositioning?: number;
|
|
39
|
+
contextWidthPositioning?: number;
|
|
40
40
|
/** Set your dynamic sheet Height*/
|
|
41
41
|
sheetHeight?: string;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
const ExcelFile: React.FC<ExcelFileProps> = ({
|
|
45
45
|
excelData,
|
|
46
|
+
contextOption,
|
|
46
47
|
sheetHeight = '100%',
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
contextWidth = 0,
|
|
48
|
+
contextHeightPositioning = 0,
|
|
49
|
+
contextWidthPositioning = 0,
|
|
50
50
|
onSave = (saveData) => {
|
|
51
51
|
saveData();
|
|
52
52
|
},
|
|
@@ -128,49 +128,55 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
|
|
|
128
128
|
|
|
129
129
|
useEffect(() => {
|
|
130
130
|
const payload = excelData;
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
131
|
+
if (payload) {
|
|
132
|
+
const sheetNames = payload.map((e) => e.sheetName);
|
|
133
|
+
setSheetNames(sheetNames);
|
|
134
|
+
if (checkEmpty(sheetNames.length)) {
|
|
135
|
+
pageRef.current = sheetNames[0] ? sheetNames[0] : ''; //Ternary is required, must use ''
|
|
136
|
+
setSelectedSheet({
|
|
137
|
+
name: sheetNames[0] ? sheetNames[0] : '', //Ternary is required, must use ''
|
|
138
|
+
index: 0,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
const newWorksheetsData: { [key: string]: Matrix.Matrix<CellBase> } = {};
|
|
142
|
+
payload.forEach((sheet) => {
|
|
143
|
+
const sheetName = sheet.sheetName;
|
|
144
|
+
const json = sheet.data;
|
|
145
|
+
const maxRows = Math.max(26, json.length + 2);
|
|
146
|
+
const maxCols = Math.max(
|
|
147
|
+
26,
|
|
148
|
+
Math.max(...json.map((row) => row.length)) + 2
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
let spreadsheetData: Matrix.Matrix<CellBase> = Array.from(
|
|
152
|
+
{ length: maxRows },
|
|
153
|
+
() => Array.from({ length: maxCols }, () => EmptyRow)
|
|
154
|
+
);
|
|
155
|
+
json.forEach((row, rowIndex) => {
|
|
156
|
+
row.forEach((cell, colIndex) => {
|
|
157
|
+
if (rowIndex < maxRows && colIndex < maxCols) {
|
|
158
|
+
if (!spreadsheetData[rowIndex]) {
|
|
159
|
+
spreadsheetData[rowIndex] = [];
|
|
160
|
+
}
|
|
161
|
+
spreadsheetData[rowIndex][colIndex] = {
|
|
162
|
+
value: checkVal(cell.value),
|
|
163
|
+
style: convertStyleToFrontend(cell?.style),
|
|
164
|
+
type: true,
|
|
165
|
+
};
|
|
156
166
|
}
|
|
157
|
-
|
|
158
|
-
value: checkVal(cell.value),
|
|
159
|
-
style: convertStyleToFrontend(cell?.style),
|
|
160
|
-
type: true,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
167
|
+
});
|
|
163
168
|
});
|
|
164
|
-
});
|
|
165
169
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
newWorksheetsData[sheetName] = spreadsheetData;
|
|
171
|
+
});
|
|
172
|
+
setWorksheetsData(newWorksheetsData);
|
|
173
|
+
const firstSheetName = Object.keys(newWorksheetsData)[0];
|
|
174
|
+
if (firstSheetName && newWorksheetsData[firstSheetName] !== undefined) {
|
|
175
|
+
setSelectedSheetData(newWorksheetsData[firstSheetName]);
|
|
176
|
+
}
|
|
172
177
|
}
|
|
173
|
-
}, []);
|
|
178
|
+
}, [excelData]);
|
|
179
|
+
|
|
174
180
|
const handleSave = React.useCallback(
|
|
175
181
|
(event: KeyboardEvent) => {
|
|
176
182
|
if (event.ctrlKey && event.key === 's') {
|
|
@@ -237,7 +243,6 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
|
|
|
237
243
|
}),
|
|
238
244
|
};
|
|
239
245
|
onSave(savedData);
|
|
240
|
-
toast.success('File saved successfully!');
|
|
241
246
|
};
|
|
242
247
|
|
|
243
248
|
const onEvaluateChange = (data: Matrix.Matrix<CellBase>) => {
|
|
@@ -422,10 +427,8 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
|
|
|
422
427
|
|
|
423
428
|
React.useEffect(() => {
|
|
424
429
|
document.addEventListener('click', handleClickOutside);
|
|
425
|
-
// document.addEventListener('contextmenu', handleClickOutside);
|
|
426
430
|
return () => {
|
|
427
431
|
document.removeEventListener('click', handleClickOutside);
|
|
428
|
-
// document.removeEventListener('contextmenu', handleClickOutside);
|
|
429
432
|
};
|
|
430
433
|
}, [handleClickOutside]);
|
|
431
434
|
|
|
@@ -449,22 +452,23 @@ const ExcelFile: React.FC<ExcelFileProps> = ({
|
|
|
449
452
|
options: options,
|
|
450
453
|
});
|
|
451
454
|
};
|
|
455
|
+
const setContextPosition = (event: React.MouseEvent) => {
|
|
456
|
+
event.preventDefault();
|
|
457
|
+
setPosition({
|
|
458
|
+
x: event.pageX + contextWidthPositioning,
|
|
459
|
+
y: event.pageY + contextHeightPositioning,
|
|
460
|
+
});
|
|
461
|
+
};
|
|
452
462
|
|
|
453
463
|
return (
|
|
454
464
|
<>
|
|
455
465
|
{sheetNames.length > 0 && (
|
|
456
|
-
<div
|
|
457
|
-
style={{ position: 'relative' }}
|
|
458
|
-
onContextMenu={(event) => {
|
|
459
|
-
const xPosition = heightType === 'page' ? event.pageX : event.clientX;
|
|
460
|
-
const yPosition = heightType === 'page' ? event.pageY : event.clientY;
|
|
461
|
-
setPosition({ x: xPosition+contextWidth, y:yPosition+contextHeight});
|
|
462
|
-
}}
|
|
463
|
-
>
|
|
466
|
+
<div className="ff-excel" onContextMenu={setContextPosition}>
|
|
464
467
|
<div ref={sheetRef} className="ff-excel-sheet">
|
|
465
468
|
<Spreadsheet
|
|
466
469
|
sheetHeight={sheetHeight}
|
|
467
470
|
setContextMenu={setContextMenu}
|
|
471
|
+
contextOption={contextOption}
|
|
468
472
|
data={selectedSheetData}
|
|
469
473
|
onEvaluatedDataChange={onEvaluateChange}
|
|
470
474
|
/>
|
|
@@ -10,6 +10,17 @@ import * as Matrix from './matrix';
|
|
|
10
10
|
|
|
11
11
|
type Props = {
|
|
12
12
|
DataEditor: Types.DataEditorComponent;
|
|
13
|
+
setContextMenu:React.Dispatch<React.SetStateAction<ContextMenuState>>;
|
|
14
|
+
contextOption?: {
|
|
15
|
+
open: boolean;
|
|
16
|
+
options: {
|
|
17
|
+
label: string;
|
|
18
|
+
value: string;
|
|
19
|
+
iconName: string;
|
|
20
|
+
action: () => void;
|
|
21
|
+
}[];
|
|
22
|
+
};
|
|
23
|
+
|
|
13
24
|
};
|
|
14
25
|
|
|
15
26
|
const ActiveCell: React.FC<Props> = (props) => {
|
|
@@ -53,7 +64,7 @@ const ActiveCell: React.FC<Props> = (props) => {
|
|
|
53
64
|
width: (dimensionValue?.width ?? 0) + 1,
|
|
54
65
|
};
|
|
55
66
|
return dimensionValue;
|
|
56
|
-
})
|
|
67
|
+
});``
|
|
57
68
|
|
|
58
69
|
const hidden = React.useMemo(
|
|
59
70
|
() => !active || !dimensions,
|
|
@@ -126,6 +137,22 @@ const ActiveCell: React.FC<Props> = (props) => {
|
|
|
126
137
|
}
|
|
127
138
|
}, [activate, autoFill, active]);
|
|
128
139
|
|
|
140
|
+
const contextClick = React.useCallback(
|
|
141
|
+
(event: React.MouseEvent) => {
|
|
142
|
+
event.preventDefault();
|
|
143
|
+
|
|
144
|
+
props.setContextMenu({
|
|
145
|
+
open: props.contextOption?.open ?? false,
|
|
146
|
+
position: {
|
|
147
|
+
x: event.pageX - 450,
|
|
148
|
+
y: event.pageY - 260,
|
|
149
|
+
},
|
|
150
|
+
options: props.contextOption?.options || [],
|
|
151
|
+
});
|
|
152
|
+
},
|
|
153
|
+
[props]
|
|
154
|
+
);
|
|
155
|
+
|
|
129
156
|
return hidden ? null : (
|
|
130
157
|
<div
|
|
131
158
|
ref={rootRef}
|
|
@@ -134,6 +161,7 @@ const ActiveCell: React.FC<Props> = (props) => {
|
|
|
134
161
|
`ff-spreadsheet-active-cell--${mode}`
|
|
135
162
|
)}
|
|
136
163
|
style={dimensions}
|
|
164
|
+
onContextMenu={contextClick}
|
|
137
165
|
onClick={mode === 'view' && !readOnly ? edit : undefined}
|
|
138
166
|
tabIndex={0}
|
|
139
167
|
>
|
|
@@ -22,7 +22,6 @@ export const Cell: React.FC<Types.CellComponentProps> = ({
|
|
|
22
22
|
activate,
|
|
23
23
|
setCellDimensions,
|
|
24
24
|
setCellData,
|
|
25
|
-
setContextMenu,
|
|
26
25
|
}): React.ReactElement => {
|
|
27
26
|
const rootRef = React.useRef<HTMLTableCellElement | null>(null);
|
|
28
27
|
const point = React.useMemo(
|
|
@@ -33,23 +32,6 @@ export const Cell: React.FC<Types.CellComponentProps> = ({
|
|
|
33
32
|
[row, column]
|
|
34
33
|
);
|
|
35
34
|
|
|
36
|
-
let options = [
|
|
37
|
-
{
|
|
38
|
-
label: 'Get data from Header',
|
|
39
|
-
value: 'Get data from Header',
|
|
40
|
-
iconName: 'success',
|
|
41
|
-
disable: false,
|
|
42
|
-
action: () => {},
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
label: 'Get Cell Value',
|
|
46
|
-
value: 'Get Cell Value',
|
|
47
|
-
iconName: 'success',
|
|
48
|
-
disable: false,
|
|
49
|
-
action: () => {},
|
|
50
|
-
},
|
|
51
|
-
];
|
|
52
|
-
|
|
53
35
|
const handleMouseDown = React.useCallback(
|
|
54
36
|
(event: React.MouseEvent<HTMLTableCellElement>) => {
|
|
55
37
|
if (mode === 'view') {
|
|
@@ -75,22 +57,6 @@ export const Cell: React.FC<Types.CellComponentProps> = ({
|
|
|
75
57
|
[setCellDimensions, select, dragging, point]
|
|
76
58
|
);
|
|
77
59
|
|
|
78
|
-
const contextClick = React.useCallback(
|
|
79
|
-
(event: React.MouseEvent) => {
|
|
80
|
-
event.preventDefault();
|
|
81
|
-
select(point);
|
|
82
|
-
setContextMenu({
|
|
83
|
-
open: true,
|
|
84
|
-
position: {
|
|
85
|
-
x: event.pageX - 50,
|
|
86
|
-
y: event.pageY - 260,
|
|
87
|
-
},
|
|
88
|
-
options: options,
|
|
89
|
-
});
|
|
90
|
-
},
|
|
91
|
-
[setContextMenu, select, point]
|
|
92
|
-
);
|
|
93
|
-
|
|
94
60
|
React.useEffect(() => {
|
|
95
61
|
const root = rootRef.current;
|
|
96
62
|
if (selected && root) {
|
|
@@ -115,12 +81,10 @@ export const Cell: React.FC<Types.CellComponentProps> = ({
|
|
|
115
81
|
})}
|
|
116
82
|
onMouseEnter={handleMouseOver}
|
|
117
83
|
onMouseDown={handleMouseDown}
|
|
118
|
-
onContextMenu={contextClick}
|
|
119
84
|
tabIndex={0}
|
|
120
85
|
>
|
|
121
86
|
<DataViewer
|
|
122
87
|
row={row}
|
|
123
|
-
setContextMenu={setContextMenu}
|
|
124
88
|
column={column}
|
|
125
89
|
cell={data}
|
|
126
90
|
evaluatedCell={evaluatedData}
|