UNPKG

@1771technologies/lytenyte-pro

Version:

Blazingly fast headless React data grid with 100s of features.

31 lines (30 loc) 1.47 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { useMemo } from "react"; import { GridProvider } from "../grid-provider/provider.js"; import { TreeRoot } from "../tree-view/root.js"; import { FilterTreeContext } from "./context.js"; import { useSlot } from "@1771technologies/lytenyte-core/yinternal"; export function Root({ grid, treeRef, filterIn, pivotMode, columnId, children, error, loading, errorAs, loadingAs, fetchItems, items, applyChangesImmediately, filterInChange, ...rootProps }) { const value = useMemo(() => { return { filter: filterIn, filterChange: filterInChange, pivotMode, columnId, items, applyChangesImmediately, }; }, [applyChangesImmediately, columnId, filterIn, filterInChange, items, pivotMode]); const loadingSlot = useSlot({ slot: loadingAs ?? _jsx("div", { children: "Loading..." }), }); const errorSlot = useSlot({ slot: errorAs ?? _jsx("div", { children: "Error Occurred Fetching" }), state: { error, refetch: fetchItems }, }); if (loading) return loadingSlot; if (error) return errorSlot; return (_jsx(GridProvider, { value: grid, children: _jsx(FilterTreeContext.Provider, { value: value, children: _jsx(TreeRoot, { selectMode: "none", transitionEnter: 0, transitionExit: 0, expansionDefault: true, ref: treeRef, ...rootProps, children: children }) }) })); }