UNPKG

@1771technologies/lytenyte-pro

Version:

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

19 lines (18 loc) 687 B
import { jsx as _jsx } from "react/jsx-runtime"; import { forwardRef, useMemo } from "react"; import { useColumnItemContext } from "./context.js"; import { useSlot } from "@1771technologies/lytenyte-core/yinternal"; export const Label = forwardRef(function Label({ as, ...props }, forwarded) { const { item } = useColumnItemContext(); const label = useMemo(() => { if (item.kind == "branch") return item.id.split("#").at(-2); return item.data.name ?? item.data.id; }, [item]); const rendered = useSlot({ props: [{ children: label }, props], ref: forwarded, slot: as ?? _jsx("div", {}), }); return rendered; });