import React from 'react';
import { TextInput } from '@breakaway/preact-core';

export const TextInputSelectUsingRef: React.FunctionComponent = () => {
  const [value, setValue] = React.useState('select all on click');
  const ref = React.useRef<HTMLInputElement>(null);
  return (
    <TextInput
      ref={ref}
      value={value}
      onFocus={() => ref?.current?.select()}
      onChange={(_event, value) => setValue(value)}
      aria-label="select-all"
    />
  );
};
