@material-ui/core#FormControl TypeScript Examples
The following examples show how to use
@material-ui/core#FormControl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.tsx From Nishan with MIT License | 6 votes |
export function BasicSelect(props: Props) {
const classes = useStyles();
const { filter_item_label } = useContext(NotionFilterContext)
return <FormControl className={classes.formControl}>
{filter_item_label && <InputLabel>{props.label}</InputLabel>}
<Select
value={props.value}
onChange={props.onChange}
>
{props.items.map(({ value, label, icon = null }) => <MenuItem key={value} value={value}>{icon} {label}</MenuItem>)}
</Select>
</FormControl>
}
Example #2
Source File: branch_setup.tsx From jupyter-extensions with Apache License 2.0 | 6 votes |
render(): React.ReactElement {
return (
<FormControl
className={classes(setupItemClass)}
disabled={this.state.disabled}
variant="outlined"
>
<FormHelperText className={setupHelperTextClass}>Branch</FormHelperText>
<Select
className={classes(setupItemInnerClass)}
value={this.state.currBranch}
onChange={event => this._onChange(event)}
>
{this._renderBranches()}
</Select>
</FormControl>
);
}
Example #3
Source File: Settings.tsx From SpaceEye with MIT License | 6 votes |
SettingsSwitch: React.FC<SettingsSwitchProps> = props => {
const { label, isChecked, onChange } = props
return (
<FormControl component="fieldset">
<FormControlLabel
control={
<Switch
checked={isChecked}
onChange={(_, checked) => onChange(checked)}
name={label}
color="primary"
/>
}
label={label}
labelPlacement="top"
/>
</FormControl>
)
}
Example #4
Source File: StatusFilterOperators.tsx From frontend with Apache License 2.0 | 6 votes |
StatusInputComponent = (props: GridFilterInputValueProps) => {
const { item, applyValue } = props;
const { testRuns } = useTestRunState();
const handleFilterChange = (event: any) => {
applyValue({ ...item, value: event.target.value as string });
};
const filterOptions: Array<TestStatus> = Array.from(
new Set(testRuns.map((item) => item.status))
);
return (
<FormControl fullWidth>
<InputLabel shrink id="statusFilter">
Value
</InputLabel>
<Select
id="statusFilter"
native
displayEmpty
value={item.value}
onChange={handleFilterChange}
>
<option aria-label="All" value="" />
{filterOptions.map((item) => (
<option key={item} value={item}>
{item}
</option>
))}
</Select>
</FormControl>
);
}
Example #5
Source File: index.tsx From prism-frontend with MIT License | 6 votes |
export default function SimpleDropdown<OptionValue extends number | string>({
options,
value,
onChange,
...rest
}: {
options: [OptionValue, OptionLabel][];
value: OptionValue;
onChange: (value: OptionValue) => void;
}) {
const { t } = useSafeTranslation();
return (
<FormControl {...rest}>
<Select
value={value === undefined ? '' : value}
onChange={e => {
onChange(e.target.value as OptionValue);
}}
>
{options.map(([val, text]) => (
<MenuItem key={val} value={val}>
{t(text)}
</MenuItem>
))}
</Select>
</FormControl>
);
}
Example #6
Source File: AudioSelector.tsx From Oratio with MIT License | 6 votes |
export default function AudioSelector() {
const { t } = useTranslation();
const [sound, setSound] = React.useState('');
const handleSoundChange = (event: React.ChangeEvent<{ value: unknown }>) => {
setSound(event.target.value as string);
localStorage.setItem('soundFileName', event.target.value as string);
};
const classes = useStyles();
return (
<div>
<FormControl className={classes.root}>
<InputLabel id="demo-simple-select-label">
{t('Speech Sound')}
</InputLabel>
<Select
labelId="demo-simple-select-label"
id="demo-simple-select"
value={sound}
autoWidth
onChange={handleSoundChange}
>
{options.map((option) => (
<MenuItem key={option} value={option}>
{option}
</MenuItem>
))}
</Select>
</FormControl>
</div>
);
}
Example #7
Source File: SortMethodSelector.tsx From backstage with Apache License 2.0 | 6 votes |
SortMethodSelector = ({
sortMethodNbr,
handleSortMethodChange,
}: Props) => {
const classes = useStyles();
return (
<FormControl fullWidth>
<Select
className={classes.select}
disableUnderline
value={sortMethodNbr}
onChange={handleSortMethodChange}
>
<MenuItem value={0}>Latest updated</MenuItem>
<MenuItem value={1}>A-Z</MenuItem>
<MenuItem value={2}>Most members</MenuItem>
</Select>
</FormControl>
);
}
Example #8
Source File: SelectApplicationView.tsx From github-deploy-center with MIT License | 6 votes |
SelectApplicationView = () => {
const { applicationsById, selectedApplicationId } = useAppState()
const { selectApplication, editApplication, editDeployment } = useActions()
const sortedApplications = orderBy(applicationsById, (x) =>
x.name.toLowerCase()
)
return size(sortedApplications) ? (
<Box display="flex" alignItems="center" style={{ gap: '1rem' }}>
<FormControl variant="outlined" style={{ flex: 1 }}>
<InputLabel id="application-select-label">Application</InputLabel>
<Select
labelId="application-select-label"
label="Application"
onChange={(event) => {
selectApplication(event.target.value as string)
}}
value={selectedApplicationId}>
{map(sortedApplications, (app) => (
<MenuItem value={app.id} key={app.id}>
{app.name}
</MenuItem>
))}
</Select>
</FormControl>
<Button color="secondary" variant="contained" onClick={editApplication}>
Edit App
</Button>
<Button color="secondary" variant="contained" onClick={editDeployment}>
Edit Deploy
</Button>
</Box>
) : null
}
Example #9
Source File: PhoneInput.tsx From glific-frontend with GNU Affero General Public License v3.0 | 6 votes |
PhoneInput: React.SFC<InputProps> = ({
enableSearch = true,
form: { errors, setFieldValue },
field,
inputProps = {
name: field.name,
required: true,
autoFocus: false,
},
...props
}) => {
const errorText = getIn(errors, field.name);
const { placeholder } = props;
return (
<div className={styles.Input} data-testid="phoneInput">
<FormControl>
<ReactPhoneInput
containerClass={styles.Container}
inputClass={styles.PhoneNumber}
data-testid="phoneNumber"
placeholder={placeholder}
enableSearch={enableSearch}
country="in"
autoFormat={false}
inputProps={inputProps}
{...field}
value={field.value}
onChange={(event) => {
setFieldValue(field.name, event);
}}
/>
{errorText ? (
<FormHelperText classes={{ root: styles.FormHelperText }}>{errorText}</FormHelperText>
) : null}
</FormControl>
</div>
);
}
Example #10
Source File: HubSortDropdown.tsx From dashboard with Apache License 2.0 | 6 votes |
HubSortDropdown = ({
selectedSortOption,
sortOptions,
handleSortOption,
}: Props) => {
return (
<FormControl>
<SortLabel shrink>Sort</SortLabel>
<SortSelect
value={selectedSortOption}
onChange={handleSortOption}
input={<InputBase />}
data-name={`selectedHubSortDropdown-${selectedSortOption.replaceAll(
" ",
"_"
)}`}
>
{sortOptions.map((sortOption) => (
<MenuItem
data-name={`sortOptionHubSortDropdown-${sortOption.replaceAll(
" ",
"_"
)}`}
value={sortOption}
>
{sortOption}
</MenuItem>
))}
</SortSelect>
</FormControl>
)
}
Example #11
Source File: Options.tsx From art with MIT License | 6 votes |
export default function Options(props: IProps) {
const selectClasses = useSelectStyles();
return (
<div className="explore__options-box">
<Text style={{ "textAlign": "center", "fontWeight": "bold", "paddingRight": "10px" }} variant="large">Closest</Text>
<FormControl>
<Select
native
value={props.value}
onChange={(event) => { props.changeConditional(event.target.value) }}
classes={{
root: selectClasses.root
}}>
{props.choices.map((choice, index) => (<option key={index} value={choice}>{choice.replace(/_/g, " ")}</option>))}
</Select>
</FormControl>
<Text style={{ "textAlign": "center", "fontWeight": "bold", "paddingLeft": "10px"}} variant="large">Artworks:</Text>
</div>
);
}
Example #12
Source File: SenderFilters.tsx From parity-bridges-ui with GNU General Public License v3.0 | 6 votes |
export default function SenderFilters({
setFilterInput,
setShowEmpty,
setShowCompanion,
showEmpty,
showCompanion
}: Props) {
const classes = useStyles();
const { isBridged } = useGUIContext();
const handleChange = useCallback(
(event: React.ChangeEvent<HTMLInputElement>) => {
setFilterInput(event.target.value);
},
[setFilterInput]
);
return (
<div className={classes.filters}>
<SenderFilterInput handleChange={handleChange} />
<Divider />
<FormControl component="fieldset">
<FormGroup aria-label="position" row>
<SenderActionSwitch name="show empty" label="show empty" callback={setShowEmpty} checked={showEmpty} />
{isBridged && (
<SenderActionSwitch
name="show companion"
label="show companion"
callback={setShowCompanion}
checked={showCompanion}
/>
)}
</FormGroup>
</FormControl>
</div>
);
}
Example #13
Source File: TemplatesForm.tsx From prompts-ai with MIT License | 6 votes |
export default function TemplatesForm() {
const templateGroups = getTemplateGroups();
const flattenedTemplates = getFlattenedTemplates();
const dispatch = useDispatch();
return <Box>
<form onSubmit={(event) => {
event.preventDefault();
const elements: FormElements = event.currentTarget.elements as FormElements;
const template = flattenedTemplates.find((template) => template.id === elements.templateId.value);
if (template === undefined) {
return;
}
dispatch(loadTemplate(template.actionPayload))
dispatch(cleanExampleList());
}}>
<FormControl style={{minWidth: '100%'}}>
<Select native defaultValue="" id="template-select" name="templateId">
{templateGroups.map((templateGroup, ind) => (
<optgroup key={ind} label={templateGroup.name}>
{templateGroup.templates.map(template => (
<option key={template.id} value={template.id}>{template.name}</option>
))}
</optgroup>
))}
</Select>
</FormControl>
<Box mt={1}>
<Grid container spacing={1} alignItems="center">
<Grid item>
<Button type="submit" variant="contained" color="primary">Load</Button>
</Grid>
</Grid>
</Box>
</form>
</Box>;
}
Example #14
Source File: LabeledRadio.tsx From UsTaxes with GNU Affero General Public License v3.0 | 6 votes |
export function LabeledRadio<A>(props: LabeledRadioProps<A>): ReactElement {
const { label, name, values, useGrid = true, sizes = { xs: 12 } } = props
const classes = useStyles()
const { control } = useFormContext<A>()
return (
<ConditionallyWrap
condition={useGrid}
wrapper={(children) => (
<Grid item {...sizes}>
{children}
</Grid>
)}
>
<Controller
name={name}
render={({ field: { value, onChange } }) => (
<div className={classes.root}>
<FormControl component="fieldset">
<FormLabel>{label}</FormLabel>
<RadioGroup name={name} value={value} onChange={onChange}>
{values.map(([rowLabel, rowValue], i) => (
<FormControlLabel
key={i}
value={rowValue}
control={<Radio color="primary" />}
label={rowLabel}
/>
))}
</RadioGroup>
</FormControl>
</div>
)}
control={control}
/>
</ConditionallyWrap>
)
}
Example #15
Source File: CustomSelect.tsx From flect-chime-sdk-demo with Apache License 2.0 | 6 votes |
CustomSelect = <T extends string | number | readonly string[] | undefined>(props: CustomSelectProps<T>) => { const classes = useCustomSelectStyles({ height: props.height, fontsize: props.fontsize, labelFontsize: props.labelFontsize }); const [value, setValue] = useState<T | undefined>(props.defaultValue); const items = props.items.map((x) => { return ( <MenuItem style={{ fontSize: props.fontsize }} key={x.label} value={x.value}> <em>{x.label}</em> </MenuItem> ); }); return ( <FormControl> <InputLabel shrink={true} classes={{ root: classes.inputLabel, focused: classes.inputLabelFocused, }} > {props.label} </InputLabel> <Select onChange={(e) => { props.onChange(e.target.value as T); setValue(e.target.value as T); }} defaultValue={value} inputProps={{ classes: { root: classes.input, }, }} > {items} </Select> </FormControl> ); }
Example #16
Source File: Recaptcha.tsx From firebase-react-typescript-project-template with MIT License | 5 votes |
Recaptcha = () => {
const classes = useStyles();
const recaptchaVerified = useBooleanState(false);
const recaptchaError = useBooleanState(false);
const recaptcha = useRef<HTMLDivElement | null>(null);
useEffect(() => {
const setupRecaptcha = async () => {
(window as WindowWithRecaptcha).recaptchaVerifier = new firebase.auth.RecaptchaVerifier(
recaptcha.current,
{
size: "normal",
callback: () => {
recaptchaVerified.setTrue();
recaptchaError.setFalse();
},
"expired-callback": () => {
recaptchaVerified.setFalse();
recaptchaError.setTrue();
},
}
);
(window as WindowWithRecaptcha).recaptchaWidgetId = await (window as WindowWithRecaptcha).recaptchaVerifier?.render();
};
setupRecaptcha();
// eslint-disable-next-line
}, []);
return (
<FormControl
error={!recaptchaVerified.state && recaptchaError.state}
fullWidth
className={classes.recaptcha}
>
<div ref={recaptcha} />
{recaptchaError.state && (
<FormHelperText id="name-error-text">
Please verify you are a human
</FormHelperText>
)}
</FormControl>
);
}
Example #17
Source File: Home.tsx From clarity with Apache License 2.0 | 5 votes |
renderCreateNewVault() {
return (
<div>
<Grid
container
spacing={4}
direction={'column'}
justify={'flex-start'}
alignItems={'center'}
>
<Grid item className={this.props.classes.alignCenter}>
<img src={logo} alt="logo" width={80} />
<Typography variant={'h6'} align={'center'}>
New Vault
</Typography>
<Typography>
Please set a password for your vault. You will need it later to
unlock it so keep it safe.
</Typography>
</Grid>
<Grid item container>
<form style={{ textAlign: 'center' }}>
<FormControl fullWidth>
<TextFieldWithFormState
fieldState={
this.props.homeContainer.homeForm.$.setPasswordField
}
required
label={'Set Password'}
type={'password'}
/>
</FormControl>
<FormControl fullWidth>
<TextFieldWithFormState
fieldState={
this.props.homeContainer.homeForm.$.confirmPasswordField
}
required
label={'Confirm Password'}
type={'password'}
/>
</FormControl>
<Typography variant="subtitle2" className="text-danger">
{this.props.homeContainer.homeForm.showFormError &&
this.props.homeContainer.homeForm.formError}
</Typography>
<FormControl fullWidth className={this.props.classes.margin}>
<Button
variant="contained"
color="primary"
disabled={this.props.homeContainer.createVaultDisabled}
onClick={async () => {
const password = this.props.homeContainer.homeForm.$
.setPasswordField.$;
await this.props.authContainer.createNewVault(password);
this.props.homeContainer.homeForm.$.setPasswordField.reset();
this.props.homeContainer.homeForm.$.confirmPasswordField.reset();
}}
>
Create Vault
</Button>
</FormControl>
</form>
</Grid>
</Grid>
</div>
);
}
Example #18
Source File: CreateRoom.tsx From cards-against-formality-pwa with BSD 2-Clause "Simplified" License | 5 votes |
function DeckSelector({ decks, onChange }: { decks: any[], onChange: (decks: string[]) => void }) {
const [deckOptions, setDeckOptions] = useState<{ name: string; _id: string, value?: boolean }[]>([]);
const [isExpanded, setIsExpanded] = useState(false);
const [isAllSelected, setIsAllSelected] = useState(false);
const toggleSelectAll = useCallback(() => {
setDeckOptions(prevDeck => {
prevDeck.forEach(deck => deck.value = !isAllSelected);
return [...prevDeck];
});
setIsAllSelected(!isAllSelected);
}, [isAllSelected])
useEffect(() => {
if (decks) {
setDeckOptions(decks.map(deck => {
return { value: deck.name.includes('Base'), ...deck }
}));
}
}, [decks]);
useEffect(() => {
onChange(deckOptions.filter(deck => deck.value).map(deck => deck._id));
}, [deckOptions, onChange]);
function _onChange(e: React.ChangeEvent<HTMLInputElement>) {
setDeckOptions(prevDeck => {
const deck = prevDeck.find(deck => deck._id === e.target.name);
if (deck) {
deck.value = e.target.checked;
}
return [...prevDeck];
});
}
if (!decks?.length) {
return null;
}
return <ExpansionPanel expanded={isExpanded} onChange={() => { setIsExpanded(prev => !prev) }}>
<ExpansionPanelSummary
expandIcon={<ExpandMoreIcon />}
aria-controls="panel1bh-content"
id="panel1bh-header"
>
<Typography>Available Decks!</Typography>
</ExpansionPanelSummary>
<ExpansionPanelDetails>
<FormControl required component="fieldset" error={!deckOptions.some(deck => deck.value)}>
<FormControlLabel
control={<Checkbox checked={isAllSelected} onChange={toggleSelectAll} name="Select all" />}
label="Select all"
/>
<Divider />
<FormLabel component="legend">Select which decks you would like to play with</FormLabel>
<FormGroup className="deck-checkbox-group">
{deckOptions.map(deck => {
return <FormControlLabel
key={deck._id}
control={<Checkbox checked={deck.value} onChange={_onChange} name={deck._id} />}
label={deck.name}
/>
})}
</FormGroup>
<FormHelperText>You must select at least one</FormHelperText>
</FormControl>
</ExpansionPanelDetails>
</ExpansionPanel>
}
Example #19
Source File: AdvancedSettings.tsx From lobis-frontend with MIT License | 5 votes |
function AdvancedSettings({ open, handleClose, slippage, recipientAddress, onRecipientAddressChange, onSlippageChange }: IAdvancedSettingsProps) {
return (
<Modal id="hades" open={open} onClose={handleClose} hideBackdrop>
<Paper className="ohm-card ohm-popover">
<div className="cross-wrap">
<IconButton onClick={handleClose}>
<SvgIcon color="primary" component={XIcon} />
</IconButton>
</div>
<Box className="card-content">
<InputLabel htmlFor="slippage">
<p className="input-lable">Slippage</p>
</InputLabel>
<FormControl variant="outlined" color="primary" fullWidth>
<OutlinedInput
id="slippage"
value={slippage}
onChange={onSlippageChange}
fullWidth
type="number"
//@ts-ignore
max="100"
min="100"
className="bond-input"
endAdornment={
<InputAdornment position="end">
<p className="percent">%</p>
</InputAdornment>
}
/>
<div className="help-text">
<p className="text-bond-desc">Transaction may revert if price changes by more than slippage %</p>
</div>
</FormControl>
</Box>
</Paper>
</Modal>
);
}
Example #20
Source File: AdvancedSettings.tsx From rugenerous-frontend with MIT License | 5 votes |
function AdvancedSettings({
open,
handleClose,
slippage,
recipientAddress,
onRecipientAddressChange,
onSlippageChange,
}: IAdvancedSettingsProps) {
const [value, setValue] = useState(slippage);
useEffect(() => {
let timeount: any = null;
clearTimeout(timeount);
timeount = setTimeout(() => onSlippageChange(value), 1000);
return () => clearTimeout(timeount);
}, [value]);
return (
<Modal id="hades" open={open} onClose={handleClose} hideBackdrop>
<Paper className="ohm-card ohm-popover">
<div className="cross-wrap">
<IconButton onClick={handleClose}>
<SvgIcon color="primary" component={XIcon} />
</IconButton>
</div>
<p className="hades-title">Settings</p>
<Box className="card-content">
<InputLabel htmlFor="slippage">
<p className="input-lable">Slippage</p>
</InputLabel>
<FormControl variant="outlined" color="primary" fullWidth>
<OutlinedInput
id="slippage"
value={value}
onChange={(e: any) => setValue(e.target.value)}
fullWidth
type="number"
className="bond-input"
endAdornment={
<InputAdornment position="end">
<p className="percent">%</p>
</InputAdornment>
}
/>
<div className="help-text">
<p className="text-bond-desc">Transaction may revert if price changes by more than slippage %</p>
</div>
</FormControl>
<InputLabel htmlFor="recipient">
<p className="input-lable">Recipient Address</p>
</InputLabel>
<FormControl variant="outlined" color="primary" fullWidth>
<OutlinedInput
className="bond-input"
id="recipient"
value={recipientAddress}
onChange={onRecipientAddressChange}
type="text"
/>
<div className="help-text">
<p className="text-bond-desc">
Choose recipient address. By default, this is your currently connected address
</p>
</div>
</FormControl>
</Box>
</Paper>
</Modal>
);
}
Example #21
Source File: SQFormRadioButtonGroup.tsx From SQForm with MIT License | 5 votes |
function SQFormRadioButtonGroup({
name,
onChange,
shouldDisplayInRow = false,
size = 'auto',
groupLabel,
children,
}: SQFormRadioButtonGroupProps): React.ReactElement {
const {
fieldState: {isFieldError, isFieldRequired},
formikField: {field},
fieldHelpers: {handleChange, handleBlur, HelperTextComponent},
} = useForm<
RadioButtonInputItemProps['value'],
React.ChangeEvent<HTMLInputElement>
>({
name,
onChange,
});
const childrenToRadioGroupItems = () => {
return children.map((radioOption) => {
const {label, value, isDisabled, InputProps} = radioOption;
return (
<SQFormRadioButtonGroupItem
label={label}
value={value}
isDisabled={isDisabled}
isRowDisplay={shouldDisplayInRow}
InputProps={InputProps}
key={`SQFormRadioButtonGroupItem_${value}`}
/>
);
});
};
return (
<Grid item sm={size}>
<FormControl
component="fieldset"
required={isFieldRequired}
error={isFieldError}
onBlur={handleBlur}
>
<FormLabel
component="legend"
classes={{
root: 'MuiInputLabel-root',
asterisk: 'MuiInputLabel-asterisk',
}}
>
{groupLabel}
</FormLabel>
<RadioGroup
value={field.value}
row={shouldDisplayInRow}
aria-label={`SQFormRadioButtonGroup_${name}`}
name={name}
onChange={handleChange}
>
{childrenToRadioGroupItems()}
</RadioGroup>
<FormHelperText>{HelperTextComponent}</FormHelperText>
</FormControl>
</Grid>
);
}
Example #22
Source File: ProjectSelect.tsx From frontend with Apache License 2.0 | 5 votes |
ProjectSelect: FunctionComponent<{
projectId?: string;
onProjectSelect: (id: string) => void;
}> = ({ projectId, onProjectSelect }) => {
const classes = useStyles();
const { projectList, selectedProjectId } = useProjectState();
const projectDispatch = useProjectDispatch();
React.useEffect(() => {
if (projectId && projectId !== selectedProjectId) {
selectProject(projectDispatch, projectId);
}
}, [projectId, selectedProjectId, projectDispatch]);
return (
<React.Fragment>
{projectList.length > 0 && (
<FormControl className={classes.formControl}>
<InputLabel id="projectSelect" shrink>
Project
</InputLabel>
<Select
id="project-select"
labelId="projectSelect"
className={classes.input}
displayEmpty
value={selectedProjectId ?? ""}
onChange={(event) => onProjectSelect(event.target.value as string)}
>
<MenuItem value="" disabled>
<em>Select project</em>
</MenuItem>
{projectList.map((project) => (
<MenuItem key={project.id} value={project.id}>
{project.name}
</MenuItem>
))}
</Select>
</FormControl>
)}
</React.Fragment>
);
}
Example #23
Source File: AdvancedSettings.tsx From wonderland-frontend with MIT License | 5 votes |
function AdvancedSettings({ open, handleClose, slippage, onSlippageChange }: IAdvancedSettingsProps) {
const [value, setValue] = useState(slippage);
useEffect(() => {
let timeount: any = null;
clearTimeout(timeount);
timeount = setTimeout(() => onSlippageChange(value), 1000);
return () => clearTimeout(timeount);
}, [value]);
return (
<Modal id="hades" open={open} onClose={handleClose} hideBackdrop>
<Paper className="ohm-card ohm-popover">
<div className="cross-wrap">
<IconButton onClick={handleClose}>
<SvgIcon color="primary" component={XIcon} />
</IconButton>
</div>
<p className="hades-title">Settings</p>
<Box className="card-content">
<InputLabel htmlFor="slippage">
<p className="input-lable">Slippage</p>
</InputLabel>
<FormControl variant="outlined" color="primary" fullWidth>
<OutlinedInput
id="slippage"
value={value}
onChange={(e: any) => setValue(e.target.value)}
fullWidth
type="number"
className="bond-input"
endAdornment={
<InputAdornment position="end">
<p className="percent">%</p>
</InputAdornment>
}
/>
<div className="help-text">
<p className="text-bond-desc">Transaction may revert if price changes by more than slippage %</p>
</div>
</FormControl>
</Box>
</Paper>
</Modal>
);
}
Example #24
Source File: DepartmentSelector.tsx From graphql-ts-client with MIT License | 5 votes |
DepartmentSelector: FC<{
value?: string,
onChange: (value?: string) => void
}> = memo(({value, onChange}) => {
const [data, setData] = useState<ModelType<typeof DEPARTMENT_LIST_FETCHER>>();
const [error, setError] = useState<Error>();
const [loading, setLoading] = useState(false);
const findDepartments = useCallback(async () => {
setLoading(true);
setData(undefined);
setError(undefined);
try {
const data = await execute(DEPARTMENT_LIST_FETCHER);
setData(data);
} catch (e) {
setError(e);
} finally {
setLoading(false);
}
}, []);
useEffect(() => {
findDepartments();
}, [findDepartments]);
const onSelectChange = useCallback((e: ChangeEvent<{value: any}>) => {
const v = e.target.value;
onChange(v === "" ? undefined : v);
}, [onChange]);
return (
<FormControl fullWidth={true}>
<InputLabel>
Department
{ loading && <CircularProgress size="1rem"/> }
{ error && <span style={{color:"red"}}>Load failed...</span>}
</InputLabel>
<Select
disabled={data === undefined}
error={false}
value={value ?? ""}
onChange={onSelectChange}
fullWidth={true}>
<MenuItem key="Nonde" value="">
<em>Unspecified</em>
</MenuItem>
{
data?.connection?.edges?.map(edge =>
<MenuItem key={edge.node.id} value={edge.node.id}>{edge.node.name}</MenuItem>
)
}
</Select>
</FormControl>
);
})
Example #25
Source File: MaxDepthFilter.tsx From backstage with Apache License 2.0 | 5 votes |
MaxDepthFilter = ({ value, onChange }: Props) => {
const classes = useStyles();
const handleChange = useCallback(
(event: React.ChangeEvent<HTMLInputElement>) => {
const v = Number(event.target.value);
onChange(v <= 0 ? Number.POSITIVE_INFINITY : v);
},
[onChange],
);
const reset = useCallback(() => {
onChange(Number.POSITIVE_INFINITY);
}, [onChange]);
return (
<Box pb={1} pt={1}>
<FormControl variant="outlined" className={classes.formControl}>
<Typography variant="button">Max Depth</Typography>
<OutlinedInput
type="number"
placeholder="∞ Infinite"
value={isFinite(value) ? value : ''}
onChange={handleChange}
endAdornment={
<InputAdornment position="end">
<IconButton
aria-label="clear max depth"
onClick={reset}
edge="end"
>
<ClearIcon />
</IconButton>
</InputAdornment>
}
inputProps={{
'aria-label': 'maxp',
}}
labelWidth={0}
/>
</FormControl>
</Box>
);
}
Example #26
Source File: AccountPage.tsx From signer with Apache License 2.0 | 5 votes |
renderImportForm() {
const form = this.accountForm as ImportAccountFormData;
return (
<form className={this.props.classes.root}>
<Typography id="continuous-slider" variant="h6" gutterBottom>
Import from Secret Key File
</Typography>
<FormControl>
<Box
display={'flex'}
flexDirection={'row'}
alignItems={'center'}
m={1}
>
<Button
id={'private-key-uploader'}
variant="contained"
style={{
backgroundColor: 'var(--cspr-dark-blue)',
color: 'white'
}}
component="label"
>
Upload
<input
type="file"
style={{ display: 'none' }}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
form.handleFileSelect(e)
}
/>
</Button>
<Box ml={1}>
<Typography component={'span'}>
<Box fontSize={12}>
{form.file ? form.file.name : 'No file selected'}
</Box>
</Typography>
</Box>
</Box>
</FormControl>
<TextFieldWithFormState
fullWidth
label="Name imported account"
placeholder="Human Readable Alias"
id="import-name"
fieldState={this.accountForm.name}
/>
<FormControl fullWidth className={this.props.classes.importButton}>
<Button
type="submit"
disabled={this.accountForm.submitDisabled}
color="primary"
variant={'contained'}
onClick={() => {
this.onImportAccount();
}}
>
Import
</Button>
</FormControl>
</form>
);
}
Example #27
Source File: SortBar.tsx From crossfeed with Creative Commons Zero v1.0 Universal | 5 votes |
SortBar: React.FC<Props> = (props) => {
const {
sortField,
sortDirection,
setSort,
saveSearch,
children,
existingSavedSearch
} = props;
const classes = useStyles(props);
const toggleDirection = () => {
setSort(sortField, sortDirection === 'asc' ? 'desc' : 'asc');
};
const onSetSortField: SelectProps['onChange'] = (e) => {
setSort(e.target.value as string, 'asc');
};
return (
<div className={classes.root}>
<div className={classes.sortMenu}>
<button className={classes.toggleDirection} onClick={toggleDirection}>
{!sortDirection || sortDirection === 'desc' ? (
<ArrowDownward />
) : (
<ArrowUpward />
)}
</button>
<span id="sort-by-label">Sort by: </span>
<FormControl className={classes.openFields}>
<Select
disableUnderline
labelId="sort-by-label"
value={sortField}
onChange={onSetSortField}
classes={{ root: classes.selectInp }}
>
<MenuItem classes={{ root: classes.option }} value="name">
Domain Name
</MenuItem>
<MenuItem classes={{ root: classes.option }} value="ip">
IP
</MenuItem>
<MenuItem classes={{ root: classes.option }} value="updatedAt">
Last Seen
</MenuItem>
<MenuItem classes={{ root: classes.option }} value="createdAt">
First Seen
</MenuItem>
</Select>
</FormControl>
</div>
{children}
<div>
{saveSearch && (
<button onClick={saveSearch}>
{existingSavedSearch ? 'Update Saved Search' : 'Save Search'}
</button>
)}
</div>
</div>
);
}
Example #28
Source File: DropdownTab.tsx From clearflask with Apache License 2.0 | 5 votes |
render() {
var anySelected = false;
const items = this.props.links.map(link => {
if (this.props.selectedValue === link.val) anySelected = true;
return (
<MenuItem
component={Link as any}
to={link.val}
key={link.name + link.val}
value={link.val}
>
{link.icon && (<DynamicMuiIcon name={link.icon} />)}
{link.name}
</MenuItem>
);
});
const id = `dropdowntab-${this.props.key}`;
return (
<div className={this.props.classes.outer}>
<FormControl className={this.props.classes.inner}>
<Select
className={this.props.classes.select}
classes={{
icon: this.props.classes.selectIcon
}}
value={anySelected ? this.props.selectedValue : '__NOT_SELECTED__'}
key={this.props.key}
onChange={e => this.props.onDropdownTabSelect(e.target.value as string)}
inputProps={{
className: classNames(
this.props.classes.tabButton,
anySelected && this.props.classes.tabButtonSelected,
this.props.className
),
id: id,
}}
displayEmpty
MenuProps={{
anchorOrigin: {
vertical: 'bottom',
horizontal: 'center',
},
transformOrigin: {
vertical: 'top',
horizontal: 'center',
},
anchorReference: 'anchorEl',
}}
>
{this.props.label && (<MenuItem style={{ display: 'none' }} divider disabled value='__NOT_SELECTED__'>
{this.props.icon}
{this.props.label}
</MenuItem>)}
{items}
</Select>
</FormControl>
</div>
);
}
Example #29
Source File: index.tsx From back-home-safe with GNU General Public License v3.0 | 5 votes |
StyledFormControl = styled(FormControl)`
width: 100%;
&.MuiFormControl-root {
margin: 8px;
}
`