UNPKG

@1771technologies/lytenyte-pro

Version:

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

26 lines (25 loc) 1.03 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { useSlot } from "@1771technologies/lytenyte-core/yinternal"; import { forwardRef } from "react"; import { useFilterRow } from "./filter-row-context.js"; function OperatorSelectImpl({ as, ...props }, ref) { const ctx = useFilterRow(); const slot = useSlot({ props: [props], state: { options: ctx.operatorOptions, value: ctx.operatorValue, onChange: ctx.operatorOnChange, }, ref: ref, slot: as ?? (_jsx("select", { value: ctx.operatorValue?.value ?? "", onChange: (c) => { const val = c.target.value; const opt = ctx.operatorOptions.find((c) => c.value === val); ctx.operatorOnChange(opt); }, children: ctx.operatorOptions.map((c) => { return (_jsx("option", { value: c.value, children: c.label }, c.value)); }) })), }); return slot; } export const OperatorSelect = forwardRef(OperatorSelectImpl);