Compare commits
1 Commits
bugfix/nic
...
feature/ni
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e7ce9f5ec9 |
@@ -68,6 +68,7 @@ impl Model {
|
|||||||
frozen_rows: 0,
|
frozen_rows: 0,
|
||||||
show_grid_lines: true,
|
show_grid_lines: true,
|
||||||
views,
|
views,
|
||||||
|
conditional_formatting: vec![]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ fn cut_paste() {
|
|||||||
|
|
||||||
// paste in cell D4 (4, 4)
|
// paste in cell D4 (4, 4)
|
||||||
model
|
model
|
||||||
.paste_from_clipboard(0, (1, 1, 2, 2), ©.data, true)
|
.paste_from_clipboard((1, 1, 2, 2), ©.data, true)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(model.get_cell_content(0, 4, 4), Ok("42".to_string()));
|
assert_eq!(model.get_cell_content(0, 4, 4), Ok("42".to_string()));
|
||||||
@@ -119,26 +119,6 @@ fn cut_paste() {
|
|||||||
assert_eq!(model.get_cell_content(0, 2, 2), Ok("".to_string()));
|
assert_eq!(model.get_cell_content(0, 2, 2), Ok("".to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn cut_paste_different_sheet() {
|
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
|
||||||
model.set_user_input(0, 1, 1, "42").unwrap();
|
|
||||||
|
|
||||||
model.set_selected_range(1, 1, 1, 1).unwrap();
|
|
||||||
let copy = model.copy_to_clipboard().unwrap();
|
|
||||||
model.new_sheet().unwrap();
|
|
||||||
model.set_selected_sheet(1).unwrap();
|
|
||||||
model.set_selected_cell(4, 4).unwrap();
|
|
||||||
|
|
||||||
// paste in cell D4 (4, 4) of Sheet2
|
|
||||||
model
|
|
||||||
.paste_from_clipboard(0, (1, 1, 1, 1), ©.data, true)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(model.get_cell_content(1, 4, 4), Ok("42".to_string()));
|
|
||||||
assert_eq!(model.get_cell_content(0, 1, 1), Ok("".to_string()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn copy_paste_internal() {
|
fn copy_paste_internal() {
|
||||||
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
let mut model = UserModel::new_empty("model", "en", "UTC").unwrap();
|
||||||
@@ -172,7 +152,7 @@ fn copy_paste_internal() {
|
|||||||
|
|
||||||
// paste in cell D4 (4, 4)
|
// paste in cell D4 (4, 4)
|
||||||
model
|
model
|
||||||
.paste_from_clipboard(0, (1, 1, 2, 2), ©.data, false)
|
.paste_from_clipboard((1, 1, 2, 2), ©.data, false)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
assert_eq!(model.get_cell_content(0, 4, 4), Ok("42".to_string()));
|
assert_eq!(model.get_cell_content(0, 4, 4), Ok("42".to_string()));
|
||||||
|
|||||||
@@ -117,6 +117,26 @@ pub struct Worksheet {
|
|||||||
pub views: HashMap<u32, WorksheetView>,
|
pub views: HashMap<u32, WorksheetView>,
|
||||||
/// Whether or not to show the grid lines in the worksheet
|
/// Whether or not to show the grid lines in the worksheet
|
||||||
pub show_grid_lines: bool,
|
pub show_grid_lines: bool,
|
||||||
|
pub conditional_formatting: Vec<ConditionalFormatting>
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Encode, Decode, Debug, PartialEq, Clone)]
|
||||||
|
pub struct ColorScale {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Encode, Decode, Debug, PartialEq, Clone)]
|
||||||
|
pub enum CfRule {
|
||||||
|
ColorScale {
|
||||||
|
priority: u32,
|
||||||
|
},
|
||||||
|
CellIs,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Encode, Decode, Debug, PartialEq, Clone)]
|
||||||
|
pub struct ConditionalFormatting {
|
||||||
|
sqref: String,
|
||||||
|
cf_rule: Vec<CfRule>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Internal representation of Excel's sheet_data
|
/// Internal representation of Excel's sheet_data
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ pub struct ClipboardCell {
|
|||||||
pub struct Clipboard {
|
pub struct Clipboard {
|
||||||
pub(crate) csv: String,
|
pub(crate) csv: String,
|
||||||
pub(crate) data: ClipboardData,
|
pub(crate) data: ClipboardData,
|
||||||
pub(crate) sheet: u32,
|
|
||||||
pub(crate) range: (i32, i32, i32, i32),
|
pub(crate) range: (i32, i32, i32, i32),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1521,7 +1520,6 @@ impl UserModel {
|
|||||||
Ok(Clipboard {
|
Ok(Clipboard {
|
||||||
csv,
|
csv,
|
||||||
data,
|
data,
|
||||||
sheet,
|
|
||||||
range: (row_start, column_start, row_end, column_end),
|
range: (row_start, column_start, row_end, column_end),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -1529,7 +1527,6 @@ impl UserModel {
|
|||||||
/// Paste text that we copied
|
/// Paste text that we copied
|
||||||
pub fn paste_from_clipboard(
|
pub fn paste_from_clipboard(
|
||||||
&mut self,
|
&mut self,
|
||||||
source_sheet: u32,
|
|
||||||
source_range: ClipboardTuple,
|
source_range: ClipboardTuple,
|
||||||
clipboard: &ClipboardData,
|
clipboard: &ClipboardData,
|
||||||
is_cut: bool,
|
is_cut: bool,
|
||||||
@@ -1620,17 +1617,17 @@ impl UserModel {
|
|||||||
let old_value = self
|
let old_value = self
|
||||||
.model
|
.model
|
||||||
.workbook
|
.workbook
|
||||||
.worksheet(source_sheet)?
|
.worksheet(sheet)?
|
||||||
.cell(row, column)
|
.cell(row, column)
|
||||||
.cloned();
|
.cloned();
|
||||||
|
|
||||||
diff_list.push(Diff::CellClearContents {
|
diff_list.push(Diff::CellClearContents {
|
||||||
sheet: source_sheet,
|
sheet,
|
||||||
row,
|
row,
|
||||||
column,
|
column,
|
||||||
old_value: Box::new(old_value),
|
old_value: Box::new(old_value),
|
||||||
});
|
});
|
||||||
self.model.cell_clear_contents(source_sheet, row, column)?;
|
self.model.cell_clear_contents(sheet, row, column)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,22 +169,20 @@ clipboard_types = r"""
|
|||||||
|
|
||||||
paste_from_clipboard = r"""
|
paste_from_clipboard = r"""
|
||||||
/**
|
/**
|
||||||
* @param {number} source_sheet
|
|
||||||
* @param {any} source_range
|
* @param {any} source_range
|
||||||
* @param {any} clipboard
|
* @param {any} clipboard
|
||||||
* @param {boolean} is_cut
|
* @param {boolean} is_cut
|
||||||
*/
|
*/
|
||||||
pasteFromClipboard(source_sheet: number, source_range: any, clipboard: any, is_cut: boolean): void;
|
pasteFromClipboard(source_range: any, clipboard: any, is_cut: boolean): void;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
paste_from_clipboard_types = r"""
|
paste_from_clipboard_types = r"""
|
||||||
/**
|
/**
|
||||||
* @param {number} source_sheet
|
|
||||||
* @param {[number, number, number, number]} source_range
|
* @param {[number, number, number, number]} source_range
|
||||||
* @param {ClipboardData} clipboard
|
* @param {ClipboardData} clipboard
|
||||||
* @param {boolean} is_cut
|
* @param {boolean} is_cut
|
||||||
*/
|
*/
|
||||||
pasteFromClipboard(source_sheet: number, source_range: [number, number, number, number], clipboard: ClipboardData, is_cut: boolean): void;
|
pasteFromClipboard(source_range: [number, number, number, number], clipboard: ClipboardData, is_cut: boolean): void;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def fix_types(text):
|
def fix_types(text):
|
||||||
|
|||||||
@@ -520,7 +520,6 @@ impl Model {
|
|||||||
#[wasm_bindgen(js_name = "pasteFromClipboard")]
|
#[wasm_bindgen(js_name = "pasteFromClipboard")]
|
||||||
pub fn paste_from_clipboard(
|
pub fn paste_from_clipboard(
|
||||||
&mut self,
|
&mut self,
|
||||||
source_sheet: u32,
|
|
||||||
source_range: JsValue,
|
source_range: JsValue,
|
||||||
clipboard: JsValue,
|
clipboard: JsValue,
|
||||||
is_cut: bool,
|
is_cut: bool,
|
||||||
@@ -530,7 +529,7 @@ impl Model {
|
|||||||
let clipboard: ClipboardData =
|
let clipboard: ClipboardData =
|
||||||
serde_wasm_bindgen::from_value(clipboard).map_err(|e| to_js_error(e.to_string()))?;
|
serde_wasm_bindgen::from_value(clipboard).map_err(|e| to_js_error(e.to_string()))?;
|
||||||
self.model
|
self.model
|
||||||
.paste_from_clipboard(source_sheet, source_range, &clipboard, is_cut)
|
.paste_from_clipboard(source_range, &clipboard, is_cut)
|
||||||
.map_err(|e| to_js_error(e.to_string()))
|
.map_err(|e| to_js_error(e.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,160 +0,0 @@
|
|||||||
import styled from "@emotion/styled";
|
|
||||||
import { Trash2 } from "lucide-react";
|
|
||||||
import { forwardRef, useEffect } from "react";
|
|
||||||
import { theme } from "../theme";
|
|
||||||
|
|
||||||
export const DeleteWorkbookDialog = forwardRef<
|
|
||||||
HTMLDivElement,
|
|
||||||
{
|
|
||||||
onClose: () => void;
|
|
||||||
onConfirm: () => void;
|
|
||||||
workbookName: string;
|
|
||||||
}
|
|
||||||
>((properties, ref) => {
|
|
||||||
useEffect(() => {
|
|
||||||
const root = document.getElementById("root");
|
|
||||||
if (root) {
|
|
||||||
root.style.filter = "blur(2px)";
|
|
||||||
}
|
|
||||||
return () => {
|
|
||||||
const root = document.getElementById("root");
|
|
||||||
if (root) {
|
|
||||||
root.style.filter = "none";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<DialogWrapper
|
|
||||||
ref={ref}
|
|
||||||
tabIndex={-1}
|
|
||||||
role="dialog"
|
|
||||||
aria-labelledby="delete-dialog-title"
|
|
||||||
aria-describedby="delete-dialog-description"
|
|
||||||
>
|
|
||||||
<IconWrapper>
|
|
||||||
<Trash2 />
|
|
||||||
</IconWrapper>
|
|
||||||
<ContentWrapper>
|
|
||||||
<Title>Are you sure?</Title>
|
|
||||||
<Body>
|
|
||||||
The workbook <strong>'{properties.workbookName}'</strong> will be
|
|
||||||
permanently deleted. This action cannot be undone.
|
|
||||||
</Body>
|
|
||||||
<ButtonGroup>
|
|
||||||
<DeleteButton
|
|
||||||
onClick={() => {
|
|
||||||
properties.onConfirm();
|
|
||||||
properties.onClose();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Yes, delete workbook
|
|
||||||
</DeleteButton>
|
|
||||||
<CancelButton onClick={properties.onClose}>Cancel</CancelButton>
|
|
||||||
</ButtonGroup>
|
|
||||||
</ContentWrapper>
|
|
||||||
</DialogWrapper>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
DeleteWorkbookDialog.displayName = "DeleteWorkbookDialog";
|
|
||||||
|
|
||||||
const DialogWrapper = styled.div`
|
|
||||||
position: fixed;
|
|
||||||
top: 50%;
|
|
||||||
left: 50%;
|
|
||||||
transform: translate(-50%, -50%);
|
|
||||||
background: white;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 16px;
|
|
||||||
padding: 12px;
|
|
||||||
border-radius: 8px;
|
|
||||||
box-shadow: 0px 1px 3px 0px ${theme.palette.common.black}1A;
|
|
||||||
width: 280px;
|
|
||||||
max-width: calc(100% - 40px);
|
|
||||||
z-index: 50;
|
|
||||||
font-family: "Inter", sans-serif;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const IconWrapper = styled.div`
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
width: 36px;
|
|
||||||
height: 36px;
|
|
||||||
border-radius: 4px;
|
|
||||||
background-color: ${theme.palette.error.main}1A;
|
|
||||||
margin: 12px auto 0 auto;
|
|
||||||
color: ${theme.palette.error.main};
|
|
||||||
svg {
|
|
||||||
width: 16px;
|
|
||||||
height: 16px;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const ContentWrapper = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
font-size: 14px;
|
|
||||||
word-break: break-word;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Title = styled.h2`
|
|
||||||
margin: 0;
|
|
||||||
font-weight: 600;
|
|
||||||
font-size: inherit;
|
|
||||||
color: ${theme.palette.grey["900"]};
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Body = styled.p`
|
|
||||||
margin: 0;
|
|
||||||
text-align: center;
|
|
||||||
color: ${theme.palette.grey["900"]};
|
|
||||||
font-size: 12px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const ButtonGroup = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 8px;
|
|
||||||
margin-top: 8px;
|
|
||||||
width: 100%;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const Button = styled.button`
|
|
||||||
cursor: pointer;
|
|
||||||
color: ${theme.palette.common.white};
|
|
||||||
background-color: ${theme.palette.primary.main};
|
|
||||||
padding: 0px 10px;
|
|
||||||
height: 36px;
|
|
||||||
border-radius: 4px;
|
|
||||||
border: none;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 14px;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
transition: background-color 150ms;
|
|
||||||
&:hover {
|
|
||||||
background-color: ${theme.palette.primary.dark};
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const DeleteButton = styled(Button)`
|
|
||||||
background-color: ${theme.palette.error.main};
|
|
||||||
color: ${theme.palette.common.white};
|
|
||||||
&:hover {
|
|
||||||
background-color: ${theme.palette.error.dark};
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const CancelButton = styled(Button)`
|
|
||||||
background-color: ${theme.palette.grey["200"]};
|
|
||||||
color: ${theme.palette.grey["700"]};
|
|
||||||
&:hover {
|
|
||||||
background-color: ${theme.palette.grey["300"]};
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
@@ -2,7 +2,6 @@ import styled from "@emotion/styled";
|
|||||||
import { Menu, MenuItem, Modal } from "@mui/material";
|
import { Menu, MenuItem, Modal } from "@mui/material";
|
||||||
import { Check, FileDown, FileUp, Plus, Trash2 } from "lucide-react";
|
import { Check, FileDown, FileUp, Plus, Trash2 } from "lucide-react";
|
||||||
import { useRef, useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
import { DeleteWorkbookDialog } from "./DeleteWorkbookDialog";
|
|
||||||
import { UploadFileDialog } from "./UploadFileDialog";
|
import { UploadFileDialog } from "./UploadFileDialog";
|
||||||
import { getModelsMetadata, getSelectedUuid } from "./storage";
|
import { getModelsMetadata, getSelectedUuid } from "./storage";
|
||||||
|
|
||||||
@@ -19,7 +18,6 @@ export function FileMenu(props: {
|
|||||||
const models = getModelsMetadata();
|
const models = getModelsMetadata();
|
||||||
const uuids = Object.keys(models);
|
const uuids = Object.keys(models);
|
||||||
const selectedUuid = getSelectedUuid();
|
const selectedUuid = getSelectedUuid();
|
||||||
const [isDeleteDialogOpen, setDeleteDialogOpen] = useState(false);
|
|
||||||
|
|
||||||
const elements = [];
|
const elements = [];
|
||||||
for (const uuid of uuids) {
|
for (const uuid of uuids) {
|
||||||
@@ -90,14 +88,16 @@ export function FileMenu(props: {
|
|||||||
Download (.xlsx)
|
Download (.xlsx)
|
||||||
</MenuItemText>
|
</MenuItemText>
|
||||||
</MenuItemWrapper>
|
</MenuItemWrapper>
|
||||||
<MenuItemWrapper
|
<MenuItemWrapper>
|
||||||
onClick={() => {
|
|
||||||
setDeleteDialogOpen(true);
|
|
||||||
setMenuOpen(false);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<StyledTrash />
|
<StyledTrash />
|
||||||
<MenuItemText>Delete workbook</MenuItemText>
|
<MenuItemText
|
||||||
|
onClick={() => {
|
||||||
|
props.onDelete();
|
||||||
|
setMenuOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Delete workbook
|
||||||
|
</MenuItemText>
|
||||||
</MenuItemWrapper>
|
</MenuItemWrapper>
|
||||||
<MenuDivider />
|
<MenuDivider />
|
||||||
{elements}
|
{elements}
|
||||||
@@ -127,18 +127,6 @@ export function FileMenu(props: {
|
|||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
</Modal>
|
</Modal>
|
||||||
<Modal
|
|
||||||
open={isDeleteDialogOpen}
|
|
||||||
onClose={() => setDeleteDialogOpen(false)}
|
|
||||||
aria-labelledby="delete-dialog-title"
|
|
||||||
aria-describedby="delete-dialog-description"
|
|
||||||
>
|
|
||||||
<DeleteWorkbookDialog
|
|
||||||
onClose={() => setDeleteDialogOpen(false)}
|
|
||||||
onConfirm={props.onDelete}
|
|
||||||
workbookName={selectedUuid ? models[selectedUuid] : ""}
|
|
||||||
/>
|
|
||||||
</Modal>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,99 +0,0 @@
|
|||||||
import { styled } from "@mui/material";
|
|
||||||
import Menu from "@mui/material/Menu";
|
|
||||||
import MenuItem from "@mui/material/MenuItem";
|
|
||||||
import { Check } from "lucide-react";
|
|
||||||
import type { SheetOptions } from "./types";
|
|
||||||
|
|
||||||
function isWhiteColor(color: string): boolean {
|
|
||||||
return ["#FFF", "#FFFFFF"].includes(color);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface SheetListMenuProps {
|
|
||||||
open: boolean;
|
|
||||||
onClose: () => void;
|
|
||||||
anchorEl: HTMLButtonElement | null;
|
|
||||||
onSheetSelected: (index: number) => void;
|
|
||||||
sheetOptionsList: SheetOptions[];
|
|
||||||
selectedIndex: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
const SheetListMenu = (properties: SheetListMenuProps) => {
|
|
||||||
const {
|
|
||||||
open,
|
|
||||||
onClose,
|
|
||||||
anchorEl,
|
|
||||||
onSheetSelected,
|
|
||||||
sheetOptionsList,
|
|
||||||
selectedIndex,
|
|
||||||
} = properties;
|
|
||||||
|
|
||||||
const hasColors = sheetOptionsList.some((tab) => !isWhiteColor(tab.color));
|
|
||||||
|
|
||||||
return (
|
|
||||||
<StyledMenu
|
|
||||||
open={open}
|
|
||||||
onClose={onClose}
|
|
||||||
anchorEl={anchorEl}
|
|
||||||
anchorOrigin={{
|
|
||||||
vertical: "top",
|
|
||||||
horizontal: "left",
|
|
||||||
}}
|
|
||||||
transformOrigin={{
|
|
||||||
vertical: "bottom",
|
|
||||||
horizontal: 6,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{sheetOptionsList.map((tab, index) => (
|
|
||||||
<StyledMenuItem
|
|
||||||
key={tab.sheetId}
|
|
||||||
onClick={() => onSheetSelected(index)}
|
|
||||||
>
|
|
||||||
{index === selectedIndex ? (
|
|
||||||
<Check
|
|
||||||
style={{ width: "16px", height: "16px", marginRight: "8px" }}
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<div
|
|
||||||
style={{ width: "16px", height: "16px", marginRight: "8px" }}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{hasColors && <ItemColor style={{ backgroundColor: tab.color }} />}
|
|
||||||
<ItemName
|
|
||||||
style={{ fontWeight: index === selectedIndex ? "bold" : "normal" }}
|
|
||||||
>
|
|
||||||
{tab.name}
|
|
||||||
</ItemName>
|
|
||||||
</StyledMenuItem>
|
|
||||||
))}
|
|
||||||
</StyledMenu>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const StyledMenu = styled(Menu)({
|
|
||||||
"& .MuiPaper-root": {
|
|
||||||
borderRadius: 8,
|
|
||||||
padding: 4,
|
|
||||||
},
|
|
||||||
"& .MuiList-padding": {
|
|
||||||
padding: 0,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const StyledMenuItem = styled(MenuItem)({
|
|
||||||
padding: 8,
|
|
||||||
borderRadius: 4,
|
|
||||||
});
|
|
||||||
|
|
||||||
const ItemColor = styled("div")`
|
|
||||||
width: 12px;
|
|
||||||
height: 12px;
|
|
||||||
border-radius: 4px;
|
|
||||||
margin-right: 8px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const ItemName = styled("div")`
|
|
||||||
font-size: 12px;
|
|
||||||
color: #333;
|
|
||||||
`;
|
|
||||||
|
|
||||||
export default SheetListMenu;
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
export { default } from "./SheetTabBar";
|
|
||||||
@@ -5,10 +5,10 @@ export const headerGlobalSelectorColor = "#EAECF4";
|
|||||||
export const headerSelectedBackground = "#EEEEEE";
|
export const headerSelectedBackground = "#EEEEEE";
|
||||||
export const headerFullSelectedBackground = "#D3D6E9";
|
export const headerFullSelectedBackground = "#D3D6E9";
|
||||||
export const headerSelectedColor = "#333";
|
export const headerSelectedColor = "#333";
|
||||||
export const headerBorderColor = "#E0E0E0";
|
export const headerBorderColor = "#DEE0EF";
|
||||||
|
|
||||||
export const gridColor = "#E0E0E0";
|
export const gridColor = "#E0E0E0";
|
||||||
export const gridSeparatorColor = "#E0E0E0";
|
export const gridSeparatorColor = "#D3D6E9";
|
||||||
export const defaultTextColor = "#2E414D";
|
export const defaultTextColor = "#2E414D";
|
||||||
|
|
||||||
export const outlineColor = "#F2994A";
|
export const outlineColor = "#F2994A";
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ const BorderPicker = (properties: BorderPickerProps) => {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const [borderSelected, setBorderSelected] = useState<BorderType | null>(null);
|
const [borderSelected, setBorderSelected] = useState<BorderType | null>(null);
|
||||||
const [borderColor, setBorderColor] = useState(theme.palette.common.white);
|
const [borderColor, setBorderColor] = useState("#000000");
|
||||||
const [borderStyle, setBorderStyle] = useState(BorderStyle.Thin);
|
const [borderStyle, setBorderStyle] = useState(BorderStyle.Thin);
|
||||||
const [colorPickerOpen, setColorPickerOpen] = useState(false);
|
const [colorPickerOpen, setColorPickerOpen] = useState(false);
|
||||||
const [stylePickerOpen, setStylePickerOpen] = useState(false);
|
const [stylePickerOpen, setStylePickerOpen] = useState(false);
|
||||||
@@ -62,7 +62,7 @@ const BorderPicker = (properties: BorderPickerProps) => {
|
|||||||
// biome-ignore lint/correctness/useExhaustiveDependencies: We reset the styles, every time we open (or close) the widget
|
// biome-ignore lint/correctness/useExhaustiveDependencies: We reset the styles, every time we open (or close) the widget
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setBorderSelected(null);
|
setBorderSelected(null);
|
||||||
setBorderColor(theme.palette.common.white);
|
setBorderColor("#000000");
|
||||||
setBorderStyle(BorderStyle.Thin);
|
setBorderStyle(BorderStyle.Thin);
|
||||||
}, [properties.open]);
|
}, [properties.open]);
|
||||||
|
|
||||||
@@ -240,21 +240,31 @@ const BorderPicker = (properties: BorderPickerProps) => {
|
|||||||
</Borders>
|
</Borders>
|
||||||
<Divider />
|
<Divider />
|
||||||
<Styles>
|
<Styles>
|
||||||
<ButtonWrapper
|
<ButtonWrapper onClick={() => setColorPickerOpen(true)}>
|
||||||
onClick={() => setColorPickerOpen(true)}
|
<Button
|
||||||
ref={borderColorButton}
|
type="button"
|
||||||
>
|
$pressed={false}
|
||||||
<PencilLine />
|
disabled={false}
|
||||||
|
ref={borderColorButton}
|
||||||
|
title={t("toolbar.borders.color")}
|
||||||
|
>
|
||||||
|
<PencilLine />
|
||||||
|
</Button>
|
||||||
<div style={{ flexGrow: 2 }}>Border color</div>
|
<div style={{ flexGrow: 2 }}>Border color</div>
|
||||||
<ChevronRightStyled />
|
<ChevronRightStyled />
|
||||||
</ButtonWrapper>
|
</ButtonWrapper>
|
||||||
|
|
||||||
<ButtonWrapper
|
<ButtonWrapper
|
||||||
onClick={() => setStylePickerOpen(true)}
|
onClick={() => setStylePickerOpen(true)}
|
||||||
ref={borderStyleButton}
|
ref={borderStyleButton}
|
||||||
>
|
>
|
||||||
<BorderStyleIcon />
|
<Button
|
||||||
|
type="button"
|
||||||
|
$pressed={false}
|
||||||
|
disabled={false}
|
||||||
|
title={t("toolbar.borders.style")}
|
||||||
|
>
|
||||||
|
<BorderStyleIcon />
|
||||||
|
</Button>
|
||||||
<div style={{ flexGrow: 2 }}>Border style</div>
|
<div style={{ flexGrow: 2 }}>Border style</div>
|
||||||
<ChevronRightStyled />
|
<ChevronRightStyled />
|
||||||
</ButtonWrapper>
|
</ButtonWrapper>
|
||||||
@@ -271,14 +281,6 @@ const BorderPicker = (properties: BorderPickerProps) => {
|
|||||||
}}
|
}}
|
||||||
anchorEl={borderColorButton}
|
anchorEl={borderColorButton}
|
||||||
open={colorPickerOpen}
|
open={colorPickerOpen}
|
||||||
anchorOrigin={{
|
|
||||||
vertical: "top", // Keep vertical alignment at the top
|
|
||||||
horizontal: "right", // Set horizontal alignment to right
|
|
||||||
}}
|
|
||||||
transformOrigin={{
|
|
||||||
vertical: "top", // Keep vertical alignment at the top
|
|
||||||
horizontal: "left", // Set horizontal alignment to left
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<StyledPopover
|
<StyledPopover
|
||||||
open={stylePickerOpen}
|
open={stylePickerOpen}
|
||||||
@@ -286,10 +288,8 @@ const BorderPicker = (properties: BorderPickerProps) => {
|
|||||||
setStylePickerOpen(false);
|
setStylePickerOpen(false);
|
||||||
}}
|
}}
|
||||||
anchorEl={borderStyleButton.current}
|
anchorEl={borderStyleButton.current}
|
||||||
anchorOrigin={{
|
anchorOrigin={{ vertical: "bottom", horizontal: "right" }}
|
||||||
vertical: "top",
|
transformOrigin={{ vertical: 38, horizontal: -6 }}
|
||||||
horizontal: "right",
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<BorderStyleDialog>
|
<BorderStyleDialog>
|
||||||
<LineWrapper
|
<LineWrapper
|
||||||
@@ -336,12 +336,12 @@ const LineWrapper = styled("div")<LineWrapperProperties>`
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
background-color: ${({ $checked }): string => {
|
background-color: ${({ $checked }): string => {
|
||||||
if ($checked) {
|
if ($checked) {
|
||||||
return theme.palette.grey["200"];
|
return "#EEEEEE;";
|
||||||
}
|
}
|
||||||
return "inherit;";
|
return "inherit;";
|
||||||
}};
|
}};
|
||||||
&:hover {
|
&:hover {
|
||||||
border: 1px solid ${theme.palette.grey["200"]};
|
border: 1px solid #eeeeee;
|
||||||
}
|
}
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@@ -351,59 +351,52 @@ const LineWrapper = styled("div")<LineWrapperProperties>`
|
|||||||
|
|
||||||
const SolidLine = styled("div")`
|
const SolidLine = styled("div")`
|
||||||
width: 68px;
|
width: 68px;
|
||||||
border-top: 1px solid ${theme.palette.grey["900"]};
|
border-top: 1px solid #333333;
|
||||||
`;
|
`;
|
||||||
const MediumLine = styled("div")`
|
const MediumLine = styled("div")`
|
||||||
width: 68px;
|
width: 68px;
|
||||||
border-top: 2px solid ${theme.palette.grey["900"]};
|
border-top: 2px solid #333333;
|
||||||
`;
|
`;
|
||||||
const ThickLine = styled("div")`
|
const ThickLine = styled("div")`
|
||||||
width: 68px;
|
width: 68px;
|
||||||
border-top: 1px solid ${theme.palette.grey["900"]};
|
border-top: 3px solid #333333;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Divider = styled("div")`
|
const Divider = styled("div")`
|
||||||
width: 100%;
|
display: inline-flex;
|
||||||
margin: auto;
|
heigh: 1px;
|
||||||
border-top: 1px solid ${theme.palette.grey["200"]};
|
border-bottom: 1px solid #eee;
|
||||||
|
margin-left: 0px;
|
||||||
|
margin-right: 0px;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Borders = styled("div")`
|
const Borders = styled("div")`
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 4px;
|
padding-bottom: 4px;
|
||||||
padding: 4px;
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Styles = styled("div")`
|
const Styles = styled("div")`
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 4px;
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Line = styled("div")`
|
const Line = styled("div")`
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 4px;
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const ButtonWrapper = styled("div")`
|
const ButtonWrapper = styled("div")`
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
border-radius: 4px;
|
|
||||||
gap: 8px;
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background-color: ${theme.palette.grey["200"]};
|
background-color: #eee;
|
||||||
border-top-color: ${(): string => theme.palette.grey["200"]};
|
border-top-color: ${(): string => theme.palette.grey["400"]};
|
||||||
}
|
}
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
svg {
|
|
||||||
width: 16px;
|
|
||||||
height: 16px;
|
|
||||||
}
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const BorderStyleDialog = styled("div")`
|
const BorderStyleDialog = styled("div")`
|
||||||
@@ -416,7 +409,7 @@ const BorderStyleDialog = styled("div")`
|
|||||||
|
|
||||||
const StyledPopover = styled(Popover)`
|
const StyledPopover = styled(Popover)`
|
||||||
.MuiPopover-paper {
|
.MuiPopover-paper {
|
||||||
border-radius: 8px;
|
border-radius: 10px;
|
||||||
border: 0px solid ${({ theme }): string => theme.palette.background.default};
|
border: 0px solid ${({ theme }): string => theme.palette.background.default};
|
||||||
box-shadow: 1px 2px 8px rgba(139, 143, 173, 0.5);
|
box-shadow: 1px 2px 8px rgba(139, 143, 173, 0.5);
|
||||||
}
|
}
|
||||||
@@ -432,6 +425,7 @@ const StyledPopover = styled(Popover)`
|
|||||||
|
|
||||||
const BorderPickerDialog = styled("div")`
|
const BorderPickerDialog = styled("div")`
|
||||||
background: ${({ theme }): string => theme.palette.background.default};
|
background: ${({ theme }): string => theme.palette.background.default};
|
||||||
|
padding: 4px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
`;
|
`;
|
||||||
@@ -450,8 +444,10 @@ const Button = styled("button")<TypeButtonProperties>(
|
|||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
// fontSize: "26px",
|
// fontSize: "26px",
|
||||||
border: `0px solid ${theme.palette.common.white}`,
|
border: "0px solid #fff",
|
||||||
borderRadius: "4px",
|
borderRadius: "4px",
|
||||||
|
marginRight: "5px",
|
||||||
|
transition: "all 0.2s",
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
padding: "0px",
|
padding: "0px",
|
||||||
};
|
};
|
||||||
@@ -464,15 +460,13 @@ const Button = styled("button")<TypeButtonProperties>(
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...result,
|
...result,
|
||||||
borderTop: $underlinedColor
|
borderTop: $underlinedColor ? "3px solid #FFF" : "none",
|
||||||
? `3px solid ${theme.palette.common.white}`
|
|
||||||
: "none",
|
|
||||||
borderBottom: $underlinedColor ? `3px solid ${$underlinedColor}` : "none",
|
borderBottom: $underlinedColor ? `3px solid ${$underlinedColor}` : "none",
|
||||||
color: `${theme.palette.grey["900"]}`,
|
color: "#21243A",
|
||||||
backgroundColor: $pressed ? theme.palette.grey["200"] : "inherit",
|
backgroundColor: $pressed ? theme.palette.grey["200"] : "inherit",
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
outline: `1px solid ${theme.palette.grey["200"]}`,
|
backgroundColor: "#F1F2F8",
|
||||||
borderTopColor: theme.palette.grey["200"],
|
borderTopColor: "#F1F2F8",
|
||||||
},
|
},
|
||||||
svg: {
|
svg: {
|
||||||
width: "16px",
|
width: "16px",
|
||||||
|
|||||||
@@ -45,8 +45,8 @@ const ColorPicker = (properties: ColorPickerProps) => {
|
|||||||
"#3BB68A",
|
"#3BB68A",
|
||||||
"#8CB354",
|
"#8CB354",
|
||||||
"#F8CD3C",
|
"#F8CD3C",
|
||||||
"#F2994A",
|
|
||||||
"#EC5753",
|
"#EC5753",
|
||||||
|
"#A23C52",
|
||||||
"#D03627",
|
"#D03627",
|
||||||
"#523E93",
|
"#523E93",
|
||||||
"#3358B7",
|
"#3358B7",
|
||||||
|
|||||||
2
webapp/src/components/navigation/index.ts
Normal file
2
webapp/src/components/navigation/index.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
export { default } from "./navigation";
|
||||||
|
export type { NavigationProps } from "./navigation";
|
||||||
@@ -1,23 +1,31 @@
|
|||||||
import { Dialog, TextField, styled } from "@mui/material";
|
import { Dialog, TextField, styled } from "@mui/material";
|
||||||
|
import Menu from "@mui/material/Menu";
|
||||||
|
import MenuItem from "@mui/material/MenuItem";
|
||||||
|
import { Check } from "lucide-react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { theme } from "../../theme";
|
import { theme } from "../../theme";
|
||||||
|
import type { SheetOptions } from "./types";
|
||||||
|
|
||||||
|
function isWhiteColor(color: string): boolean {
|
||||||
|
return ["#FFF", "#FFFFFF"].includes(color);
|
||||||
|
}
|
||||||
|
|
||||||
interface SheetRenameDialogProps {
|
interface SheetRenameDialogProps {
|
||||||
open: boolean;
|
isOpen: boolean;
|
||||||
onClose: () => void;
|
close: () => void;
|
||||||
onNameChanged: (name: string) => void;
|
onNameChanged: (name: string) => void;
|
||||||
defaultName: string;
|
defaultName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SheetRenameDialog = (properties: SheetRenameDialogProps) => {
|
export const SheetRenameDialog = (properties: SheetRenameDialogProps) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [name, setName] = useState(properties.defaultName);
|
const [name, setName] = useState(properties.defaultName);
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
properties.onClose();
|
properties.close();
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<Dialog open={properties.open} onClose={properties.onClose}>
|
<Dialog open={properties.isOpen} onClose={properties.close}>
|
||||||
<StyledDialogTitle>
|
<StyledDialogTitle>
|
||||||
{t("sheet_rename.title")}
|
{t("sheet_rename.title")}
|
||||||
<Cross onClick={handleClose} onKeyDown={() => {}}>
|
<Cross onClick={handleClose} onKeyDown={() => {}}>
|
||||||
@@ -53,9 +61,7 @@ const SheetRenameDialog = (properties: SheetRenameDialogProps) => {
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
if (event.key === "Enter") {
|
if (event.key === "Enter") {
|
||||||
properties.onNameChanged(name);
|
properties.onNameChanged(name);
|
||||||
properties.onClose();
|
properties.close();
|
||||||
} else if (event.key === "Escape") {
|
|
||||||
properties.onClose();
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
@@ -63,8 +69,6 @@ const SheetRenameDialog = (properties: SheetRenameDialogProps) => {
|
|||||||
}}
|
}}
|
||||||
spellCheck="false"
|
spellCheck="false"
|
||||||
onPaste={(event) => event.stopPropagation()}
|
onPaste={(event) => event.stopPropagation()}
|
||||||
onCopy={(event) => event.stopPropagation()}
|
|
||||||
onCut={(event) => event.stopPropagation()}
|
|
||||||
/>
|
/>
|
||||||
</StyledDialogContent>
|
</StyledDialogContent>
|
||||||
<DialogFooter>
|
<DialogFooter>
|
||||||
@@ -80,6 +84,94 @@ const SheetRenameDialog = (properties: SheetRenameDialogProps) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
interface SheetListMenuProps {
|
||||||
|
isOpen: boolean;
|
||||||
|
close: () => void;
|
||||||
|
anchorEl: HTMLButtonElement | null;
|
||||||
|
onSheetSelected: (index: number) => void;
|
||||||
|
sheetOptionsList: SheetOptions[];
|
||||||
|
selectedIndex: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
const SheetListMenu = (properties: SheetListMenuProps) => {
|
||||||
|
const {
|
||||||
|
isOpen,
|
||||||
|
close,
|
||||||
|
anchorEl,
|
||||||
|
onSheetSelected,
|
||||||
|
sheetOptionsList,
|
||||||
|
selectedIndex,
|
||||||
|
} = properties;
|
||||||
|
|
||||||
|
const hasColors = sheetOptionsList.some((tab) => !isWhiteColor(tab.color));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<StyledMenu
|
||||||
|
open={isOpen}
|
||||||
|
onClose={close}
|
||||||
|
anchorEl={anchorEl}
|
||||||
|
anchorOrigin={{
|
||||||
|
vertical: "top",
|
||||||
|
horizontal: "left",
|
||||||
|
}}
|
||||||
|
transformOrigin={{
|
||||||
|
vertical: "bottom",
|
||||||
|
horizontal: 6,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{sheetOptionsList.map((tab, index) => (
|
||||||
|
<StyledMenuItem
|
||||||
|
key={tab.sheetId}
|
||||||
|
onClick={() => onSheetSelected(index)}
|
||||||
|
>
|
||||||
|
{index === selectedIndex ? (
|
||||||
|
<Check
|
||||||
|
style={{ width: "16px", height: "16px", marginRight: "8px" }}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
style={{ width: "16px", height: "16px", marginRight: "8px" }}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{hasColors && <ItemColor style={{ backgroundColor: tab.color }} />}
|
||||||
|
<ItemName
|
||||||
|
style={{ fontWeight: index === selectedIndex ? "bold" : "normal" }}
|
||||||
|
>
|
||||||
|
{tab.name}
|
||||||
|
</ItemName>
|
||||||
|
</StyledMenuItem>
|
||||||
|
))}
|
||||||
|
</StyledMenu>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const StyledMenu = styled(Menu)({
|
||||||
|
"& .MuiPaper-root": {
|
||||||
|
borderRadius: 8,
|
||||||
|
padding: 4,
|
||||||
|
},
|
||||||
|
"& .MuiList-padding": {
|
||||||
|
padding: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const StyledMenuItem = styled(MenuItem)({
|
||||||
|
padding: 8,
|
||||||
|
borderRadius: 4,
|
||||||
|
});
|
||||||
|
|
||||||
|
const ItemColor = styled("div")`
|
||||||
|
width: 12px;
|
||||||
|
height: 12px;
|
||||||
|
border-radius: 4px;
|
||||||
|
margin-right: 8px;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const ItemName = styled("div")`
|
||||||
|
font-size: 12px;
|
||||||
|
color: #333;
|
||||||
|
`;
|
||||||
|
|
||||||
const StyledDialogTitle = styled("div")`
|
const StyledDialogTitle = styled("div")`
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -154,4 +246,4 @@ const StyledButton = styled("div")`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default SheetRenameDialog;
|
export default SheetListMenu;
|
||||||
@@ -6,11 +6,11 @@ import { theme } from "../../theme";
|
|||||||
import { NAVIGATION_HEIGHT } from "../constants";
|
import { NAVIGATION_HEIGHT } from "../constants";
|
||||||
import { StyledButton } from "../toolbar";
|
import { StyledButton } from "../toolbar";
|
||||||
import type { WorkbookState } from "../workbookState";
|
import type { WorkbookState } from "../workbookState";
|
||||||
import SheetListMenu from "./SheetListMenu";
|
import SheetListMenu from "./menus";
|
||||||
import SheetTab from "./SheetTab";
|
import Sheet from "./sheet";
|
||||||
import type { SheetOptions } from "./types";
|
import type { SheetOptions } from "./types";
|
||||||
|
|
||||||
export interface SheetTabBarProps {
|
export interface NavigationProps {
|
||||||
sheets: SheetOptions[];
|
sheets: SheetOptions[];
|
||||||
selectedIndex: number;
|
selectedIndex: number;
|
||||||
workbookState: WorkbookState;
|
workbookState: WorkbookState;
|
||||||
@@ -21,7 +21,7 @@ export interface SheetTabBarProps {
|
|||||||
onSheetDeleted: () => void;
|
onSheetDeleted: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SheetTabBar(props: SheetTabBarProps) {
|
function Navigation(props: NavigationProps) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { workbookState, onSheetSelected, sheets, selectedIndex } = props;
|
const { workbookState, onSheetSelected, sheets, selectedIndex } = props;
|
||||||
const [anchorEl, setAnchorEl] = useState<null | HTMLButtonElement>(null);
|
const [anchorEl, setAnchorEl] = useState<null | HTMLButtonElement>(null);
|
||||||
@@ -35,27 +35,24 @@ function SheetTabBar(props: SheetTabBarProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
<LeftButtonsContainer>
|
<StyledButton
|
||||||
<StyledButton
|
title={t("navigation.add_sheet")}
|
||||||
title={t("navigation.add_sheet")}
|
$pressed={false}
|
||||||
$pressed={false}
|
onClick={props.onAddBlankSheet}
|
||||||
onClick={props.onAddBlankSheet}
|
>
|
||||||
>
|
<Plus />
|
||||||
<Plus />
|
</StyledButton>
|
||||||
</StyledButton>
|
<StyledButton
|
||||||
<StyledButton
|
onClick={handleClick}
|
||||||
onClick={handleClick}
|
title={t("navigation.sheet_list")}
|
||||||
title={t("navigation.sheet_list")}
|
$pressed={false}
|
||||||
$pressed={false}
|
>
|
||||||
>
|
<Menu />
|
||||||
<Menu />
|
</StyledButton>
|
||||||
</StyledButton>
|
|
||||||
</LeftButtonsContainer>
|
|
||||||
<VerticalDivider />
|
|
||||||
<Sheets>
|
<Sheets>
|
||||||
<SheetInner>
|
<SheetInner>
|
||||||
{sheets.map((tab, index) => (
|
{sheets.map((tab, index) => (
|
||||||
<SheetTab
|
<Sheet
|
||||||
key={tab.sheetId}
|
key={tab.sheetId}
|
||||||
name={tab.name}
|
name={tab.name}
|
||||||
color={tab.color}
|
color={tab.color}
|
||||||
@@ -71,7 +68,6 @@ function SheetTabBar(props: SheetTabBarProps) {
|
|||||||
props.onSheetDeleted();
|
props.onSheetDeleted();
|
||||||
}}
|
}}
|
||||||
workbookState={workbookState}
|
workbookState={workbookState}
|
||||||
canDelete={sheets.length > 1}
|
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</SheetInner>
|
</SheetInner>
|
||||||
@@ -81,8 +77,8 @@ function SheetTabBar(props: SheetTabBarProps) {
|
|||||||
</Advert>
|
</Advert>
|
||||||
<SheetListMenu
|
<SheetListMenu
|
||||||
anchorEl={anchorEl}
|
anchorEl={anchorEl}
|
||||||
open={open}
|
isOpen={open}
|
||||||
onClose={handleClose}
|
close={handleClose}
|
||||||
sheetOptionsList={sheets}
|
sheetOptionsList={sheets}
|
||||||
onSheetSelected={(index) => {
|
onSheetSelected={(index) => {
|
||||||
onSheetSelected(index);
|
onSheetSelected(index);
|
||||||
@@ -96,8 +92,6 @@ function SheetTabBar(props: SheetTabBarProps) {
|
|||||||
|
|
||||||
// Note I have to specify the font-family in every component that can be considered stand-alone
|
// Note I have to specify the font-family in every component that can be considered stand-alone
|
||||||
const Container = styled("div")`
|
const Container = styled("div")`
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
left: 0px;
|
left: 0px;
|
||||||
@@ -105,10 +99,10 @@ const Container = styled("div")`
|
|||||||
display: flex;
|
display: flex;
|
||||||
height: ${NAVIGATION_HEIGHT}px;
|
height: ${NAVIGATION_HEIGHT}px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0px 12px;
|
padding-left: 12px;
|
||||||
font-family: Inter;
|
font-family: Inter;
|
||||||
background-color: ${theme.palette.common.white};
|
background-color: #fff;
|
||||||
border-top: 1px solid ${theme.palette.grey["300"]};
|
border-top: 1px solid #e0e0e0;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const Sheets = styled("div")`
|
const Sheets = styled("div")`
|
||||||
@@ -116,9 +110,6 @@ const Sheets = styled("div")`
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
scrollbar-width: none;
|
scrollbar-width: none;
|
||||||
padding-left: 12px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const SheetInner = styled("div")`
|
const SheetInner = styled("div")`
|
||||||
@@ -128,8 +119,8 @@ const SheetInner = styled("div")`
|
|||||||
const Advert = styled("a")`
|
const Advert = styled("a")`
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: ${theme.palette.primary.main};
|
color: #f2994a;
|
||||||
padding: 0px 0px 0px 12px;
|
padding: 0px 12px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
border-left: 1px solid ${theme.palette.grey["300"]};
|
border-left: 1px solid ${theme.palette.grey["300"]};
|
||||||
@@ -142,19 +133,4 @@ const Advert = styled("a")`
|
|||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const LeftButtonsContainer = styled("div")`
|
export default Navigation;
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
gap: 4px;
|
|
||||||
padding-right: 12px;
|
|
||||||
`;
|
|
||||||
|
|
||||||
const VerticalDivider = styled("div")`
|
|
||||||
height: 100%;
|
|
||||||
width: 0px;
|
|
||||||
@media (max-width: 769px) {
|
|
||||||
border-right: 1px solid ${theme.palette.grey["200"]};
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export default SheetTabBar;
|
|
||||||
@@ -1,26 +1,23 @@
|
|||||||
import { Button, Menu, MenuItem, styled } from "@mui/material";
|
import { Button, Menu, MenuItem, styled } from "@mui/material";
|
||||||
import type { MenuItemProps } from "@mui/material";
|
|
||||||
import { ChevronDown } from "lucide-react";
|
import { ChevronDown } from "lucide-react";
|
||||||
import { useRef, useState } from "react";
|
import { useRef, useState } from "react";
|
||||||
import { theme } from "../../theme";
|
|
||||||
import ColorPicker from "../colorPicker";
|
import ColorPicker from "../colorPicker";
|
||||||
import { isInReferenceMode } from "../editor/util";
|
import { isInReferenceMode } from "../editor/util";
|
||||||
import type { WorkbookState } from "../workbookState";
|
import type { WorkbookState } from "../workbookState";
|
||||||
import SheetRenameDialog from "./SheetRenameDialog";
|
import { SheetRenameDialog } from "./menus";
|
||||||
|
|
||||||
interface SheetTabProps {
|
interface SheetProps {
|
||||||
name: string;
|
name: string;
|
||||||
color: string;
|
color: string;
|
||||||
selected: boolean;
|
selected: boolean;
|
||||||
onSelected: () => void;
|
onSelected: () => void;
|
||||||
onColorChanged: (hex: string) => void;
|
onColorChanged: (hex: string) => void;
|
||||||
onRenamed: (name: string) => void;
|
onRenamed: (name: string) => void;
|
||||||
canDelete: boolean;
|
|
||||||
onDeleted: () => void;
|
onDeleted: () => void;
|
||||||
workbookState: WorkbookState;
|
workbookState: WorkbookState;
|
||||||
}
|
}
|
||||||
|
|
||||||
function SheetTab(props: SheetTabProps) {
|
function Sheet(props: SheetProps) {
|
||||||
const { name, color, selected, workbookState, onSelected } = props;
|
const { name, color, selected, workbookState, onSelected } = props;
|
||||||
const [anchorEl, setAnchorEl] = useState<null | HTMLButtonElement>(null);
|
const [anchorEl, setAnchorEl] = useState<null | HTMLButtonElement>(null);
|
||||||
const [colorPickerOpen, setColorPickerOpen] = useState(false);
|
const [colorPickerOpen, setColorPickerOpen] = useState(false);
|
||||||
@@ -41,9 +38,8 @@ function SheetTab(props: SheetTabProps) {
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TabWrapper
|
<Wrapper
|
||||||
$color={color}
|
style={{ borderBottomColor: color, fontWeight: selected ? 600 : 400 }}
|
||||||
$selected={selected}
|
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
onSelected();
|
onSelected();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@@ -59,11 +55,11 @@ function SheetTab(props: SheetTabProps) {
|
|||||||
}}
|
}}
|
||||||
ref={colorButton}
|
ref={colorButton}
|
||||||
>
|
>
|
||||||
<Name onDoubleClick={handleOpenRenameDialog}>{name}</Name>
|
<Name>{name}</Name>
|
||||||
<StyledButton onClick={handleOpen}>
|
<StyledButton onClick={handleOpen}>
|
||||||
<ChevronDown />
|
<ChevronDown />
|
||||||
</StyledButton>
|
</StyledButton>
|
||||||
</TabWrapper>
|
</Wrapper>
|
||||||
<StyledMenu
|
<StyledMenu
|
||||||
anchorEl={anchorEl}
|
anchorEl={anchorEl}
|
||||||
open={open}
|
open={open}
|
||||||
@@ -94,7 +90,6 @@ function SheetTab(props: SheetTabProps) {
|
|||||||
Change Color
|
Change Color
|
||||||
</StyledMenuItem>
|
</StyledMenuItem>
|
||||||
<StyledMenuItem
|
<StyledMenuItem
|
||||||
disabled={!props.canDelete}
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
props.onDeleted();
|
props.onDeleted();
|
||||||
handleClose();
|
handleClose();
|
||||||
@@ -105,8 +100,8 @@ function SheetTab(props: SheetTabProps) {
|
|||||||
</StyledMenuItem>
|
</StyledMenuItem>
|
||||||
</StyledMenu>
|
</StyledMenu>
|
||||||
<SheetRenameDialog
|
<SheetRenameDialog
|
||||||
open={renameDialogOpen}
|
isOpen={renameDialogOpen}
|
||||||
onClose={handleCloseRenameDialog}
|
close={handleCloseRenameDialog}
|
||||||
defaultName={name}
|
defaultName={name}
|
||||||
onNameChanged={(newName) => {
|
onNameChanged={(newName) => {
|
||||||
props.onRenamed(newName);
|
props.onRenamed(newName);
|
||||||
@@ -129,42 +124,10 @@ function SheetTab(props: SheetTabProps) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const StyledMenu = styled(Menu)`
|
const StyledMenu = styled(Menu)``;
|
||||||
& .MuiPaper-root {
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 4px 0px;
|
|
||||||
margin-left: -4px;
|
|
||||||
}
|
|
||||||
& .MuiList-root {
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const StyledMenuItem = styled(MenuItem)<MenuItemProps>(() => ({
|
const StyledMenuItem = styled(MenuItem)`
|
||||||
display: "flex",
|
font-size: 12px;
|
||||||
justifyContent: "space-between",
|
|
||||||
fontSize: "12px",
|
|
||||||
width: "calc(100% - 8px)",
|
|
||||||
margin: "0px 4px",
|
|
||||||
borderRadius: "4px",
|
|
||||||
padding: "8px",
|
|
||||||
height: "32px",
|
|
||||||
"&:disabled": {
|
|
||||||
color: "#BDBDBD",
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
const TabWrapper = styled("div")<{ $color: string; $selected: boolean }>`
|
|
||||||
display: flex;
|
|
||||||
margin-right: 12px;
|
|
||||||
border-bottom: 3px solid ${(props) => props.$color};
|
|
||||||
line-height: 37px;
|
|
||||||
padding: 0px 4px;
|
|
||||||
align-items: center;
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: ${(props) => (props.$selected ? 600 : 400)};
|
|
||||||
background-color: ${(props) =>
|
|
||||||
props.$selected ? `${theme.palette.grey[50]}80` : "transparent"};
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const StyledButton = styled(Button)`
|
const StyledButton = styled(Button)`
|
||||||
@@ -174,27 +137,26 @@ const StyledButton = styled(Button)`
|
|||||||
padding: 0px;
|
padding: 0px;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
font-weight: inherit;
|
font-weight: inherit;
|
||||||
&:hover {
|
|
||||||
background-color: transparent;
|
|
||||||
}
|
|
||||||
&:active {
|
|
||||||
background-color: transparent;
|
|
||||||
}
|
|
||||||
svg {
|
svg {
|
||||||
width: 15px;
|
width: 15px;
|
||||||
height: 15px;
|
height: 15px;
|
||||||
transition: transform 0.2s;
|
|
||||||
}
|
|
||||||
&:hover svg {
|
|
||||||
transform: translateY(2px);
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const Wrapper = styled("div")`
|
||||||
|
display: flex;
|
||||||
|
margin-left: 20px;
|
||||||
|
border-bottom: 3px solid;
|
||||||
|
border-top: 3px solid white;
|
||||||
|
line-height: 34px;
|
||||||
|
align-items: center;
|
||||||
|
cursor: pointer;
|
||||||
|
`;
|
||||||
|
|
||||||
const Name = styled("div")`
|
const Name = styled("div")`
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
text-wrap: nowrap;
|
text-wrap: nowrap;
|
||||||
user-select: none;
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default SheetTab;
|
export default Sheet;
|
||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
Grid2x2X,
|
Grid2x2X,
|
||||||
Italic,
|
Italic,
|
||||||
PaintBucket,
|
PaintBucket,
|
||||||
PaintRoller,
|
Paintbrush2,
|
||||||
Percent,
|
Percent,
|
||||||
Redo2,
|
Redo2,
|
||||||
Strikethrough,
|
Strikethrough,
|
||||||
@@ -114,7 +114,7 @@ function Toolbar(properties: ToolbarProperties) {
|
|||||||
onClick={properties.onCopyStyles}
|
onClick={properties.onCopyStyles}
|
||||||
title={t("toolbar.copy_styles")}
|
title={t("toolbar.copy_styles")}
|
||||||
>
|
>
|
||||||
<PaintRoller />
|
<Paintbrush2 />
|
||||||
</StyledButton>
|
</StyledButton>
|
||||||
<Divider />
|
<Divider />
|
||||||
<StyledButton
|
<StyledButton
|
||||||
@@ -183,7 +183,8 @@ function Toolbar(properties: ToolbarProperties) {
|
|||||||
title={t("toolbar.format_number")}
|
title={t("toolbar.format_number")}
|
||||||
sx={{
|
sx={{
|
||||||
width: "40px", // Keep in sync with anchorOrigin in FormatMenu above
|
width: "40px", // Keep in sync with anchorOrigin in FormatMenu above
|
||||||
padding: "0px 4px",
|
fontSize: "13px",
|
||||||
|
fontWeight: 400,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{"123"}
|
{"123"}
|
||||||
@@ -390,9 +391,7 @@ const ToolbarContainer = styled("div")`
|
|||||||
font-family: Inter;
|
font-family: Inter;
|
||||||
border-radius: 4px 4px 0px 0px;
|
border-radius: 4px 4px 0px 0px;
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
padding: 0px 12px;
|
padding-left: 11px;
|
||||||
gap: 4px;
|
|
||||||
scrollbar-width: none;
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
type TypeButtonProperties = { $pressed: boolean; $underlinedColor?: string };
|
type TypeButtonProperties = { $pressed: boolean; $underlinedColor?: string };
|
||||||
@@ -400,16 +399,15 @@ export const StyledButton = styled("button")<TypeButtonProperties>(
|
|||||||
({ disabled, $pressed, $underlinedColor }) => {
|
({ disabled, $pressed, $underlinedColor }) => {
|
||||||
const result = {
|
const result = {
|
||||||
width: "24px",
|
width: "24px",
|
||||||
minWidth: "24px",
|
|
||||||
height: "24px",
|
height: "24px",
|
||||||
display: "inline-flex",
|
display: "inline-flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
fontSize: "12px",
|
fontSize: "26px",
|
||||||
border: `0px solid ${theme.palette.common.white}`,
|
border: "0px solid #fff",
|
||||||
borderRadius: "4px",
|
borderRadius: "2px",
|
||||||
|
marginRight: "5px",
|
||||||
transition: "all 0.2s",
|
transition: "all 0.2s",
|
||||||
outline: `1px solid ${theme.palette.common.white}`,
|
|
||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
backgroundColor: "white",
|
backgroundColor: "white",
|
||||||
padding: "0px",
|
padding: "0px",
|
||||||
@@ -421,28 +419,19 @@ export const StyledButton = styled("button")<TypeButtonProperties>(
|
|||||||
if (disabled) {
|
if (disabled) {
|
||||||
return {
|
return {
|
||||||
...result,
|
...result,
|
||||||
color: theme.palette.grey["400"],
|
color: theme.palette.grey["600"],
|
||||||
cursor: "default",
|
cursor: "default",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...result,
|
...result,
|
||||||
borderTop: $underlinedColor
|
borderTop: $underlinedColor ? "3px solid #FFF" : "none",
|
||||||
? `3px solid ${theme.palette.common.white}`
|
|
||||||
: "none",
|
|
||||||
borderBottom: $underlinedColor ? `3px solid ${$underlinedColor}` : "none",
|
borderBottom: $underlinedColor ? `3px solid ${$underlinedColor}` : "none",
|
||||||
color: theme.palette.grey["900"],
|
color: "#21243A",
|
||||||
backgroundColor: $pressed
|
backgroundColor: $pressed ? "#EEE" : "#FFF",
|
||||||
? theme.palette.grey["300"]
|
|
||||||
: theme.palette.common.white,
|
|
||||||
"&:hover": {
|
"&:hover": {
|
||||||
transition: "all 0.2s",
|
backgroundColor: "#F1F2F8",
|
||||||
outline: `1px solid ${theme.palette.grey["200"]}`,
|
borderTopColor: "#F1F2F8",
|
||||||
borderTopColor: theme.palette.common.white,
|
|
||||||
},
|
|
||||||
"&:active": {
|
|
||||||
backgroundColor: theme.palette.grey["300"],
|
|
||||||
outline: `1px solid ${theme.palette.grey["300"]}`,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -450,9 +439,10 @@ export const StyledButton = styled("button")<TypeButtonProperties>(
|
|||||||
|
|
||||||
const Divider = styled("div")({
|
const Divider = styled("div")({
|
||||||
width: "0px",
|
width: "0px",
|
||||||
height: "12px",
|
height: "10px",
|
||||||
borderLeft: `1px solid ${theme.palette.grey["300"]}`,
|
borderLeft: "1px solid #E0E0E0",
|
||||||
margin: "0px 12px",
|
marginLeft: "5px",
|
||||||
|
marginRight: "10px",
|
||||||
});
|
});
|
||||||
|
|
||||||
export default Toolbar;
|
export default Toolbar;
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import type {
|
|||||||
} from "@ironcalc/wasm";
|
} from "@ironcalc/wasm";
|
||||||
import { styled } from "@mui/material/styles";
|
import { styled } from "@mui/material/styles";
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import SheetTabBar from "./SheetTabBar/SheetTabBar";
|
|
||||||
import {
|
import {
|
||||||
COLUMN_WIDTH_SCALE,
|
COLUMN_WIDTH_SCALE,
|
||||||
LAST_COLUMN,
|
LAST_COLUMN,
|
||||||
@@ -17,6 +16,7 @@ import {
|
|||||||
getNewClipboardId,
|
getNewClipboardId,
|
||||||
} from "./clipboard";
|
} from "./clipboard";
|
||||||
import FormulaBar from "./formulabar";
|
import FormulaBar from "./formulabar";
|
||||||
|
import Navigation from "./navigation/navigation";
|
||||||
import Toolbar from "./toolbar";
|
import Toolbar from "./toolbar";
|
||||||
import useKeyboardNavigation from "./useKeyboardNavigation";
|
import useKeyboardNavigation from "./useKeyboardNavigation";
|
||||||
import { type NavigationKey, getCellAddress } from "./util";
|
import { type NavigationKey, getCellAddress } from "./util";
|
||||||
@@ -390,12 +390,7 @@ const Workbook = (props: { model: Model; workbookState: WorkbookState }) => {
|
|||||||
}
|
}
|
||||||
data.set(Number.parseInt(row, 10), rowMap);
|
data.set(Number.parseInt(row, 10), rowMap);
|
||||||
}
|
}
|
||||||
model.pasteFromClipboard(
|
model.pasteFromClipboard(source.area, data, source.type === "cut");
|
||||||
source.sheet,
|
|
||||||
source.area,
|
|
||||||
data,
|
|
||||||
source.type === "cut",
|
|
||||||
);
|
|
||||||
setRedrawId((id) => id + 1);
|
setRedrawId((id) => id + 1);
|
||||||
} else if (mimeType === "text/plain") {
|
} else if (mimeType === "text/plain") {
|
||||||
const {
|
const {
|
||||||
@@ -421,7 +416,6 @@ const Workbook = (props: { model: Model; workbookState: WorkbookState }) => {
|
|||||||
}}
|
}}
|
||||||
onCopy={(event: React.ClipboardEvent) => {
|
onCopy={(event: React.ClipboardEvent) => {
|
||||||
const data = model.copyToClipboard();
|
const data = model.copyToClipboard();
|
||||||
const sheet = model.getSelectedSheet();
|
|
||||||
// '2024-10-18T14:07:37.599Z'
|
// '2024-10-18T14:07:37.599Z'
|
||||||
|
|
||||||
let clipboardId = sessionStorage.getItem(
|
let clipboardId = sessionStorage.getItem(
|
||||||
@@ -449,7 +443,6 @@ const Workbook = (props: { model: Model; workbookState: WorkbookState }) => {
|
|||||||
type: "copy",
|
type: "copy",
|
||||||
area: data.range,
|
area: data.range,
|
||||||
sheetData,
|
sheetData,
|
||||||
sheet,
|
|
||||||
clipboardId,
|
clipboardId,
|
||||||
});
|
});
|
||||||
event.clipboardData.setData("text/plain", data.csv);
|
event.clipboardData.setData("text/plain", data.csv);
|
||||||
@@ -459,7 +452,6 @@ const Workbook = (props: { model: Model; workbookState: WorkbookState }) => {
|
|||||||
}}
|
}}
|
||||||
onCut={(event: React.ClipboardEvent) => {
|
onCut={(event: React.ClipboardEvent) => {
|
||||||
const data = model.copyToClipboard();
|
const data = model.copyToClipboard();
|
||||||
const sheet = model.getSelectedSheet();
|
|
||||||
// '2024-10-18T14:07:37.599Z'
|
// '2024-10-18T14:07:37.599Z'
|
||||||
|
|
||||||
let clipboardId = sessionStorage.getItem(
|
let clipboardId = sessionStorage.getItem(
|
||||||
@@ -487,7 +479,6 @@ const Workbook = (props: { model: Model; workbookState: WorkbookState }) => {
|
|||||||
type: "cut",
|
type: "cut",
|
||||||
area: data.range,
|
area: data.range,
|
||||||
sheetData,
|
sheetData,
|
||||||
sheet,
|
|
||||||
clipboardId,
|
clipboardId,
|
||||||
});
|
});
|
||||||
event.clipboardData.setData("text/plain", data.csv);
|
event.clipboardData.setData("text/plain", data.csv);
|
||||||
@@ -581,7 +572,7 @@ const Workbook = (props: { model: Model; workbookState: WorkbookState }) => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<SheetTabBar
|
<Navigation
|
||||||
sheets={info}
|
sheets={info}
|
||||||
selectedIndex={model.getSelectedSheet()}
|
selectedIndex={model.getSelectedSheet()}
|
||||||
workbookState={workbookState}
|
workbookState={workbookState}
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M3 8H2M14 8H13M7 8H5M11 8H9M14 4H2M2.01 12H2M4.01 12H4M6.01 12H6M8.01 12H8M10.01 12H10M12.01 12H12M14.01 12H14" stroke="#333333" stroke-linecap="round" stroke-linejoin="round"/>
|
<line x1="0" y1="2" x2="16" y2="2" stroke="#000"/>
|
||||||
|
<!-- Dashes and gaps of the same size -->
|
||||||
|
<line x1="0" y1="8" x2="16" y2="8" stroke-dasharray="2.28 2.28" stroke="#000"/>
|
||||||
|
<!-- Dashes and gaps of different sizes -->
|
||||||
|
<line x1="0" y1="14" x2="16" y2="14" stroke-dasharray="1 2" stroke="#000"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 290 B After Width: | Height: | Size: 400 B |
@@ -148,6 +148,65 @@ fn load_columns(ws: Node) -> Result<Vec<Col>, XlsxError> {
|
|||||||
Ok(cols)
|
Ok(cols)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// https://c-rex.net/samples/ooxml/e1/Part4/OOXML_P4_DOCX_cfRule_topic_ID0EFKO4.html
|
||||||
|
fn load_conditional_formatting(ws: Node) -> Result<Vec<String>, XlsxError> {
|
||||||
|
// Conditional Formatting
|
||||||
|
// <conditionalFormatting sqref="B1:B9">
|
||||||
|
// <cfRule type="colorScale" priority="1">
|
||||||
|
// <colorScale>
|
||||||
|
// <cfvo type="min"/>
|
||||||
|
// <cfvo type="max"/>
|
||||||
|
// <color rgb="FFF8696B"/>
|
||||||
|
// <color rgb="FFFCFCFF"/>
|
||||||
|
// </colorScale>
|
||||||
|
// </cfRule>
|
||||||
|
// </conditionalFormatting>
|
||||||
|
let mut conditional_formatting = Vec::new();
|
||||||
|
let conditional_formatting_nodes = ws
|
||||||
|
.children()
|
||||||
|
.filter(|n| n.has_tag_name("conditionalFormattng"))
|
||||||
|
.collect::<Vec<Node>>();
|
||||||
|
for format in conditional_formatting_nodes {
|
||||||
|
let reference = get_attribute(&format, "sqref")?.to_string();
|
||||||
|
// cfRule
|
||||||
|
let cf_rule_nodes = ws
|
||||||
|
.children()
|
||||||
|
.filter(|n| n.has_tag_name("cfRule"))
|
||||||
|
.collect::<Vec<Node>>();
|
||||||
|
if cf_rule_nodes.len() == 1 {
|
||||||
|
let cf_rule = cf_rule_nodes[0] ;
|
||||||
|
let cf_type = get_attribute(&cf_rule, "type")?.to_string();
|
||||||
|
match cf_type.as_str() {
|
||||||
|
"colorScale" => {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
"aboveAverage" => {
|
||||||
|
let dxf_id = get_attribute(&cf_rule, "dxfId")?.to_string();
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
"notContainsBlanks" => {
|
||||||
|
let dxf_id = get_attribute(&cf_rule, "dxfId")?.to_string();
|
||||||
|
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// priority
|
||||||
|
|
||||||
|
// if type is avobeAverage then avobeAverage (and equlAverage)
|
||||||
|
|
||||||
|
// dxfId for some types((Differential Formatting Id) What style to apply when the criteria are met
|
||||||
|
|
||||||
|
// Posible children
|
||||||
|
// formula
|
||||||
|
// colorScales
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(conditional_formatting)
|
||||||
|
}
|
||||||
|
|
||||||
fn load_merge_cells(ws: Node) -> Result<Vec<String>, XlsxError> {
|
fn load_merge_cells(ws: Node) -> Result<Vec<String>, XlsxError> {
|
||||||
// 18.3.1.55 Merge Cells
|
// 18.3.1.55 Merge Cells
|
||||||
// <mergeCells count="1">
|
// <mergeCells count="1">
|
||||||
@@ -945,17 +1004,7 @@ pub(super) fn load_sheet<R: Read + std::io::Seek>(
|
|||||||
|
|
||||||
let merge_cells = load_merge_cells(ws)?;
|
let merge_cells = load_merge_cells(ws)?;
|
||||||
|
|
||||||
// Conditional Formatting
|
let conditional_formatting = load_conditional_formatting(ws)?;
|
||||||
// <conditionalFormatting sqref="B1:B9">
|
|
||||||
// <cfRule type="colorScale" priority="1">
|
|
||||||
// <colorScale>
|
|
||||||
// <cfvo type="min"/>
|
|
||||||
// <cfvo type="max"/>
|
|
||||||
// <color rgb="FFF8696B"/>
|
|
||||||
// <color rgb="FFFCFCFF"/>
|
|
||||||
// </colorScale>
|
|
||||||
// </cfRule>
|
|
||||||
// </conditionalFormatting>
|
|
||||||
// pageSetup
|
// pageSetup
|
||||||
// <pageSetup orientation="portrait" r:id="rId1"/>
|
// <pageSetup orientation="portrait" r:id="rId1"/>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user