// Copyright 2017-2024 @polkadot/react-params authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { Props } from '../types.js'; import React, { useCallback, useState } from 'react'; import { Toggle } from '@polkadot/react-components'; import { compactAddLength } from '@polkadot/util'; import { useTranslation } from '../translate.js'; import BaseBytes from './BaseBytes.js'; import File from './File.js'; function Bytes ({ className = '', defaultValue, isDisabled, isError, label, name, onChange, onEnter, onEscape, type, withLabel }: Props): React.ReactElement { const { t } = useTranslation(); const [isValid, setIsValid] = useState(false); const [isFileDrop, setFileInput] = useState(false); const _onChangeFile = useCallback( (value: Uint8Array): void => { const isValid = value.length !== 0; onChange && onChange({ isValid, value: compactAddLength(value) }); setIsValid(isValid); }, [onChange] ); const toggleLabel = !isDisabled && ( ); return (
{!isDisabled && isFileDrop ? ( ) : ( ) } {}
); } export default React.memo(Bytes);