MCPcopy Create free account
hub / github.com/code-with-antonio/nodebase / FieldError

Function FieldError

src/components/ui/field.tsx:186–231  ·  view source on GitHub ↗
({
  className,
  children,
  errors,
  ...props
}: React.ComponentProps<"div"> & {
  errors?: Array<{ message?: string } | undefined>
})

Source from the content-addressed store, hash-verified

184}
185
186function FieldError({
187 className,
188 children,
189 errors,
190 ...props
191}: React.ComponentProps<"div"> & {
192 errors?: Array<{ message?: string } | undefined>
193}) {
194 const content = useMemo(() => {
195 if (children) {
196 return children
197 }
198
199 if (!errors) {
200 return null
201 }
202
203 if (errors?.length === 1 && errors[0]?.message) {
204 return errors[0].message
205 }
206
207 return (
208 <ul className="ml-4 flex list-disc flex-col gap-1">
209 {errors.map(
210 (error, index) =>
211 error?.message && <li key={index}>{error.message}</li>
212 )}
213 </ul>
214 )
215 }, [children, errors])
216
217 if (!content) {
218 return null
219 }
220
221 return (
222 <div
223 role="alert"
224 data-slot="field-error"
225 className={cn("text-destructive text-sm font-normal", className)}
226 {...props}
227 >
228 {content}
229 </div>
230 )
231}
232
233export {
234 Field,

Callers

nothing calls this directly

Calls 1

cnFunction · 0.90

Tested by

no test coverage detected