import { QueryLanguage } from "@contember/binding";
import { FieldContainer, Checkbox } from "@contember/ui";
import { dataGridCellsDictionary } from "./dataGridCellsDictionary.js";
import { jsx } from "react/jsx-runtime";
import { useMessageFormatter } from "../../../../../i18n/useMessageFormatter.js";
const NullConditionFilter = ({
  filter,
  setFilter,
  field,
  environment,
  showNullConditionFilter
}) => {
  const formatMessage = useMessageFormatter(dataGridCellsDictionary);
  const desugared = QueryLanguage.desugarRelativeSingleField(field, environment);
  const entitySchema = environment.getSubTreeNode().entity;
  const fieldSchema = entitySchema.fields.get(desugared.field);
  const showFilter = showNullConditionFilter ?? fieldSchema?.nullable === true;
  if (!showFilter) {
    return null;
  }
  return /* @__PURE__ */ jsx(FieldContainer, {
    label: /* @__PURE__ */ jsx("i", {
      style: {
        opacity: 0.8,
        fontWeight: "normal"
      },
      children: formatMessage("dataGridCells.includeNull")
    }),
    labelPosition: "labelInlineRight",
    children: /* @__PURE__ */ jsx(Checkbox, {
      notNull: true,
      value: filter.nullCondition,
      onChange: (checked) => {
        setFilter({
          ...filter,
          nullCondition: !!checked
        });
      }
    })
  }, "__null");
};
export {
  NullConditionFilter
};
//# sourceMappingURL=NullConditionFilter.js.map
