/*! * Copyright (c) Microsoft. All rights reserved. * Licensed under the MIT license. See LICENSE file in the project. */ import type { SampleArgs } from '@datashaper/schema' import { num } from '@datashaper/utilities' import { SpinButton } from '@fluentui/react' import { format } from 'd3-format' import { memo } from 'react' import { useSpinButtonChangeHandler } from '../../../../hooks/index.js' import type { StepFormProps } from '../types.js' import { Container, Input, InputLabel, OrLabel, spinStyles, } from './Sample.styles.js' const whole = format('d') /** * Provides inputs for a Sample step. */ export const SampleForm: React.FC> = memo( function SampleForm({ step, onChange }) { const handleSizeChange = useSpinButtonChangeHandler( step, (s, val) => { s.args.size = num(val) }, onChange, ) const handlePercentChange = useSpinButtonChangeHandler( step, (s, val) => { s.args.proportion = val != null ? +val / 100 : undefined }, onChange, ) const handleSeedChange = useSpinButtonChangeHandler( step, (s, val) => { s.args.seed = val != null ? +val : undefined }, onChange, ) return ( # rows or percentage seed ) }, )