43f1f6e9f2
sign.js : - aria-label sur les 4 Fab (Se déconnecter, dashboard, Se connecter, S'enregistrer) - Correction des guillemets typographiques U+2018/U+2019 en ASCII (empêchaient le parsing JSX) - Suppression de useMemo inutilisé - IIFE async ;() → startSubscription() nommée + .catch() explicite (semi-style + no-void) auth-form/index.js : - aria-label des IconButton visibility traduits en français avec état dynamique : 'Afficher/Masquer le mot de passe' et 'Afficher/Masquer la vérification' version-timeline.js : - aria-label='Comparer les versions' sur IconButton Comparer - aria-label dynamique + aria-expanded sur le bouton expand/collapse - Correction object-curly-newline et jsx-closing-bracket-location (pré-existants) version-search.js : - inputProps aria-label='Rechercher dans les versions' (placeholder seul insuffisant) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
78 lines
2.2 KiB
JavaScript
78 lines
2.2 KiB
JavaScript
import {useState} from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import Box from '@mui/material/Box'
|
|
import TextField from '@mui/material/TextField'
|
|
import InputAdornment from '@mui/material/InputAdornment'
|
|
import IconButton from '@mui/material/IconButton'
|
|
import SearchIcon from '@mui/icons-material/Search'
|
|
import ClearIcon from '@mui/icons-material/Clear'
|
|
import {useDebouncedCallback} from 'use-debounce'
|
|
|
|
export default function VersionSearch({onSearchChange, placeholder = 'Rechercher dans les versions...'}) {
|
|
const [searchValue, setSearchValue] = useState('')
|
|
|
|
// Debounce search to avoid too many filter updates
|
|
const debouncedSearch = useDebouncedCallback(value => {
|
|
onSearchChange(value.trim())
|
|
}, 300)
|
|
|
|
const handleSearchChange = event => {
|
|
const {value} = event.target
|
|
setSearchValue(value)
|
|
debouncedSearch(value)
|
|
}
|
|
|
|
const handleClearSearch = () => {
|
|
setSearchValue('')
|
|
onSearchChange('')
|
|
}
|
|
|
|
return (
|
|
<Box sx={{mb: 2}}>
|
|
<TextField
|
|
fullWidth
|
|
size='small'
|
|
placeholder={placeholder}
|
|
value={searchValue}
|
|
inputProps={{'aria-label': 'Rechercher dans les versions'}}
|
|
InputProps={{
|
|
startAdornment: (
|
|
<InputAdornment position='start'>
|
|
<SearchIcon color='action' />
|
|
</InputAdornment>
|
|
),
|
|
endAdornment: searchValue && (
|
|
<InputAdornment position='end'>
|
|
<IconButton
|
|
size='small'
|
|
aria-label='effacer recherche'
|
|
edge='end'
|
|
onClick={handleClearSearch}
|
|
>
|
|
<ClearIcon />
|
|
</IconButton>
|
|
</InputAdornment>
|
|
)
|
|
}}
|
|
sx={{
|
|
'& .MuiOutlinedInput-root': {
|
|
backgroundColor: 'background.paper',
|
|
'&:hover': {
|
|
backgroundColor: 'action.hover'
|
|
},
|
|
'&.Mui-focused': {
|
|
backgroundColor: 'background.paper'
|
|
}
|
|
}
|
|
}}
|
|
onChange={handleSearchChange}
|
|
/>
|
|
</Box>
|
|
)
|
|
}
|
|
|
|
VersionSearch.propTypes = {
|
|
onSearchChange: PropTypes.func.isRequired,
|
|
placeholder: PropTypes.string
|
|
}
|