UNPKG

@1771technologies/lytenyte-pro

Version:

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

23 lines (22 loc) 806 B
import { jsx as _jsx } from "react/jsx-runtime"; import { forwardRef } from "react"; import { useSortManagerCtx } from "./context.js"; import { useEvent, useSlot } from "@1771technologies/lytenyte-core/yinternal"; export const SortClear = forwardRef(function SortClear({ as, ...props }, forwarded) { const ctx = useSortManagerCtx(); const onClear = useEvent(() => { if (ctx.mode) { ctx.grid.state.columnPivotModel.set((prev) => ({ ...prev, sorts: [] })); } else { ctx.grid.state.sortModel.set([]); } }); const renderer = useSlot({ props: [typeof as !== "function" ? { onClick: onClear } : {}, props], ref: forwarded, slot: as ?? _jsx("button", {}), state: { onClear }, }); return renderer; });