Skip to content

Commit 2637cfd

Browse files
AtsushiMclaude
andauthored
refactor(SearchInput)!: decorators属性を削除しIntlProviderのみを使用 (#6237)
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 253f0e4 commit 2637cfd

2 files changed

Lines changed: 8 additions & 25 deletions

File tree

packages/smarthr-ui/src/components/Input/SearchInput/SearchInput.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import {
2-
type ComponentProps,
3-
type ComponentPropsWithoutRef,
4-
type ReactNode,
5-
forwardRef,
6-
useMemo,
7-
} from 'react'
1+
import { type ComponentProps, type ReactNode, forwardRef, useMemo } from 'react'
82
import { tv } from 'tailwind-variants'
93

104
import { InputWithTooltip } from '../InputWithTooltip'
@@ -14,7 +8,6 @@ import { SearchInputIcon } from './SearchInputIcon'
148
type Props = Omit<ComponentProps<typeof InputWithTooltip>, 'tooltipMessage' | 'prefix'> & {
159
/** 入力欄の説明を紐付けるツールチップに表示するメッセージ */
1610
tooltipMessage: ReactNode
17-
decorators?: ComponentPropsWithoutRef<typeof SearchInputIcon>['decorators']
1811
}
1912

2013
const classNameGenerator = tv({
@@ -33,7 +26,7 @@ const classNameGenerator = tv({
3326
})
3427

3528
export const SearchInput = forwardRef<HTMLInputElement, Props>(
36-
({ decorators, width, className, ...rest }, ref) => {
29+
({ width, className, ...rest }, ref) => {
3730
const labelStyle = useMemo(
3831
() => ({
3932
width: typeof width === 'number' ? `${width}px` : width,
@@ -54,7 +47,7 @@ export const SearchInput = forwardRef<HTMLInputElement, Props>(
5447
<InputWithTooltip
5548
{...rest}
5649
ref={ref}
57-
prefix={<SearchInputIcon decorators={decorators} />}
50+
prefix={<SearchInputIcon />}
5851
className={classNames.input}
5952
/>
6053
</label>

packages/smarthr-ui/src/components/Input/SearchInput/SearchInputIcon.tsx

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,20 @@
22

33
import { useMemo } from 'react'
44

5-
import { type DecoratorsType, useDecorators } from '../../../hooks/useDecorators'
65
import { useIntl } from '../../../intl'
76
import { FaMagnifyingGlassIcon } from '../../Icon'
87

9-
type Props = {
10-
decorators?: DecoratorsType<DecoratorKeyTypes>
11-
}
12-
13-
type DecoratorKeyTypes = 'iconAlt'
14-
15-
export const SearchInputIcon = ({ decorators }: Props) => {
8+
export const SearchInputIcon = () => {
169
const { localize } = useIntl()
1710

18-
const decoratorDefaultTexts = useMemo(
19-
() => ({
20-
iconAlt: localize({
11+
const iconAlt = useMemo(
12+
() =>
13+
localize({
2114
id: 'smarthr-ui/SearchInput/iconAlt',
2215
defaultText: '検索',
2316
}),
24-
}),
2517
[localize],
2618
)
2719

28-
const decorated = useDecorators<DecoratorKeyTypes>(decoratorDefaultTexts, decorators)
29-
30-
return <FaMagnifyingGlassIcon alt={decorated.iconAlt} color="TEXT_GREY" />
20+
return <FaMagnifyingGlassIcon alt={iconAlt} color="TEXT_GREY" />
3121
}

0 commit comments

Comments
 (0)