import React from "react"; import { type DataEditorRef } from "../../data-editor/data-editor.js"; import { DataEditorAll as DataEditor } from "../../data-editor-all.js"; import { BeautifulWrapper, Description, MoreInfo, PropName, defaultProps, useAllMockedKinds, } from "../../data-editor/stories/utils.js"; import { SimpleThemeWrapper } from "../../stories/story-utils.js"; export default { title: "Glide-Data-Grid/DataEditor Demos", decorators: [ (Story: React.ComponentType) => ( ), ], }; interface ImperativeScrollProps { paddingY: number; paddingX: number; vAlign?: "start" | "center" | "end"; hAlign?: "start" | "center" | "end"; } export const ImperativeScroll: React.VFC = p => { const { cols, getCellContent, onColumnResize, setCellValue } = useAllMockedKinds(); const ref = React.useRef(null); const onClick = () => { ref.current?.scrollTo(4, 99, "both", p.paddingX, p.paddingY, { vAlign: p.vAlign, hAlign: p.hAlign, }); }; return ( You can imperatively scroll to a cell by calling scrollTo on a DataEditor ref. Click to scroll to column 4 row 100 }> ); }; (ImperativeScroll as any).args = { paddingY: 0, paddingX: 0, vAlign: "start", hAlign: "start", }; (ImperativeScroll as any).argTypes = { paddingY: 0, paddingX: 0, vAlign: { control: { type: "select" }, options: ["start", "center", "end", undefined], }, hAlign: { control: { type: "select" }, options: ["start", "center", "end", undefined], }, };