File tree 2 files changed +18
-2
lines changed
packages/smarthr-ui/src/components/FormControl
2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ export default {
17
17
title : 'Forms(フォーム)/FormControl' ,
18
18
component : FormControl ,
19
19
}
20
-
21
20
export const All : StoryFn = ( ) => (
22
21
< Stack gap = { 2 } as = "dl" >
23
22
< Stack >
@@ -126,6 +125,20 @@ export const All: StoryFn = () => (
126
125
</ FormControl >
127
126
</ dd >
128
127
</ Stack >
128
+ < Stack >
129
+ < Text italic color = "TEXT_GREY" as = "dt" >
130
+ 入力要素への error 自動紐づけ(VRT 用の自動紐づけを切った場合)
131
+ </ Text >
132
+ < dd >
133
+ < FormControl
134
+ title = "氏名"
135
+ autoBindErrorInput = { false }
136
+ errorMessages = "氏名が入力されていません。"
137
+ >
138
+ < Input name = "fullname" value = "草野栄一郎" />
139
+ </ FormControl >
140
+ </ dd >
141
+ </ Stack >
129
142
</ Stack >
130
143
)
131
144
All . storyName = 'all'
Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ type Props = PropsWithChildren<{
47
47
exampleMessage ?: ReactNode
48
48
/** タイトルの下に表示するエラーメッセージ */
49
49
errorMessages ?: ReactNode | ReactNode [ ]
50
+ /** エラーがある場合に自動的に入力要素を error にするかどうか */
51
+ autoBindErrorInput ?: boolean
50
52
/** フォームコントロールの下に表示する補足メッセージ */
51
53
supplementaryMessage ?: ReactNode
52
54
/** `true` のとき、文字色を `TEXT_DISABLED` にする */
@@ -133,6 +135,7 @@ export const ActualFormControl: React.FC<Props & ElementProps> = ({
133
135
helpMessage,
134
136
exampleMessage,
135
137
errorMessages,
138
+ autoBindErrorInput = true ,
136
139
supplementaryMessage,
137
140
as = 'div' ,
138
141
className,
@@ -233,7 +236,7 @@ export const ActualFormControl: React.FC<Props & ElementProps> = ({
233
236
{ decorateFirstInputElement ( children , {
234
237
managedHtmlFor,
235
238
describedbyIds,
236
- error : actualErrorMessages . length > 0 ,
239
+ error : autoBindErrorInput && actualErrorMessages . length > 0 ,
237
240
} ) }
238
241
</ div >
239
242
You can’t perform that action at this time.
0 commit comments