import React from "react";
import { useEventListener } from "../../common/utils.js";
import { DataEditorAll as DataEditor } from "../../data-editor-all.js";
import { BeautifulWrapper, Description, defaultProps, useAllMockedKinds } from "../../data-editor/stories/utils.js";
import type { GridSelection } from "../../internal/data-grid/data-grid-types.js";
import { CompactSelection } from "../../internal/data-grid/data-grid-types.js";
import { SimpleThemeWrapper } from "../../stories/story-utils.js";
export default {
title: "Glide-Data-Grid/DataEditor Demos",
decorators: [
(Story: React.ComponentType) => (
You can update your grid however you want based on search inputs.
>
}>
),
],
};
export const SearchAsFilter: React.VFC = () => {
const { cols, getCellContent, onColumnResize, setCellValue } = useAllMockedKinds();
const [showSearch, setShowSearch] = React.useState(false);
const [selection, setSelection] = React.useState({
rows: CompactSelection.empty(),
columns: CompactSelection.empty(),
});
useEventListener(
"keydown",
React.useCallback(event => {
if ((event.ctrlKey || event.metaKey) && event.code === "KeyF") {
setShowSearch(cv => !cv);
event.stopPropagation();
event.preventDefault();
}
}, []),
window,
false,
true
);
const [searchValue, setSearchValue] = React.useState("");
return (
{
setShowSearch(false);
setSearchValue("");
}}
rows={searchValue.length === 0 ? 10_000 : searchValue.length}
/>
);
};