import { map, keys } from "lodash"; import React from "react"; import { useDebouncedCallback } from "use-debounce"; import PropTypes from "prop-types"; import * as Grid from "antd/lib/grid"; import { Section, Select, Input, Checkbox, TextAlignmentSelect } from "@/components/visualizations/editor"; import ColumnTypes from "../columns"; export default function ColumnEditor({ column, onChange }) { function handleChange(changes) { onChange({ ...column, ...changes }); } const [handleChangeDebounced] = useDebouncedCallback(handleChange, 200); const AdditionalOptions = ColumnTypes[column.displayAs].Editor || null; return (
handleChangeDebounced({ title: event.target.value })} /> handleChange({ alignContent: event.target.value })} />
handleChange({ allowSearch: event.target.checked })}> Use for search
{AdditionalOptions && }
); } ColumnEditor.propTypes = { column: PropTypes.shape({ name: PropTypes.string.isRequired, title: PropTypes.string, visible: PropTypes.bool, alignContent: PropTypes.oneOf(["left", "center", "right"]), displayAs: PropTypes.oneOf(keys(ColumnTypes)), }).isRequired, onChange: PropTypes.func, }; ColumnEditor.defaultProps = { onChange: () => {}, };