import React from "react"; import { DataEditorAll as DataEditor } from "../../data-editor-all.js"; import { BeautifulWrapper, Description, MoreInfo, PropName, KeyName, defaultProps, useAllMockedKinds, } from "../../data-editor/stories/utils.js"; import type { GridCell, Item } from "../../internal/data-grid/data-grid-types.js"; import { SimpleThemeWrapper } from "../../stories/story-utils.js"; import type { DataEditorCoreProps } from "../../index.js"; export default { title: "Glide-Data-Grid/DataEditor Demos", decorators: [ (Story: React.ComponentType) => ( ), ], }; export const CellActivatedEvent: React.VFC> = p => { const { cols, getCellContent, onColumnResize, setCellValue } = useAllMockedKinds(); const getCellContentMangled = React.useCallback( (item: Item): GridCell => { const result = getCellContent(item); if (item[0] === 3) { return { ...result, activationBehaviorOverride: "single-click", hoverEffect: true, } as any; } return result; }, [getCellContent] ); const [lastActivated, setLastActivated] = React.useState(undefined); const onCellActivated = React.useCallback((cell: Item) => { setLastActivated(cell); }, []); return ( When you tap Enter, Space or double click a cell, that cell is activated. You can track this with onCellActivated. Last activated cell:{" "} {lastActivated === undefined ? "none" : `(${lastActivated[0]}, ${lastActivated[1]})`} }> ); }; (CellActivatedEvent as any).argTypes = { cellActivationBehavior: { control: { type: "select" }, options: ["double-click", "single-click", "second-click"], }, }; (CellActivatedEvent as any).args = { cellActivationBehavior: "second-click", };