Conditional Format Editor
Adds a Conditonal format editor component
Last updated
Adds a Conditonal format editor component
Last updated
import { CanvasGrid, SpreadsheetProvider, defaultSpreadsheetTheme } from "@rowsncolumns/spreadsheet"
import { useSpreadsheet, ConditionalFormatDialog, ConditionalFormatEditor } from "@rowsncolumns/spreadsheet-state"
const Spreadsheet = () => {
const [conditionalFormats, onChangeConditionalFormats] = useState<
ConditionalFormatRule[]>([]);
const [theme, onChangeTheme] = useState<SpreadsheetTheme>(
defaultSpreadsheetTheme
);
const {
activeSheetId,
rowCount,
columnCount,
getSheetName,
getSheetId,
onCreateConditionalFormattingRule,
onDeleteConditionalFormattingRule,
onUpdateConditionalFormattingRule,
onPreviewConditionalFormattingRule
} = useSpreadsheetState({
conditionalFormats
})
return (
<>
<ConditionalFormatDialog>
<ConditionalFormatEditor
sheetId={activeSheetId}
rowCount={rowCount}
columnCount={columnCount}
theme={theme}
conditionalFormats={conditionalFormats}
onCreateRule={onCreateConditionalFormattingRule}
onDeleteRule={onDeleteConditionalFormattingRule}
onUpdateRule={onUpdateConditionalFormattingRule}
onPreviewRule={onPreviewConditionalFormattingRule}
/>
</ConditionalFormatDialog>
</>
)
}
const App = () => (
<SpreadsheetProvider>
<Spreadsheet />
</SpreadsheetProvider>
)