Skip to content

Commit

Permalink
add isDisabled and placeholder props
Browse files Browse the repository at this point in the history
  • Loading branch information
fsimonjetz committed Aug 3, 2024
1 parent ed1c323 commit 696a10e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/fragmentarium/ui/LemmaSearchForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,22 @@ export const LemmaSearchForm = withData<
{
wordService: WordService
onChange: (name: string) => (name: string) => void
isDisabled?: boolean
placeholder?: string
},
{ lemmas: string },
LemmaOption[]
>(
({ data, wordService, onChange }) => {
({ data, wordService, onChange, isDisabled, placeholder }) => {
return (
<LemmaSelectionForm
wordService={wordService}
onChange={(query) => {
onChange('lemmas')(query.map((lemma) => lemma.value).join('+'))
}}
query={data}
isDisabled={isDisabled}
placeholder={placeholder}
/>
)
},
Expand Down
9 changes: 6 additions & 3 deletions src/fragmentarium/ui/lemmatization/LemmaSelectionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type Props = {
query?: readonly LemmaOption[]
onChange: (query: readonly LemmaOption[]) => void
wordService: { searchLemma(query: string): Promise<readonly Word[]> }
placeholder?: string
isDisabled?: boolean
}
type State = {
query: ValueType<LemmaOption, true>
Expand Down Expand Up @@ -97,11 +99,11 @@ class LemmaSelectionForm extends Component<Props, State> {
}
}

Select = ({ label }: { label: string }): JSX.Element => {
Select = (): JSX.Element => {
return (
<AsyncSelect
aria-label={'Select lemmata'}
placeholder={label}
placeholder={this.props.placeholder || 'Lemmata'}
isClearable
loadOptions={this.loadOptions}
onInputChange={this.onInputChange}
Expand All @@ -111,12 +113,13 @@ class LemmaSelectionForm extends Component<Props, State> {
isMulti={true}
components={{ Option, MultiValueLabel }}
isOptionSelected={() => false}
isDisabled={this.props.isDisabled}
/>
)
}

render(): JSX.Element {
return <this.Select label={'Lemmata'} />
return <this.Select />
}
}

Expand Down

0 comments on commit 696a10e

Please sign in to comment.