@1771technologies/lytenyte-pro
Version:
Blazingly fast headless React data grid with 100s of features.
28 lines (27 loc) • 1.12 kB
JavaScript
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { useSlot } from "@1771technologies/lytenyte-core/yinternal";
import { forwardRef } from "react";
import { useFilterRow } from "./filter-row-context.js";
function ValueInputImpl({ as, ...props }, ref) {
const ctx = useFilterRow();
const slot = useSlot({
slot: as ?? (_jsx(_Fragment, { children: !ctx.filterHasNoValue && (_jsx("input", { type: ctx.filter.kind === "number" || ctx.isNumberInput
? "number"
: ctx.filter.kind === "date"
? "date"
: "text", value: ctx.value ?? "", onChange: (e) => {
ctx.onValueChange(e.target.value);
} })) })),
props: [props],
ref,
state: {
disabled: ctx.valueDisabled,
filterNeedsValue: ctx.filterHasNoValue,
isNumberInput: ctx.isNumberInput,
onValueChange: ctx.onValueChange,
value: ctx.value,
},
});
return slot;
}
export const ValueInput = forwardRef(ValueInputImpl);