MCPcopy
hub / github.com/marmelab/react-admin / SelectInput

Function SelectInput

packages/ra-ui-materialui/src/input/SelectInput.tsx:112–361  ·  view source on GitHub ↗
(inProps: SelectInputProps)

Source from the content-addressed store, hash-verified

110 *
111 */
112export const SelectInput = (inProps: SelectInputProps) => {
113 const props = useThemeProps({
114 props: inProps,
115 name: PREFIX,
116 });
117 const {
118 choices: choicesProp,
119 className,
120 create,
121 createLabel,
122 createValue,
123 createHintValue,
124 defaultValue,
125 disableValue = 'disabled',
126 emptyText = '',
127 emptyValue = '',
128 format,
129 filter,
130 helperText,
131 isFetching: isFetchingProp,
132 isLoading: isLoadingProp,
133 isPending: isPendingProp,
134 label,
135 margin = 'dense',
136 onBlur,
137 onChange,
138 onCreate,
139 optionText,
140 optionValue,
141 parse,
142 resource: resourceProp,
143 source: sourceProp,
144 translateChoice,
145 validate,
146 ...rest
147 } = props;
148 const translate = useTranslate();
149
150 useEffect(() => {
151 if (emptyValue == null) {
152 throw new Error(
153 `emptyValue being set to null or undefined is not supported. Use parse to turn the empty string into null.`
154 );
155 }
156 }, [emptyValue]);
157
158 const {
159 allChoices,
160 isPending,
161 error: fetchError,
162 source,
163 resource,
164 isFromReference,
165 } = useChoicesContext({
166 choices: choicesProp,
167 isLoading: isLoadingProp,
168 isFetching: isFetchingProp,
169 isPending: isPendingProp,

Callers

nothing calls this directly

Calls 8

useTranslateFunction · 0.90
useChoicesContextFunction · 0.90
useChoicesFunction · 0.90
useInputFunction · 0.90
translateFunction · 0.85
sanitizeRestPropsFunction · 0.70

Tested by

no test coverage detected