/*! * Copyright (c) Microsoft. All rights reserved. * Licensed under the MIT license. See LICENSE file in the project. */ import type { EncodeDecodeArgs } from '@datashaper/schema' import { memo, useEffect } from 'react' import type { StepFormProps } from '../types.js' import { EncodeDecodeFormBase } from './EncodeDecodeForm.base.js' import { useCodebookContent } from './EncodeDecodeForm.hooks.js' /* * * Input table is expected to be edited elsewhere and configured as the step input. */ export const EncodeDecodeForm: React.FC> = memo( function EncodeDecodeForm({ step, onChange, table }) { const codebook = useCodebookContent(table) useEffect(() => { if (table != null && onChange != null) { if (step.args.codebook == null && codebook != null) { onChange({ ...step, args: { ...step.args, codebook, }, }) } } }, [table, onChange, step, codebook]) return }, )