@@ -16,14 +16,11 @@ import {
1616} from 'react'
1717import { tv } from 'tailwind-variants'
1818
19- import { useDecorators } from '../../hooks/useDecorators'
2019import { useIntl } from '../../intl'
2120import { Button } from '../Button'
2221import { FaFolderOpenIcon } from '../Icon'
2322import { VisuallyHiddenText } from '../VisuallyHiddenText'
2423
25- import type { DecoratorsType } from '../../hooks/useDecorators'
26-
2724const classNameGenerator = tv ( {
2825 slots : {
2926 wrapper : [
@@ -74,8 +71,8 @@ type AbstractProps = PropsWithChildren<{
7471 disabled ?: boolean
7572 /** フォームにエラーがあるかどうか */
7673 error ?: boolean
77- /** コンポーネント内の文言を変更するための関数を設定 */
78- decorators ?: DecoratorsType < 'selectButtonLabel' >
74+ /** ファイル選択ボタンのラベル */
75+ selectButtonLabel ?: string
7976} >
8077type Props = AbstractProps & Omit < ComponentPropsWithRef < 'div' > , keyof AbstractProps >
8178
@@ -85,7 +82,10 @@ const overrideEventDefault = (e: DragEvent<HTMLElement>) => {
8582}
8683
8784export const DropZone = forwardRef < HTMLInputElement , Props > (
88- ( { children, onSelectFiles, multiple = true , disabled, error, decorators, ...rest } , ref ) => {
85+ (
86+ { children, onSelectFiles, multiple = true , disabled, error, selectButtonLabel, ...rest } ,
87+ ref ,
88+ ) => {
8989 const fileRef = useRef < HTMLInputElement > ( null )
9090 const [ filesDraggedOver , setFilesDraggedOver ] = useState ( false )
9191 const classNames = useMemo ( ( ) => {
@@ -149,7 +149,7 @@ export const DropZone = forwardRef<HTMLInputElement, Props>(
149149 onClick = { onClickButton }
150150 disabled = { disabled }
151151 className = { classNames . button }
152- decorators = { decorators }
152+ label = { selectButtonLabel }
153153 />
154154 < VisuallyHiddenText >
155155 { /* eslint-disable-next-line smarthr/a11y-input-in-form-control */ }
@@ -171,25 +171,23 @@ export const DropZone = forwardRef<HTMLInputElement, Props>(
171171)
172172
173173const SelectButton = memo <
174- ComponentPropsWithoutRef < typeof Button > & Pick < Props , 'decorators' > & { onClick : ( ) => void }
175- > ( ( { onClick, decorators , ...rest } ) => {
174+ ComponentPropsWithoutRef < typeof Button > & { onClick : ( ) => void ; label ?: string }
175+ > ( ( { onClick, label , ...rest } ) => {
176176 const { localize } = useIntl ( )
177177
178- const decoratorDefaultTexts = useMemo (
179- ( ) => ( {
180- selectButtonLabel : localize ( {
178+ const buttonLabel = useMemo (
179+ ( ) =>
180+ label ||
181+ localize ( {
181182 id : 'smarthr-ui/DropZone/selectButtonLabel' ,
182183 defaultText : 'ファイルを選択' ,
183184 } ) ,
184- } ) ,
185- [ localize ] ,
185+ [ label , localize ] ,
186186 )
187187
188- const decorated = useDecorators < 'selectButtonLabel' > ( decoratorDefaultTexts , decorators )
189-
190188 return (
191189 < Button { ...rest } prefix = { < FaFolderOpenIcon /> } onClick = { onClick } >
192- { decorated . selectButtonLabel }
190+ { buttonLabel }
193191 </ Button >
194192 )
195193} )
0 commit comments