Files
metabuilder/components/fakemui/email/inputs/EmailAddressInput.tsx
johndoe6345789 c406b8df96 refactor: Reorganize FakeMUI by implementation type
Move FakeMUI content to appropriate root-level folders by implementation:

**React Components → components/fakemui/**
- 537 components (inputs, surfaces, layout, data-display, feedback,
  navigation, utils, atoms, lab, x, email, workflows)
- 416 SVG icons
- Full barrel exports in components/fakemui/index.ts

**QML Components → qml/**
- 104 Material Design 3 components (11 categories)
- 7 hybrid application views
- 8 desktop widgets
- qmldir module registration

**Python Bindings → python/fakemui/**
- 15 PyQt6 modules (120+ components)
- Full Python package structure with pyproject.toml

**SCSS/Styles → fakemui/** (renamed purpose)
- scss/ - Material Design 3 stylesheets
- styles/ - Component SCSS modules
- src/utils/ - Accessibility utilities
- index.ts now re-exports from components/fakemui/

This separation allows:
- React: import { Button } from '@metabuilder/components/fakemui'
- QML: import QmlComponents 1.0
- Python: from fakemui import Button, Card
- Backward compat: import { Button } from '@metabuilder/fakemui'

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-02 12:59:24 +00:00

49 lines
1.6 KiB
TypeScript

// fakemui/react/components/email/inputs/EmailAddressInput.tsx
import React, { forwardRef } from 'react'
import { TextField, TextFieldProps } from '../../inputs/TextField'
import { useAccessible } from '../../../../hooks/useAccessible'
export interface EmailAddressInputProps extends Omit<TextFieldProps, 'type'> {
onValidate?: (valid: boolean) => void
allowMultiple?: boolean
}
export const EmailAddressInput = forwardRef<HTMLInputElement, EmailAddressInputProps>(
({ onValidate, allowMultiple = false, testId: customTestId, ...props }, ref) => {
const accessible = useAccessible({
feature: 'email',
component: 'email-input',
identifier: customTestId || 'email'
})
const validateEmail = (value: string) => {
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
if (allowMultiple) {
const emails = value.split(',').map(e => e.trim())
return emails.every(e => emailRegex.test(e) || e === '')
}
return emailRegex.test(value) || value === ''
}
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const valid = validateEmail(e.target.value)
onValidate?.(valid)
props.onChange?.(e)
}
return (
<TextField
ref={ref}
type="email"
label={props.label || (allowMultiple ? 'Recipients' : 'Email Address')}
placeholder={allowMultiple ? 'user@example.com, another@example.com' : 'user@example.com'}
{...accessible}
{...props}
onChange={handleChange}
/>
)
}
)
EmailAddressInput.displayName = 'EmailAddressInput'