import React, { useState } from "react"; import { DataEditorAll as DataEditor } from "../../data-editor-all.js"; import { BeautifulWrapper, Description, useMockDataGenerator, defaultProps } from "../../data-editor/stories/utils.js"; import { SimpleThemeWrapper } from "../../stories/story-utils.js"; import { type Keybinds, type Keybind, keybindingDefaults } from "../../data-editor/data-editor-keybindings.js"; export default { title: "Glide-Data-Grid/DataEditor Demos", decorators: [ (Story: React.ComponentType) => ( ), ], }; export const CustomKeybindings: React.VFC = () => { const { getCellContent, cols, setCellValue } = useMockDataGenerator(30, false); const keybindingStyle = { display: "grid", gridTemplateColumns: "repeat(4, 1fr)", gridColumnGap: "32px", gridRowGap: "10px", marginBottom: "10px", marginTop: "20px", font: "13px sans-serif", }; const controlGroupStyle = { display: "flex", justifyContent: "space-between", alignItems: "center", }; const { copy, cut, paste, pageDown, pageUp, first, last, ...rest } = keybindingDefaults; const [keybindings, setKeybindings] = useState>(rest); const handleKeybindingChange = (key: keyof Keybinds, value: Keybind) => { setKeybindings(prev => ({ ...prev, [key]: value })); }; return ( This demo showcases custom keybindings. Modify the keybindings using the controls below.
{Object.keys(rest).map(key => (
handleKeybindingChange( key as keyof Keybinds, e.target.checked ? true : false ) } /> handleKeybindingChange(key as keyof Keybinds, e.target.value)} />
))}
}>
); };