UNPKG

@1771technologies/lytenyte-pro

Version:

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

25 lines (24 loc) 1.09 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { forwardRef } from "react"; import { useSortRowCtx } from "./context.js"; import { useSlot } from "@1771technologies/lytenyte-core/yinternal"; export const SortDirectionSelect = forwardRef(function SortDirectionSelect({ as, ...props }, forwarded) { const row = useSortRowCtx(); const el = (_jsx("select", { "aria-label": "Select sort direction", value: row.sortDirectionSelected?.value ?? "", onChange: (e) => { const item = row.sortDirectionOptions.find((c) => c.value === e.target.value); row.sortDirectionOnSelect(item ?? null); }, children: row.sortDirectionOptions.map((c) => { return (_jsx("option", { value: c.value, children: c.label }, c.value)); }) })); const renderer = useSlot({ props: [props], ref: forwarded, slot: as ?? el, state: { options: row.sortDirectionOptions, onSelect: row.sortDirectionOnSelect, value: row.sortDirectionSelected, }, }); return renderer; });