-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: supports custom onChange handling in text, select, and upload f…
…ields
- Loading branch information
1 parent
3540a18
commit 4affdc3
Showing
9 changed files
with
166 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
demo/collections/CustomComponents/components/fields/UI/Field/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React, { useCallback } from 'react'; | ||
import TextInput from '../../../../../../../src/admin/components/forms/field-types/Text'; | ||
import { UIField as UIFieldType } from '../../../../../../../src/fields/config/types'; | ||
import SelectInput from '../../../../../../../src/admin/components/forms/field-types/Select'; | ||
|
||
const UIField: React.FC<UIFieldType> = () => { | ||
const [textValue, setTextValue] = React.useState(''); | ||
const [selectValue, setSelectValue] = React.useState(''); | ||
|
||
const onTextChange = useCallback((incomingValue) => { | ||
setTextValue(incomingValue); | ||
}, []) | ||
|
||
const onSelectChange = useCallback((incomingValue) => { | ||
setSelectValue(incomingValue); | ||
}, []) | ||
|
||
return ( | ||
<div> | ||
<TextInput | ||
name="ui-text" | ||
label="Presentation-only text field (does not submit)" | ||
value={textValue as string} | ||
onChange={onTextChange} | ||
/> | ||
<SelectInput | ||
name="ui-select" | ||
label="Presentation-only select field (does not submit)" | ||
options={[ | ||
{ | ||
label: 'Option 1', | ||
value: 'option-1' | ||
}, | ||
{ | ||
label: 'Option 2', | ||
value: 'option-2' | ||
}, | ||
{ | ||
label: 'Option 3', | ||
value: 'option-4' | ||
} | ||
]} | ||
value={selectValue as string} | ||
onChange={onSelectChange} | ||
/> | ||
</div> | ||
) | ||
}; | ||
|
||
export default UIField; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.