pixel-react 1.1.8 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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/AppHeader/types.d.ts +7 -7
- package/lib/components/Drawer/Drawer.stories.d.ts +2 -0
- package/lib/components/Drawer/Types.d.ts +11 -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/Icon/Icon.stories.d.ts +1 -0
- package/lib/components/Icon/types.d.ts +1 -0
- package/lib/components/IconRadioGroup/IconRadioGroup.d.ts +5 -0
- package/lib/components/IconRadioGroup/IconRadioGroup.stories.d.ts +7 -0
- package/lib/components/IconRadioGroup/index.d.ts +1 -0
- package/lib/components/IconRadioGroup/type.d.ts +41 -0
- package/lib/components/Table/Table.d.ts +1 -1
- package/lib/components/Table/Table.stories.d.ts +2 -0
- package/lib/components/Table/Types.d.ts +16 -0
- package/lib/index.d.ts +81 -9
- package/lib/index.esm.js +739 -248
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +739 -247
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utils/find/findAndInsert.d.ts +7 -0
- package/lib/utils/find/findAndInsert.stories.d.ts +7 -0
- package/package.json +4 -2
- package/src/assets/Themes/BaseTheme.scss +4 -0
- package/src/assets/Themes/DarkTheme.scss +4 -0
- package/src/assets/icons/all_borders.svg +3 -0
- package/src/assets/icons/bold.svg +3 -0
- package/src/assets/icons/border_bottom.svg +3 -0
- package/src/assets/icons/border_left.svg +3 -0
- package/src/assets/icons/border_right.svg +3 -0
- package/src/assets/icons/border_top.svg +3 -0
- package/src/assets/icons/clone_icon.svg +3 -0
- package/src/assets/icons/double_underline.svg +5 -0
- package/src/assets/icons/eye_closed.svg +3 -0
- package/src/assets/icons/fill_color.svg +7 -0
- package/src/assets/icons/formate_painter.svg +5 -0
- package/src/assets/icons/full_access_icon.svg +4 -0
- package/src/assets/icons/history_icon.svg +19 -0
- package/src/assets/icons/italic.svg +3 -0
- package/src/assets/icons/jira.svg +3 -0
- package/src/assets/icons/linked_defects.svg +11 -0
- package/src/assets/icons/move_icon.svg +5 -0
- package/src/assets/icons/no_access_icon.svg +4 -0
- package/src/assets/icons/no_border.svg +3 -0
- package/src/assets/icons/strike_through.svg +3 -0
- package/src/assets/icons/text_align_center.svg +3 -0
- package/src/assets/icons/text_align_left.svg +3 -0
- package/src/assets/icons/text_align_right.svg +3 -0
- package/src/assets/icons/text_color.svg +3 -0
- package/src/assets/icons/underline.svg +4 -0
- package/src/assets/icons/view_access_icon.svg +4 -0
- package/src/components/AppHeader/AppHeader.scss +23 -10
- package/src/components/AppHeader/AppHeader.stories.tsx +29 -28
- package/src/components/AppHeader/AppHeader.tsx +18 -16
- package/src/components/AppHeader/types.ts +7 -7
- package/src/components/Button/Button.scss +1 -0
- package/src/components/Checkbox/Checkbox.tsx +1 -1
- package/src/components/Drawer/Drawer.scss +13 -9
- package/src/components/Drawer/Drawer.stories.tsx +28 -0
- package/src/components/Drawer/Drawer.tsx +29 -6
- package/src/components/Drawer/Types.ts +11 -0
- package/src/components/ExcelFile/ChangeExcelStyles.tsx +78 -0
- package/src/components/ExcelFile/ColorBarselector/ColorBarSelector.scss +13 -0
- package/src/components/ExcelFile/ColorBarselector/ColorBarSelector.tsx +43 -0
- package/src/components/ExcelFile/ContextMenu/ContextMenu.scss +102 -0
- package/src/components/ExcelFile/ContextMenu/ContextMenu.tsx +104 -0
- package/src/components/ExcelFile/ExcelFile/Excel/ActiveCell.tsx +131 -0
- package/src/components/ExcelFile/ExcelFile/Excel/Cell.tsx +201 -0
- package/src/components/ExcelFile/ExcelFile/Excel/ColumnIndicator.tsx +123 -0
- package/src/components/ExcelFile/ExcelFile/Excel/Copied.tsx +25 -0
- package/src/components/ExcelFile/ExcelFile/Excel/CornerIndicator.tsx +49 -0
- package/src/components/ExcelFile/ExcelFile/Excel/DataEditor.tsx +37 -0
- package/src/components/ExcelFile/ExcelFile/Excel/DataViewer.tsx +46 -0
- package/src/components/ExcelFile/ExcelFile/Excel/FloatingRect.tsx +31 -0
- package/src/components/ExcelFile/ExcelFile/Excel/HeaderRow.tsx +5 -0
- package/src/components/ExcelFile/ExcelFile/Excel/Row.tsx +5 -0
- package/src/components/ExcelFile/ExcelFile/Excel/RowIndicator.tsx +102 -0
- package/src/components/ExcelFile/ExcelFile/Excel/Selected.tsx +32 -0
- package/src/components/ExcelFile/ExcelFile/Excel/Spreadsheet.css +144 -0
- package/src/components/ExcelFile/ExcelFile/Excel/Spreadsheet.tsx +494 -0
- package/src/components/ExcelFile/ExcelFile/Excel/Table.tsx +19 -0
- package/src/components/ExcelFile/ExcelFile/Excel/actions.ts +302 -0
- package/src/components/ExcelFile/ExcelFile/Excel/areModelsEqual.ts +18 -0
- package/src/components/ExcelFile/ExcelFile/Excel/context.ts +12 -0
- package/src/components/ExcelFile/ExcelFile/Excel/engine/engine.ts +200 -0
- package/src/components/ExcelFile/ExcelFile/Excel/engine/formula.ts +137 -0
- package/src/components/ExcelFile/ExcelFile/Excel/engine/index.ts +2 -0
- package/src/components/ExcelFile/ExcelFile/Excel/engine/point-graph.ts +154 -0
- package/src/components/ExcelFile/ExcelFile/Excel/engine/point-hash.ts +10 -0
- package/src/components/ExcelFile/ExcelFile/Excel/engine/point-set.ts +69 -0
- package/src/components/ExcelFile/ExcelFile/Excel/index.ts +48 -0
- package/src/components/ExcelFile/ExcelFile/Excel/matrix.ts +388 -0
- package/src/components/ExcelFile/ExcelFile/Excel/point-range.ts +82 -0
- package/src/components/ExcelFile/ExcelFile/Excel/point.ts +15 -0
- package/src/components/ExcelFile/ExcelFile/Excel/reducer.ts +682 -0
- package/src/components/ExcelFile/ExcelFile/Excel/selection.ts +257 -0
- package/src/components/ExcelFile/ExcelFile/Excel/types.ts +269 -0
- package/src/components/ExcelFile/ExcelFile/Excel/typings/fast-formula-parser.d.ts +58 -0
- package/src/components/ExcelFile/ExcelFile/Excel/use-dispatch.ts +8 -0
- package/src/components/ExcelFile/ExcelFile/Excel/use-selector.ts +9 -0
- package/src/components/ExcelFile/ExcelFile/Excel/util.ts +173 -0
- package/src/components/ExcelFile/ExcelFile/ExcelFile.scss +27 -0
- package/src/components/ExcelFile/ExcelFile/ExcelFile.tsx +520 -0
- package/src/components/ExcelFile/ExcelFile.stories.tsx +132 -0
- package/src/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.scss +16 -0
- package/src/components/ExcelFile/ExcelSheetBar/ExcelSheetBar.tsx +79 -0
- package/src/components/ExcelFile/ExcelToolBar/ExcelToolBar.scss +22 -0
- package/src/components/ExcelFile/ExcelToolBar/ExcelToolBar.tsx +271 -0
- package/src/components/ExcelFile/ImportExcelStyles.tsx +86 -0
- package/src/components/ExcelFile/Types.ts +241 -0
- package/src/components/ExcelFile/index.ts +1 -0
- package/src/components/Icon/Icon.stories.tsx +27 -0
- package/src/components/Icon/Icon.tsx +5 -1
- package/src/components/Icon/Icons.scss +15 -5
- package/src/components/Icon/iconList.ts +52 -1
- package/src/components/Icon/types.ts +1 -0
- package/src/components/IconRadioGroup/IconRadioGroup.scss +60 -0
- package/src/components/IconRadioGroup/IconRadioGroup.stories.tsx +108 -0
- package/src/components/IconRadioGroup/IconRadioGroup.tsx +72 -0
- package/src/components/IconRadioGroup/index.ts +1 -0
- package/src/components/IconRadioGroup/type.ts +50 -0
- package/src/components/Modal/Modal.tsx +8 -1
- package/src/components/Modal/modal.scss +10 -2
- package/src/components/Table/Table.scss +16 -4
- package/src/components/Table/Table.stories.tsx +36 -12
- package/src/components/Table/Table.tsx +33 -16
- package/src/components/Table/Types.ts +121 -105
- package/src/index.ts +2 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
import React, { useState } from 'react';
|
2
|
+
import Tooltip from '../../Tooltip';
|
3
|
+
import Icon from '../../Icon';
|
4
|
+
import Tabs from '../../Tabs';
|
5
|
+
import { Col, Container, Row } from '../../GridLayout/GridLayout';
|
6
|
+
|
7
|
+
interface ExcelSheetBarProps {
|
8
|
+
fileDetails: {
|
9
|
+
sheetNames: string[]; // List of sheet names
|
10
|
+
};
|
11
|
+
handleSheetChange: (name: string, index: number) => void;
|
12
|
+
contextMenu: (e: React.MouseEvent, name: string, index: number) => void;
|
13
|
+
addSheet: () => void;
|
14
|
+
selectedSheet: { name: string };
|
15
|
+
contextSelect: (e: React.MouseEvent) => void;
|
16
|
+
}
|
17
|
+
|
18
|
+
const ExcelSheetBar: React.FC<ExcelSheetBarProps> = ({
|
19
|
+
fileDetails,
|
20
|
+
handleSheetChange,
|
21
|
+
contextMenu,
|
22
|
+
addSheet,
|
23
|
+
selectedSheet,
|
24
|
+
contextSelect,
|
25
|
+
}) => {
|
26
|
+
const [activeTabId, setActiveTabId] = useState<string>('0');
|
27
|
+
|
28
|
+
const tabsData = fileDetails.sheetNames.map((name, index) => ({
|
29
|
+
label: name,
|
30
|
+
components: (
|
31
|
+
<div
|
32
|
+
key={name}
|
33
|
+
className={`tab-request ${
|
34
|
+
name === selectedSheet.name ? 'active font-bold' : ''
|
35
|
+
}`}
|
36
|
+
onClick={() => handleSheetChange(name, index)}
|
37
|
+
onContextMenu={(e) => {
|
38
|
+
contextMenu(e, name, index);
|
39
|
+
contextSelect(e);
|
40
|
+
}}
|
41
|
+
>
|
42
|
+
{name}
|
43
|
+
</div>
|
44
|
+
),
|
45
|
+
id: index.toString(),
|
46
|
+
}));
|
47
|
+
|
48
|
+
return (
|
49
|
+
<>
|
50
|
+
<Container fluid>
|
51
|
+
<Row>
|
52
|
+
<Col size={0}>
|
53
|
+
<Tooltip title="Add Sheet" placement="top">
|
54
|
+
<Icon
|
55
|
+
className="cursor-pointer ml-1"
|
56
|
+
hoverEffect={true}
|
57
|
+
name="plus_icon"
|
58
|
+
height={20}
|
59
|
+
width={20}
|
60
|
+
onClick={addSheet}
|
61
|
+
/>
|
62
|
+
</Tooltip>
|
63
|
+
</Col>
|
64
|
+
<Col size={11}>
|
65
|
+
<Tabs
|
66
|
+
tabsData={tabsData}
|
67
|
+
activeTabId={activeTabId}
|
68
|
+
onTabClick={(tabId) => {
|
69
|
+
setActiveTabId(tabId);
|
70
|
+
}}
|
71
|
+
/>
|
72
|
+
</Col>
|
73
|
+
</Row>
|
74
|
+
</Container>
|
75
|
+
</>
|
76
|
+
);
|
77
|
+
};
|
78
|
+
|
79
|
+
export default ExcelSheetBar;
|
@@ -0,0 +1,22 @@
|
|
1
|
+
@import '../../../assets/styles/colors';
|
2
|
+
@import '../../../assets/styles/fonts';
|
3
|
+
|
4
|
+
.excel-toolbar {
|
5
|
+
display: flex;
|
6
|
+
align-items: center;
|
7
|
+
justify-content: space-evenly;
|
8
|
+
padding: 5px 0;
|
9
|
+
width: 100%;
|
10
|
+
|
11
|
+
.menu-option {
|
12
|
+
display: flex;
|
13
|
+
flex-direction: column;
|
14
|
+
align-items: center;
|
15
|
+
justify-content: center;
|
16
|
+
cursor: pointer;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
.excel-toolbar-hide {
|
21
|
+
display: none;
|
22
|
+
}
|
@@ -0,0 +1,271 @@
|
|
1
|
+
import { useEffect, useState } from 'react';
|
2
|
+
import './ExcelToolBar.scss';
|
3
|
+
import ColorBarSelector from '../ColorBarselector/ColorBarSelector';
|
4
|
+
import MenuOption from '../../MenuOption';
|
5
|
+
import Tooltip from '../../Tooltip';
|
6
|
+
import Icon from '../../Icon';
|
7
|
+
import classNames from 'classnames';
|
8
|
+
import Select from '../../Select';
|
9
|
+
|
10
|
+
let colors={grey_dark:"#000000"}
|
11
|
+
|
12
|
+
const ExcelToolBar: React.FC<ExcelToolBarProps> = ({
|
13
|
+
toolbar = 'show',
|
14
|
+
applyStyle,
|
15
|
+
formatePaint,
|
16
|
+
}) => {
|
17
|
+
const [borderType, setBorderType] = useState<string>('All Border');
|
18
|
+
const [textAlign, setTextAlign] = useState<string>('Text Left');
|
19
|
+
const [colorContainer, setColorPicker] = useState<ColorContainer>({
|
20
|
+
color: colors.grey_dark.replace('#', ''),
|
21
|
+
backgroundColor: colors.grey_dark.replace('#', ''),
|
22
|
+
borderColor: colors.grey_dark.replace('#', ''),
|
23
|
+
});
|
24
|
+
const [formatePainter, setFormatePainter] = useState<boolean>(false);
|
25
|
+
|
26
|
+
const borderTypeIcon = () =>{
|
27
|
+
|
28
|
+
return [
|
29
|
+
{ value: 'border-all-sides', label: 'All Border', icon: 'all_borders' },
|
30
|
+
{ value: 'border-bottom', label: 'Border Bottom', icon: 'border_bottom' },
|
31
|
+
{ value: 'border-left', label: 'Border Left', icon: 'border_left' },
|
32
|
+
{ value: 'border-right', label: 'Border Right', icon: 'border_right' },
|
33
|
+
{ value: 'border-top', label: 'Border Top', icon: 'border_top' },
|
34
|
+
{ value: 'border-none', label: 'No Border', icon: 'no_border' },
|
35
|
+
]
|
36
|
+
}
|
37
|
+
const TextAlignIcon = () => {
|
38
|
+
return [
|
39
|
+
{ label: 'Text Left', value: 'text-align-left', icon: 'text_align_left' },
|
40
|
+
{ label: 'Text Center', value: 'text-align-center', icon: 'text_align_center' },
|
41
|
+
{ label: 'Text Right', value: 'text-align-right', icon: 'text_align_right' },
|
42
|
+
];
|
43
|
+
};
|
44
|
+
|
45
|
+
const getTextColor = (color: string) => {
|
46
|
+
setColorPicker((prev) => ({ ...prev, color }));
|
47
|
+
};
|
48
|
+
|
49
|
+
const getBackgroundColor = (color: string) => {
|
50
|
+
setColorPicker((prev) => ({ ...prev, backgroundColor: color }));
|
51
|
+
};
|
52
|
+
|
53
|
+
useEffect(() => {
|
54
|
+
let timeGap = setTimeout(() => {
|
55
|
+
applyStyle('color', colorContainer.color);
|
56
|
+
}, 800);
|
57
|
+
return () => {
|
58
|
+
clearTimeout(timeGap);
|
59
|
+
};
|
60
|
+
}, [colorContainer.color]);
|
61
|
+
|
62
|
+
useEffect(() => {
|
63
|
+
let timeGap = setTimeout(() => {
|
64
|
+
applyStyle('backgroundColor', colorContainer.backgroundColor);
|
65
|
+
}, 800);
|
66
|
+
return () => {
|
67
|
+
clearTimeout(timeGap);
|
68
|
+
};
|
69
|
+
}, [colorContainer.backgroundColor]);
|
70
|
+
|
71
|
+
return (
|
72
|
+
<div
|
73
|
+
className={classNames('excel-toolbar', {
|
74
|
+
'excel-toolbar-hide': toolbar === 'hide',
|
75
|
+
})}
|
76
|
+
>
|
77
|
+
<Tooltip placement="top" title={'Bold'}>
|
78
|
+
<Icon
|
79
|
+
disabled={toolbar === 'disable'}
|
80
|
+
onClick={() => {
|
81
|
+
applyStyle('bold', true);
|
82
|
+
}}
|
83
|
+
name="bold"
|
84
|
+
/>
|
85
|
+
</Tooltip>
|
86
|
+
<Tooltip placement="top" title={'Italic'}>
|
87
|
+
<Icon
|
88
|
+
disabled={toolbar === 'disable'}
|
89
|
+
onClick={() => {
|
90
|
+
applyStyle('italic', true);
|
91
|
+
}}
|
92
|
+
name="italic"
|
93
|
+
/>
|
94
|
+
</Tooltip>
|
95
|
+
|
96
|
+
<Select
|
97
|
+
className='textType'
|
98
|
+
label="Text type"
|
99
|
+
onChange={()=>{}}
|
100
|
+
optionsList={[
|
101
|
+
{
|
102
|
+
label: 'Option 1',
|
103
|
+
value: '1'
|
104
|
+
},
|
105
|
+
{
|
106
|
+
label: 'Option 2',
|
107
|
+
value: '2'
|
108
|
+
},
|
109
|
+
{
|
110
|
+
label: 'Option 3',
|
111
|
+
value: '3'
|
112
|
+
}
|
113
|
+
]}
|
114
|
+
selectedOption={{
|
115
|
+
label: 'Option 2',
|
116
|
+
value: 'Arial'
|
117
|
+
}}
|
118
|
+
/>
|
119
|
+
<Select
|
120
|
+
label="Text Size"
|
121
|
+
onChange={()=>{}}
|
122
|
+
optionsList={[
|
123
|
+
{
|
124
|
+
label: 'Option 1',
|
125
|
+
value: '1'
|
126
|
+
},
|
127
|
+
{
|
128
|
+
label: 'Option 2',
|
129
|
+
value: '2'
|
130
|
+
},
|
131
|
+
{
|
132
|
+
label: 'Option 3',
|
133
|
+
value: '3'
|
134
|
+
}
|
135
|
+
]}
|
136
|
+
selectedOption={{
|
137
|
+
label: 'Option 2',
|
138
|
+
value: '11'
|
139
|
+
}}
|
140
|
+
/>
|
141
|
+
<div style={{display:"flex",alignItems:'center'}}>
|
142
|
+
<Tooltip placement="top" title={'Formate Painter'}>
|
143
|
+
<div className={formatePainter ? 'formate-painter-active' : ''}>
|
144
|
+
<Icon
|
145
|
+
disabled={toolbar === 'disable'}
|
146
|
+
onClick={() => {
|
147
|
+
setFormatePainter((prev) => !prev);
|
148
|
+
formatePaint();
|
149
|
+
}}
|
150
|
+
name="all_borders"
|
151
|
+
/>
|
152
|
+
</div>
|
153
|
+
</Tooltip>
|
154
|
+
<MenuOption
|
155
|
+
iconName="more"
|
156
|
+
options={borderTypeIcon()}
|
157
|
+
tooltipTitle="Border Type"
|
158
|
+
tooltipPlacement="top"
|
159
|
+
onOptionClick={(e) => {
|
160
|
+
setBorderType(borderType);
|
161
|
+
applyStyle('border', e.label);
|
162
|
+
}}
|
163
|
+
/>
|
164
|
+
</div>
|
165
|
+
<div style={{display:"flex",alignItems:'center'}}>
|
166
|
+
<Tooltip placement="top" title={'Formate Painter'}>
|
167
|
+
<div className={formatePainter ? 'formate-painter-active' : ''}>
|
168
|
+
<Icon
|
169
|
+
disabled={toolbar === 'disable'}
|
170
|
+
onClick={() => {
|
171
|
+
setFormatePainter((prev) => !prev);
|
172
|
+
formatePaint();
|
173
|
+
}}
|
174
|
+
name="text_align_left"
|
175
|
+
/>
|
176
|
+
</div>
|
177
|
+
</Tooltip>
|
178
|
+
<MenuOption
|
179
|
+
iconName="more"
|
180
|
+
options={TextAlignIcon()}
|
181
|
+
tooltipTitle="Text Align"
|
182
|
+
tooltipPlacement="top"
|
183
|
+
onOptionClick={(e) => {
|
184
|
+
setTextAlign(textAlign);
|
185
|
+
applyStyle('alignment', e.label);
|
186
|
+
}}
|
187
|
+
/>
|
188
|
+
</div>
|
189
|
+
<Tooltip placement="top" title={'Formate Painter'}>
|
190
|
+
<div className={formatePainter ? 'formate-painter-active' : ''}>
|
191
|
+
<Icon
|
192
|
+
disabled={toolbar === 'disable'}
|
193
|
+
onClick={() => {
|
194
|
+
setFormatePainter((prev) => !prev);
|
195
|
+
formatePaint();
|
196
|
+
}}
|
197
|
+
name="formate_painter"
|
198
|
+
/>
|
199
|
+
</div>
|
200
|
+
</Tooltip>
|
201
|
+
<Tooltip placement="top" title={'Formate Painter'}>
|
202
|
+
<div className={formatePainter ? 'formate-painter-active' : ''}>
|
203
|
+
<Icon
|
204
|
+
disabled={toolbar === 'disable'}
|
205
|
+
onClick={() => {
|
206
|
+
setFormatePainter((prev) => !prev);
|
207
|
+
formatePaint();
|
208
|
+
}}
|
209
|
+
name="strike_through"
|
210
|
+
/>
|
211
|
+
</div>
|
212
|
+
</Tooltip>
|
213
|
+
<Tooltip placement="top" title={'Formate Painter'}>
|
214
|
+
<div className={formatePainter ? 'formate-painter-active' : ''}>
|
215
|
+
<Icon
|
216
|
+
disabled={toolbar === 'disable'}
|
217
|
+
onClick={() => {
|
218
|
+
setFormatePainter((prev) => !prev);
|
219
|
+
formatePaint();
|
220
|
+
}}
|
221
|
+
name="underline"
|
222
|
+
/>
|
223
|
+
</div>
|
224
|
+
</Tooltip>
|
225
|
+
<Tooltip placement="top" title={'Formate Painter'}>
|
226
|
+
<div className={formatePainter ? 'formate-painter-active' : ''}>
|
227
|
+
<Icon
|
228
|
+
disabled={toolbar === 'disable'}
|
229
|
+
onClick={() => {
|
230
|
+
setFormatePainter((prev) => !prev);
|
231
|
+
formatePaint();
|
232
|
+
}}
|
233
|
+
name="double_underline"
|
234
|
+
/>
|
235
|
+
</div>
|
236
|
+
</Tooltip>
|
237
|
+
<div className="menu-option">
|
238
|
+
<Tooltip placement="top" title={'Text Color'}>
|
239
|
+
<Icon
|
240
|
+
disabled={toolbar === 'disable'}
|
241
|
+
onClick={() => {
|
242
|
+
applyStyle('color', colorContainer.color);
|
243
|
+
}}
|
244
|
+
name="text_color"
|
245
|
+
/>
|
246
|
+
<ColorBarSelector
|
247
|
+
disabled={toolbar === 'disable'}
|
248
|
+
getColorValue={getTextColor}
|
249
|
+
/>
|
250
|
+
</Tooltip>
|
251
|
+
</div>
|
252
|
+
<div className="menu-option">
|
253
|
+
<Tooltip placement="top" title={'Background Color'}>
|
254
|
+
<Icon
|
255
|
+
disabled={toolbar === 'disable'}
|
256
|
+
onClick={() => {
|
257
|
+
applyStyle('backgroundColor', colorContainer.backgroundColor);
|
258
|
+
}}
|
259
|
+
name="fill_color"
|
260
|
+
/>
|
261
|
+
</Tooltip>
|
262
|
+
<ColorBarSelector
|
263
|
+
disabled={toolbar === 'disable'}
|
264
|
+
getColorValue={getBackgroundColor}
|
265
|
+
/>
|
266
|
+
</div>
|
267
|
+
</div>
|
268
|
+
);
|
269
|
+
};
|
270
|
+
|
271
|
+
export default ExcelToolBar;
|
@@ -0,0 +1,86 @@
|
|
1
|
+
interface CellStyle {
|
2
|
+
color?: string;
|
3
|
+
backgroundColor?: string;
|
4
|
+
bold?: boolean;
|
5
|
+
italic?: boolean;
|
6
|
+
name?: string;
|
7
|
+
border: {
|
8
|
+
top: string;
|
9
|
+
bottom: string;
|
10
|
+
left: string;
|
11
|
+
right: string;
|
12
|
+
};
|
13
|
+
alignment: {
|
14
|
+
horizontal?: string;
|
15
|
+
vertical?: string;
|
16
|
+
wrapText?: boolean;
|
17
|
+
};
|
18
|
+
}
|
19
|
+
|
20
|
+
interface CellData {
|
21
|
+
style?: CellStyle;
|
22
|
+
}
|
23
|
+
|
24
|
+
type ImportExcelStylesData = Array<Array<CellData>>;
|
25
|
+
|
26
|
+
export default function ImportExcelStyles(data: ImportExcelStylesData | null) {
|
27
|
+
const getTable = document.querySelector(
|
28
|
+
'.Spreadsheet__table'
|
29
|
+
) as HTMLTableElement | null;
|
30
|
+
|
31
|
+
if (!getTable) {
|
32
|
+
return;
|
33
|
+
}
|
34
|
+
|
35
|
+
const tableRows = getTable.querySelectorAll('tr');
|
36
|
+
const tableHeader = getTable.querySelectorAll('th');
|
37
|
+
|
38
|
+
tableHeader.forEach((cell) => {
|
39
|
+
const cellText = cell.innerText.trim();
|
40
|
+
const isNumber = !isNaN(Number(cellText));
|
41
|
+
cell.style.width = isNumber ? '50px' : '150px';
|
42
|
+
});
|
43
|
+
|
44
|
+
if (data) {
|
45
|
+
data.forEach((row, rowIndex) => {
|
46
|
+
const rowData = tableRows[rowIndex + 1] as
|
47
|
+
| HTMLTableRowElement
|
48
|
+
| undefined;
|
49
|
+
|
50
|
+
if (!rowData) return;
|
51
|
+
|
52
|
+
const colData = rowData.querySelectorAll('.Spreadsheet__cell');
|
53
|
+
|
54
|
+
row.forEach((column, columnIndex) => {
|
55
|
+
if (colData[columnIndex] && column.style) {
|
56
|
+
const {
|
57
|
+
color,
|
58
|
+
backgroundColor,
|
59
|
+
bold,
|
60
|
+
italic,
|
61
|
+
name,
|
62
|
+
border,
|
63
|
+
alignment,
|
64
|
+
} = column.style;
|
65
|
+
const cell = colData[columnIndex] as HTMLElement;
|
66
|
+
cell.style.color = color ? `#${color}` : '';
|
67
|
+
cell.style.backgroundColor = backgroundColor
|
68
|
+
? `#${backgroundColor}`
|
69
|
+
: 'white';
|
70
|
+
cell.style.fontWeight = bold ? 'bolder' : 'normal';
|
71
|
+
cell.style.fontStyle = italic ? 'italic' : 'normal';
|
72
|
+
cell.style.fontFamily = name || '';
|
73
|
+
cell.style.borderLeft =
|
74
|
+
border.left === 'NONE' ? '' : `2px solid ${'black'}`;
|
75
|
+
cell.style.borderRight =
|
76
|
+
border.right === 'NONE' ? '' : `2px solid ${'black'}`;
|
77
|
+
cell.style.borderBottom =
|
78
|
+
border.bottom === 'NONE' ? '' : `2px solid ${'black'}`;
|
79
|
+
cell.style.borderTop =
|
80
|
+
border.top === 'NONE' ? '' : `2px solid ${'black'}`;
|
81
|
+
cell.style.textAlign = alignment?.horizontal || 'left';
|
82
|
+
}
|
83
|
+
});
|
84
|
+
});
|
85
|
+
}
|
86
|
+
}
|
@@ -0,0 +1,241 @@
|
|
1
|
+
interface ExcelFileProps {
|
2
|
+
/** The Excel data containing sheets and their content */
|
3
|
+
excelData: {
|
4
|
+
sheets: WorkSheet[];
|
5
|
+
};
|
6
|
+
|
7
|
+
/** Optional: Provide context menu options for actions like right-click */
|
8
|
+
contextOption?: {
|
9
|
+
name: string;
|
10
|
+
title: React.ReactNode;
|
11
|
+
action: () => void;
|
12
|
+
}[];
|
13
|
+
|
14
|
+
/** Controls whether the toolbar is shown, disabled, or hidden */
|
15
|
+
toolbar?: 'show' | 'disable' | 'hide';
|
16
|
+
|
17
|
+
/** Callback function to save the Excel data */
|
18
|
+
onSave?: (excelData?: any) => void;
|
19
|
+
}
|
20
|
+
|
21
|
+
interface WorkSheet {
|
22
|
+
/** The name of the worksheet */
|
23
|
+
sheetName: string;
|
24
|
+
|
25
|
+
/** 2D array of worksheet data (cells) */
|
26
|
+
data: WorkData[][];
|
27
|
+
}
|
28
|
+
|
29
|
+
interface WorkData {
|
30
|
+
/** Value of the cell */
|
31
|
+
value: string;
|
32
|
+
|
33
|
+
/** Styling options for the cell */
|
34
|
+
style: CellStyle;
|
35
|
+
type?:boolean;
|
36
|
+
}
|
37
|
+
|
38
|
+
interface CellStyle {
|
39
|
+
/** Font name for the cell text */
|
40
|
+
name?: string;
|
41
|
+
|
42
|
+
/** Font size of the cell text */
|
43
|
+
size?: number;
|
44
|
+
|
45
|
+
position?:string;
|
46
|
+
|
47
|
+
/** Whether the text is bold */
|
48
|
+
bold?: boolean;
|
49
|
+
|
50
|
+
fontSize?: string,
|
51
|
+
fontFamily?: string,
|
52
|
+
|
53
|
+
|
54
|
+
/** Whether the text is italicized */
|
55
|
+
italic?: boolean;
|
56
|
+
|
57
|
+
/** Text color in the cell (hex code) */
|
58
|
+
color?: string;
|
59
|
+
|
60
|
+
/** Background color of the cell (hex code) */
|
61
|
+
backgroundColor?: string;
|
62
|
+
|
63
|
+
/** Border color of the cell (hex code) */
|
64
|
+
borderColor?: string;
|
65
|
+
|
66
|
+
/** Border styles for each side of the cell */
|
67
|
+
border?: {
|
68
|
+
/** Border style for the top side of the cell */
|
69
|
+
top: string;
|
70
|
+
|
71
|
+
/** Border style for the bottom side of the cell */
|
72
|
+
bottom: string;
|
73
|
+
|
74
|
+
/** Border style for the left side of the cell */
|
75
|
+
left: string;
|
76
|
+
|
77
|
+
/** Border style for the right side of the cell */
|
78
|
+
right: string;
|
79
|
+
};
|
80
|
+
|
81
|
+
/** Text alignment and wrapping properties */
|
82
|
+
alignment?: {
|
83
|
+
/** Horizontal text alignment ('left', 'center', or 'right') */
|
84
|
+
horizontal: string;
|
85
|
+
|
86
|
+
/** Vertical text alignment ('top', 'middle', or 'bottom') */
|
87
|
+
vertical: string;
|
88
|
+
|
89
|
+
/** Whether the text is wrapped within the cell */
|
90
|
+
wrapText: boolean;
|
91
|
+
};
|
92
|
+
}
|
93
|
+
|
94
|
+
/** A generic type to represent a 2D matrix of any type (or undefined values) */
|
95
|
+
type Matrix<T> = (T | undefined)[][];
|
96
|
+
|
97
|
+
interface ContextAction {
|
98
|
+
/** Name of the right-click option */
|
99
|
+
name: string;
|
100
|
+
|
101
|
+
/** Display title of the right-click menu option */
|
102
|
+
title: React.ReactNode;
|
103
|
+
|
104
|
+
/** The action that occurs when the right-click menu option is selected */
|
105
|
+
action: () => void;
|
106
|
+
}
|
107
|
+
|
108
|
+
interface ContextOption {
|
109
|
+
/** Type of the context option ('cell', 'row', 'column') */
|
110
|
+
name: string;
|
111
|
+
|
112
|
+
/** Array of context menu actions for right-click options */
|
113
|
+
value: ContextAction[];
|
114
|
+
}
|
115
|
+
|
116
|
+
interface ContextMenuState {
|
117
|
+
/** Whether the context menu is visible */
|
118
|
+
visible: boolean;
|
119
|
+
|
120
|
+
/** X-coordinate position for the context menu */
|
121
|
+
x: number;
|
122
|
+
|
123
|
+
/** Y-coordinate position for the context menu */
|
124
|
+
y: number;
|
125
|
+
|
126
|
+
/** Type of the context menu ('cell', 'row', 'column', or 'sheet_options') */
|
127
|
+
type: 'cell' | 'row' | 'column' | 'sheet_options' | null;
|
128
|
+
}
|
129
|
+
|
130
|
+
interface SelectedCell {
|
131
|
+
/** The row index of the selected cell */
|
132
|
+
row: number;
|
133
|
+
|
134
|
+
/** The column index of the selected cell */
|
135
|
+
column: number;
|
136
|
+
}
|
137
|
+
|
138
|
+
interface ColorContainer {
|
139
|
+
/** The color used for the text (hex code) */
|
140
|
+
color: string;
|
141
|
+
|
142
|
+
/** The background color used for the cell (hex code) */
|
143
|
+
backgroundColor: string;
|
144
|
+
|
145
|
+
/** The border color used for the cell (hex code) */
|
146
|
+
borderColor: string;
|
147
|
+
}
|
148
|
+
|
149
|
+
interface SelectedValue {
|
150
|
+
/** The value inside the selected cell */
|
151
|
+
value: string;
|
152
|
+
|
153
|
+
/** The row index of the selected cell */
|
154
|
+
row: number;
|
155
|
+
|
156
|
+
/** The column index of the selected cell */
|
157
|
+
column: number;
|
158
|
+
|
159
|
+
/** The column represented as an alphabetical string ('A', 'B') */
|
160
|
+
alphaCol: string;
|
161
|
+
|
162
|
+
/** The style applied to the selected cell */
|
163
|
+
style: CellStyle;
|
164
|
+
|
165
|
+
/** The sheet name where the cell is located */
|
166
|
+
sheet: string;
|
167
|
+
}
|
168
|
+
interface ExcelToolBarProps {
|
169
|
+
/** use this to hide/show/disable the toolbar */
|
170
|
+
toolbar?: 'show' | 'disable' | 'hide';
|
171
|
+
|
172
|
+
/** function to apply styles */
|
173
|
+
applyStyle: (styleType: string, value: any) => void;
|
174
|
+
|
175
|
+
/** function to trigger format painter */
|
176
|
+
formatePaint: () => void;
|
177
|
+
}
|
178
|
+
|
179
|
+
interface ExcelSheetBarProps {
|
180
|
+
/** Object containing details about the file, including sheet names */
|
181
|
+
fileDetails: {
|
182
|
+
sheetNames: string[];
|
183
|
+
};
|
184
|
+
|
185
|
+
/** Function to handle sheet change events */
|
186
|
+
handleSheetChange: (name: string, index: number) => void;
|
187
|
+
|
188
|
+
/** Function to open the context menu on a sheet */
|
189
|
+
contextMenu: (
|
190
|
+
e: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
191
|
+
name: string,
|
192
|
+
index: number
|
193
|
+
) => void;
|
194
|
+
|
195
|
+
/** Function to add a new sheet */
|
196
|
+
addSheet: () => void;
|
197
|
+
|
198
|
+
/** Object representing the currently selected sheet */
|
199
|
+
selectedSheet: {
|
200
|
+
name: string;
|
201
|
+
index: number;
|
202
|
+
};
|
203
|
+
/** Function to update the context Type */
|
204
|
+
contextSelect: (event: React.MouseEvent) => void;
|
205
|
+
}
|
206
|
+
|
207
|
+
interface ContextMenuProps {
|
208
|
+
/** Custom context menu options */
|
209
|
+
customContext: {
|
210
|
+
name: string;
|
211
|
+
title: React.ReactNode;
|
212
|
+
action: () => void;
|
213
|
+
}[];
|
214
|
+
|
215
|
+
/** Object that holds different context actions based on the type (cell, row, column, sheet_options) */
|
216
|
+
contextAction: {
|
217
|
+
/** Function to add a row */
|
218
|
+
addRow: () => void;
|
219
|
+
|
220
|
+
/** Function to delete a row */
|
221
|
+
deleteRow: () => void;
|
222
|
+
|
223
|
+
/** Function to add a column */
|
224
|
+
addColumn: () => void;
|
225
|
+
|
226
|
+
/** Function to delete a column */
|
227
|
+
deleteColumn: () => void;
|
228
|
+
|
229
|
+
/** Function to add a new sheet */
|
230
|
+
addSheet: () => void;
|
231
|
+
|
232
|
+
/** Function to delete a sheet */
|
233
|
+
deleteSheet: () => void;
|
234
|
+
};
|
235
|
+
|
236
|
+
/** The state of the context menu, controlling its visibility and position */
|
237
|
+
contextData: ContextMenuState;
|
238
|
+
|
239
|
+
/** Function to update the context menu state */
|
240
|
+
setContextData: React.Dispatch<React.SetStateAction<ContextMenuState>>;
|
241
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './ExcelFile/ExcelFile';
|