UNPKG

33 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
4
5var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
6
7Object.defineProperty(exports, "__esModule", {
8 value: true
9});
10Object.defineProperty(exports, "createFilterOptions", {
11 enumerable: true,
12 get: function get() {
13 return _useAutocomplete2.createFilterOptions;
14 }
15});
16exports.default = exports.styles = void 0;
17
18var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
19
20var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
21
22var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
23
24var React = _interopRequireWildcard(require("react"));
25
26var _propTypes = _interopRequireDefault(require("prop-types"));
27
28var _clsx = _interopRequireDefault(require("clsx"));
29
30var _styles = require("@material-ui/core/styles");
31
32var _Popper = _interopRequireDefault(require("@material-ui/core/Popper"));
33
34var _ListSubheader = _interopRequireDefault(require("@material-ui/core/ListSubheader"));
35
36var _Paper = _interopRequireDefault(require("@material-ui/core/Paper"));
37
38var _IconButton = _interopRequireDefault(require("@material-ui/core/IconButton"));
39
40var _Chip = _interopRequireDefault(require("@material-ui/core/Chip"));
41
42var _Close = _interopRequireDefault(require("../internal/svg-icons/Close"));
43
44var _ArrowDropDown = _interopRequireDefault(require("../internal/svg-icons/ArrowDropDown"));
45
46var _useAutocomplete2 = _interopRequireWildcard(require("../useAutocomplete"));
47
48var styles = function styles(theme) {
49 var _option;
50
51 return {
52 /* Styles applied to the root element. */
53 root: {
54 '&$focused $clearIndicatorDirty': {
55 visibility: 'visible'
56 },
57
58 /* Avoid double tap issue on iOS */
59 '@media (pointer: fine)': {
60 '&:hover $clearIndicatorDirty': {
61 visibility: 'visible'
62 }
63 }
64 },
65
66 /* Styles applied to the root element if `fullWidth={true}`. */
67 fullWidth: {
68 width: '100%'
69 },
70
71 /* Pseudo-class applied to the root element if focused. */
72 focused: {},
73
74 /* Styles applied to the tag elements, e.g. the chips. */
75 tag: {
76 margin: 3,
77 maxWidth: 'calc(100% - 6px)'
78 },
79
80 /* Styles applied to the tag elements, e.g. the chips if `size="small"`. */
81 tagSizeSmall: {
82 margin: 2,
83 maxWidth: 'calc(100% - 4px)'
84 },
85
86 /* Styles applied when the popup icon is rendered. */
87 hasPopupIcon: {},
88
89 /* Styles applied when the clear icon is rendered. */
90 hasClearIcon: {},
91
92 /* Styles applied to the Input element. */
93 inputRoot: {
94 flexWrap: 'wrap',
95 '$hasPopupIcon &, $hasClearIcon &': {
96 paddingRight: 26 + 4
97 },
98 '$hasPopupIcon$hasClearIcon &': {
99 paddingRight: 52 + 4
100 },
101 '& $input': {
102 width: 0,
103 minWidth: 30
104 },
105 '&[class*="MuiInput-root"]': {
106 paddingBottom: 1,
107 '& $input': {
108 padding: 4
109 },
110 '& $input:first-child': {
111 padding: '6px 0'
112 }
113 },
114 '&[class*="MuiInput-root"][class*="MuiInput-marginDense"]': {
115 '& $input': {
116 padding: '4px 4px 5px'
117 },
118 '& $input:first-child': {
119 padding: '3px 0 6px'
120 }
121 },
122 '&[class*="MuiOutlinedInput-root"]': {
123 padding: 9,
124 '$hasPopupIcon &, $hasClearIcon &': {
125 paddingRight: 26 + 4 + 9
126 },
127 '$hasPopupIcon$hasClearIcon &': {
128 paddingRight: 52 + 4 + 9
129 },
130 '& $input': {
131 padding: '9.5px 4px'
132 },
133 '& $input:first-child': {
134 paddingLeft: 6
135 },
136 '& $endAdornment': {
137 right: 9
138 }
139 },
140 '&[class*="MuiOutlinedInput-root"][class*="MuiOutlinedInput-marginDense"]': {
141 padding: 6,
142 '& $input': {
143 padding: '4.5px 4px'
144 }
145 },
146 '&[class*="MuiFilledInput-root"]': {
147 paddingTop: 19,
148 paddingLeft: 8,
149 '$hasPopupIcon &, $hasClearIcon &': {
150 paddingRight: 26 + 4 + 9
151 },
152 '$hasPopupIcon$hasClearIcon &': {
153 paddingRight: 52 + 4 + 9
154 },
155 '& $input': {
156 padding: '9px 4px'
157 },
158 '& $endAdornment': {
159 right: 9
160 }
161 },
162 '&[class*="MuiFilledInput-root"][class*="MuiFilledInput-marginDense"]': {
163 paddingBottom: 1,
164 '& $input': {
165 padding: '4.5px 4px'
166 }
167 }
168 },
169
170 /* Styles applied to the input element. */
171 input: {
172 flexGrow: 1,
173 textOverflow: 'ellipsis',
174 opacity: 0
175 },
176
177 /* Styles applied to the input element if tag focused. */
178 inputFocused: {
179 opacity: 1
180 },
181
182 /* Styles applied to the endAdornment element. */
183 endAdornment: {
184 // We use a position absolute to support wrapping tags.
185 position: 'absolute',
186 right: 0,
187 top: 'calc(50% - 14px)' // Center vertically
188
189 },
190
191 /* Styles applied to the clear indicator. */
192 clearIndicator: {
193 marginRight: -2,
194 padding: 4,
195 visibility: 'hidden'
196 },
197
198 /* Styles applied to the clear indicator if the input is dirty. */
199 clearIndicatorDirty: {},
200
201 /* Styles applied to the popup indicator. */
202 popupIndicator: {
203 padding: 2,
204 marginRight: -2
205 },
206
207 /* Styles applied to the popup indicator if the popup is open. */
208 popupIndicatorOpen: {
209 transform: 'rotate(180deg)'
210 },
211
212 /* Styles applied to the popper element. */
213 popper: {
214 zIndex: theme.zIndex.modal
215 },
216
217 /* Styles applied to the popper element if `disablePortal={true}`. */
218 popperDisablePortal: {
219 position: 'absolute'
220 },
221
222 /* Styles applied to the `Paper` component. */
223 paper: (0, _extends2.default)({}, theme.typography.body1, {
224 overflow: 'hidden',
225 margin: '4px 0'
226 }),
227
228 /* Styles applied to the `listbox` component. */
229 listbox: {
230 listStyle: 'none',
231 margin: 0,
232 padding: '8px 0',
233 maxHeight: '40vh',
234 overflow: 'auto'
235 },
236
237 /* Styles applied to the loading wrapper. */
238 loading: {
239 color: theme.palette.text.secondary,
240 padding: '14px 16px'
241 },
242
243 /* Styles applied to the no option wrapper. */
244 noOptions: {
245 color: theme.palette.text.secondary,
246 padding: '14px 16px'
247 },
248
249 /* Styles applied to the option elements. */
250 option: (_option = {
251 minHeight: 48,
252 display: 'flex',
253 justifyContent: 'flex-start',
254 alignItems: 'center',
255 cursor: 'pointer',
256 paddingTop: 6,
257 boxSizing: 'border-box',
258 outline: '0',
259 WebkitTapHighlightColor: 'transparent',
260 paddingBottom: 6,
261 paddingLeft: 16,
262 paddingRight: 16
263 }, (0, _defineProperty2.default)(_option, theme.breakpoints.up('sm'), {
264 minHeight: 'auto'
265 }), (0, _defineProperty2.default)(_option, '&[aria-selected="true"]', {
266 backgroundColor: theme.palette.action.selected
267 }), (0, _defineProperty2.default)(_option, '&[data-focus="true"]', {
268 backgroundColor: theme.palette.action.hover
269 }), (0, _defineProperty2.default)(_option, '&:active', {
270 backgroundColor: theme.palette.action.selected
271 }), (0, _defineProperty2.default)(_option, '&[aria-disabled="true"]', {
272 opacity: theme.palette.action.disabledOpacity,
273 pointerEvents: 'none'
274 }), _option),
275
276 /* Styles applied to the group's label elements. */
277 groupLabel: {
278 backgroundColor: theme.palette.background.paper,
279 top: -8
280 },
281
282 /* Styles applied to the group's ul elements. */
283 groupUl: {
284 padding: 0,
285 '& $option': {
286 paddingLeft: 24
287 }
288 }
289 };
290};
291
292exports.styles = styles;
293
294function DisablePortal(props) {
295 // eslint-disable-next-line react/prop-types
296 var anchorEl = props.anchorEl,
297 open = props.open,
298 other = (0, _objectWithoutProperties2.default)(props, ["anchorEl", "open"]);
299 return /*#__PURE__*/React.createElement("div", other);
300}
301
302var _ref = /*#__PURE__*/React.createElement(_Close.default, {
303 fontSize: "small"
304});
305
306var _ref2 = /*#__PURE__*/React.createElement(_ArrowDropDown.default, null);
307
308var Autocomplete = /*#__PURE__*/React.forwardRef(function Autocomplete(props, ref) {
309 /* eslint-disable no-unused-vars */
310 var _props$autoComplete = props.autoComplete,
311 autoComplete = _props$autoComplete === void 0 ? false : _props$autoComplete,
312 _props$autoHighlight = props.autoHighlight,
313 autoHighlight = _props$autoHighlight === void 0 ? false : _props$autoHighlight,
314 _props$autoSelect = props.autoSelect,
315 autoSelect = _props$autoSelect === void 0 ? false : _props$autoSelect,
316 _props$blurOnSelect = props.blurOnSelect,
317 blurOnSelect = _props$blurOnSelect === void 0 ? false : _props$blurOnSelect,
318 ChipProps = props.ChipProps,
319 classes = props.classes,
320 className = props.className,
321 _props$clearOnBlur = props.clearOnBlur,
322 clearOnBlur = _props$clearOnBlur === void 0 ? !props.freeSolo : _props$clearOnBlur,
323 _props$clearOnEscape = props.clearOnEscape,
324 clearOnEscape = _props$clearOnEscape === void 0 ? false : _props$clearOnEscape,
325 _props$clearText = props.clearText,
326 clearText = _props$clearText === void 0 ? 'Clear' : _props$clearText,
327 _props$closeIcon = props.closeIcon,
328 closeIcon = _props$closeIcon === void 0 ? _ref : _props$closeIcon,
329 _props$closeText = props.closeText,
330 closeText = _props$closeText === void 0 ? 'Close' : _props$closeText,
331 _props$debug = props.debug,
332 debug = _props$debug === void 0 ? false : _props$debug,
333 _props$defaultValue = props.defaultValue,
334 defaultValue = _props$defaultValue === void 0 ? props.multiple ? [] : null : _props$defaultValue,
335 _props$disableClearab = props.disableClearable,
336 disableClearable = _props$disableClearab === void 0 ? false : _props$disableClearab,
337 _props$disableCloseOn = props.disableCloseOnSelect,
338 disableCloseOnSelect = _props$disableCloseOn === void 0 ? false : _props$disableCloseOn,
339 _props$disabled = props.disabled,
340 disabled = _props$disabled === void 0 ? false : _props$disabled,
341 _props$disabledItemsF = props.disabledItemsFocusable,
342 disabledItemsFocusable = _props$disabledItemsF === void 0 ? false : _props$disabledItemsF,
343 _props$disableListWra = props.disableListWrap,
344 disableListWrap = _props$disableListWra === void 0 ? false : _props$disableListWra,
345 _props$disablePortal = props.disablePortal,
346 disablePortal = _props$disablePortal === void 0 ? false : _props$disablePortal,
347 filterOptions = props.filterOptions,
348 _props$filterSelected = props.filterSelectedOptions,
349 filterSelectedOptions = _props$filterSelected === void 0 ? false : _props$filterSelected,
350 _props$forcePopupIcon = props.forcePopupIcon,
351 forcePopupIcon = _props$forcePopupIcon === void 0 ? 'auto' : _props$forcePopupIcon,
352 _props$freeSolo = props.freeSolo,
353 freeSolo = _props$freeSolo === void 0 ? false : _props$freeSolo,
354 _props$fullWidth = props.fullWidth,
355 fullWidth = _props$fullWidth === void 0 ? false : _props$fullWidth,
356 _props$getLimitTagsTe = props.getLimitTagsText,
357 getLimitTagsText = _props$getLimitTagsTe === void 0 ? function (more) {
358 return "+".concat(more);
359 } : _props$getLimitTagsTe,
360 getOptionDisabled = props.getOptionDisabled,
361 _props$getOptionLabel = props.getOptionLabel,
362 getOptionLabel = _props$getOptionLabel === void 0 ? function (x) {
363 return x;
364 } : _props$getOptionLabel,
365 getOptionSelected = props.getOptionSelected,
366 groupBy = props.groupBy,
367 _props$handleHomeEndK = props.handleHomeEndKeys,
368 handleHomeEndKeys = _props$handleHomeEndK === void 0 ? !props.freeSolo : _props$handleHomeEndK,
369 idProp = props.id,
370 _props$includeInputIn = props.includeInputInList,
371 includeInputInList = _props$includeInputIn === void 0 ? false : _props$includeInputIn,
372 inputValueProp = props.inputValue,
373 _props$limitTags = props.limitTags,
374 limitTags = _props$limitTags === void 0 ? -1 : _props$limitTags,
375 _props$ListboxCompone = props.ListboxComponent,
376 ListboxComponent = _props$ListboxCompone === void 0 ? 'ul' : _props$ListboxCompone,
377 ListboxProps = props.ListboxProps,
378 _props$loading = props.loading,
379 loading = _props$loading === void 0 ? false : _props$loading,
380 _props$loadingText = props.loadingText,
381 loadingText = _props$loadingText === void 0 ? 'Loading…' : _props$loadingText,
382 _props$multiple = props.multiple,
383 multiple = _props$multiple === void 0 ? false : _props$multiple,
384 _props$noOptionsText = props.noOptionsText,
385 noOptionsText = _props$noOptionsText === void 0 ? 'No options' : _props$noOptionsText,
386 onChange = props.onChange,
387 onClose = props.onClose,
388 onHighlightChange = props.onHighlightChange,
389 onInputChange = props.onInputChange,
390 onOpen = props.onOpen,
391 open = props.open,
392 _props$openOnFocus = props.openOnFocus,
393 openOnFocus = _props$openOnFocus === void 0 ? false : _props$openOnFocus,
394 _props$openText = props.openText,
395 openText = _props$openText === void 0 ? 'Open' : _props$openText,
396 options = props.options,
397 _props$PaperComponent = props.PaperComponent,
398 PaperComponent = _props$PaperComponent === void 0 ? _Paper.default : _props$PaperComponent,
399 _props$PopperComponen = props.PopperComponent,
400 PopperComponentProp = _props$PopperComponen === void 0 ? _Popper.default : _props$PopperComponen,
401 _props$popupIcon = props.popupIcon,
402 popupIcon = _props$popupIcon === void 0 ? _ref2 : _props$popupIcon,
403 renderGroupProp = props.renderGroup,
404 renderInput = props.renderInput,
405 renderOptionProp = props.renderOption,
406 renderTags = props.renderTags,
407 _props$selectOnFocus = props.selectOnFocus,
408 selectOnFocus = _props$selectOnFocus === void 0 ? !props.freeSolo : _props$selectOnFocus,
409 _props$size = props.size,
410 size = _props$size === void 0 ? 'medium' : _props$size,
411 valueProp = props.value,
412 other = (0, _objectWithoutProperties2.default)(props, ["autoComplete", "autoHighlight", "autoSelect", "blurOnSelect", "ChipProps", "classes", "className", "clearOnBlur", "clearOnEscape", "clearText", "closeIcon", "closeText", "debug", "defaultValue", "disableClearable", "disableCloseOnSelect", "disabled", "disabledItemsFocusable", "disableListWrap", "disablePortal", "filterOptions", "filterSelectedOptions", "forcePopupIcon", "freeSolo", "fullWidth", "getLimitTagsText", "getOptionDisabled", "getOptionLabel", "getOptionSelected", "groupBy", "handleHomeEndKeys", "id", "includeInputInList", "inputValue", "limitTags", "ListboxComponent", "ListboxProps", "loading", "loadingText", "multiple", "noOptionsText", "onChange", "onClose", "onHighlightChange", "onInputChange", "onOpen", "open", "openOnFocus", "openText", "options", "PaperComponent", "PopperComponent", "popupIcon", "renderGroup", "renderInput", "renderOption", "renderTags", "selectOnFocus", "size", "value"]);
413 /* eslint-enable no-unused-vars */
414
415 var PopperComponent = disablePortal ? DisablePortal : PopperComponentProp;
416
417 var _useAutocomplete = (0, _useAutocomplete2.default)((0, _extends2.default)({}, props, {
418 componentName: 'Autocomplete'
419 })),
420 getRootProps = _useAutocomplete.getRootProps,
421 getInputProps = _useAutocomplete.getInputProps,
422 getInputLabelProps = _useAutocomplete.getInputLabelProps,
423 getPopupIndicatorProps = _useAutocomplete.getPopupIndicatorProps,
424 getClearProps = _useAutocomplete.getClearProps,
425 getTagProps = _useAutocomplete.getTagProps,
426 getListboxProps = _useAutocomplete.getListboxProps,
427 getOptionProps = _useAutocomplete.getOptionProps,
428 value = _useAutocomplete.value,
429 dirty = _useAutocomplete.dirty,
430 id = _useAutocomplete.id,
431 popupOpen = _useAutocomplete.popupOpen,
432 focused = _useAutocomplete.focused,
433 focusedTag = _useAutocomplete.focusedTag,
434 anchorEl = _useAutocomplete.anchorEl,
435 setAnchorEl = _useAutocomplete.setAnchorEl,
436 inputValue = _useAutocomplete.inputValue,
437 groupedOptions = _useAutocomplete.groupedOptions;
438
439 var startAdornment;
440
441 if (multiple && value.length > 0) {
442 var getCustomizedTagProps = function getCustomizedTagProps(params) {
443 return (0, _extends2.default)({
444 className: (0, _clsx.default)(classes.tag, size === 'small' && classes.tagSizeSmall),
445 disabled: disabled
446 }, getTagProps(params));
447 };
448
449 if (renderTags) {
450 startAdornment = renderTags(value, getCustomizedTagProps);
451 } else {
452 startAdornment = value.map(function (option, index) {
453 return /*#__PURE__*/React.createElement(_Chip.default, (0, _extends2.default)({
454 label: getOptionLabel(option),
455 size: size
456 }, getCustomizedTagProps({
457 index: index
458 }), ChipProps));
459 });
460 }
461 }
462
463 if (limitTags > -1 && Array.isArray(startAdornment)) {
464 var more = startAdornment.length - limitTags;
465
466 if (!focused && more > 0) {
467 startAdornment = startAdornment.splice(0, limitTags);
468 startAdornment.push( /*#__PURE__*/React.createElement("span", {
469 className: classes.tag,
470 key: startAdornment.length
471 }, getLimitTagsText(more)));
472 }
473 }
474
475 var defaultRenderGroup = function defaultRenderGroup(params) {
476 return /*#__PURE__*/React.createElement("li", {
477 key: params.key
478 }, /*#__PURE__*/React.createElement(_ListSubheader.default, {
479 className: classes.groupLabel,
480 component: "div"
481 }, params.group), /*#__PURE__*/React.createElement("ul", {
482 className: classes.groupUl
483 }, params.children));
484 };
485
486 var renderGroup = renderGroupProp || defaultRenderGroup;
487 var renderOption = renderOptionProp || getOptionLabel;
488
489 var renderListOption = function renderListOption(option, index) {
490 var optionProps = getOptionProps({
491 option: option,
492 index: index
493 });
494 return /*#__PURE__*/React.createElement("li", (0, _extends2.default)({}, optionProps, {
495 className: classes.option
496 }), renderOption(option, {
497 selected: optionProps['aria-selected'],
498 inputValue: inputValue
499 }));
500 };
501
502 var hasClearIcon = !disableClearable && !disabled;
503 var hasPopupIcon = (!freeSolo || forcePopupIcon === true) && forcePopupIcon !== false;
504 return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", (0, _extends2.default)({
505 ref: ref,
506 className: (0, _clsx.default)(classes.root, className, focused && classes.focused, fullWidth && classes.fullWidth, hasClearIcon && classes.hasClearIcon, hasPopupIcon && classes.hasPopupIcon)
507 }, getRootProps(other)), renderInput({
508 id: id,
509 disabled: disabled,
510 fullWidth: true,
511 size: size === 'small' ? 'small' : undefined,
512 InputLabelProps: getInputLabelProps(),
513 InputProps: {
514 ref: setAnchorEl,
515 className: classes.inputRoot,
516 startAdornment: startAdornment,
517 endAdornment: /*#__PURE__*/React.createElement("div", {
518 className: classes.endAdornment
519 }, hasClearIcon ? /*#__PURE__*/React.createElement(_IconButton.default, (0, _extends2.default)({}, getClearProps(), {
520 "aria-label": clearText,
521 title: clearText,
522 className: (0, _clsx.default)(classes.clearIndicator, dirty && classes.clearIndicatorDirty)
523 }), closeIcon) : null, hasPopupIcon ? /*#__PURE__*/React.createElement(_IconButton.default, (0, _extends2.default)({}, getPopupIndicatorProps(), {
524 disabled: disabled,
525 "aria-label": popupOpen ? closeText : openText,
526 title: popupOpen ? closeText : openText,
527 className: (0, _clsx.default)(classes.popupIndicator, popupOpen && classes.popupIndicatorOpen)
528 }), popupIcon) : null)
529 },
530 inputProps: (0, _extends2.default)({
531 className: (0, _clsx.default)(classes.input, focusedTag === -1 && classes.inputFocused),
532 disabled: disabled
533 }, getInputProps())
534 })), popupOpen && anchorEl ? /*#__PURE__*/React.createElement(PopperComponent, {
535 className: (0, _clsx.default)(classes.popper, disablePortal && classes.popperDisablePortal),
536 style: {
537 width: anchorEl ? anchorEl.clientWidth : null
538 },
539 role: "presentation",
540 anchorEl: anchorEl,
541 open: true
542 }, /*#__PURE__*/React.createElement(PaperComponent, {
543 className: classes.paper
544 }, loading && groupedOptions.length === 0 ? /*#__PURE__*/React.createElement("div", {
545 className: classes.loading
546 }, loadingText) : null, groupedOptions.length === 0 && !freeSolo && !loading ? /*#__PURE__*/React.createElement("div", {
547 className: classes.noOptions
548 }, noOptionsText) : null, groupedOptions.length > 0 ? /*#__PURE__*/React.createElement(ListboxComponent, (0, _extends2.default)({
549 className: classes.listbox
550 }, getListboxProps(), ListboxProps), groupedOptions.map(function (option, index) {
551 if (groupBy) {
552 return renderGroup({
553 key: option.key,
554 group: option.group,
555 children: option.options.map(function (option2, index2) {
556 return renderListOption(option2, option.index + index2);
557 })
558 });
559 }
560
561 return renderListOption(option, index);
562 })) : null)) : null);
563});
564process.env.NODE_ENV !== "production" ? Autocomplete.propTypes = {
565 // ----------------------------- Warning --------------------------------
566 // | These PropTypes are generated from the TypeScript type definitions |
567 // | To update them edit the d.ts file and run "yarn proptypes" |
568 // ----------------------------------------------------------------------
569
570 /**
571 * If `true`, the portion of the selected suggestion that has not been typed by the user,
572 * known as the completion string, appears inline after the input cursor in the textbox.
573 * The inline completion string is visually highlighted and has a selected state.
574 */
575 autoComplete: _propTypes.default.bool,
576
577 /**
578 * If `true`, the first option is automatically highlighted.
579 */
580 autoHighlight: _propTypes.default.bool,
581
582 /**
583 * If `true`, the selected option becomes the value of the input
584 * when the Autocomplete loses focus unless the user chooses
585 * a different option or changes the character string in the input.
586 */
587 autoSelect: _propTypes.default.bool,
588
589 /**
590 * Control if the input should be blurred when an option is selected:
591 *
592 * - `false` the input is not blurred.
593 * - `true` the input is always blurred.
594 * - `touch` the input is blurred after a touch event.
595 * - `mouse` the input is blurred after a mouse event.
596 */
597 blurOnSelect: _propTypes.default.oneOfType([_propTypes.default.oneOf(['mouse', 'touch']), _propTypes.default.bool]),
598
599 /**
600 * Props applied to the [`Chip`](/api/chip/) element.
601 */
602 ChipProps: _propTypes.default.object,
603
604 /**
605 * Override or extend the styles applied to the component.
606 * See [CSS API](#css) below for more details.
607 */
608 classes: _propTypes.default.object,
609
610 /**
611 * @ignore
612 */
613 className: _propTypes.default.string,
614
615 /**
616 * If `true`, the input's text will be cleared on blur if no value is selected.
617 *
618 * Set to `true` if you want to help the user enter a new value.
619 * Set to `false` if you want to help the user resume his search.
620 */
621 clearOnBlur: _propTypes.default.bool,
622
623 /**
624 * If `true`, clear all values when the user presses escape and the popup is closed.
625 */
626 clearOnEscape: _propTypes.default.bool,
627
628 /**
629 * Override the default text for the *clear* icon button.
630 *
631 * For localization purposes, you can use the provided [translations](/guides/localization/).
632 */
633 clearText: _propTypes.default.string,
634
635 /**
636 * The icon to display in place of the default close icon.
637 */
638 closeIcon: _propTypes.default.node,
639
640 /**
641 * Override the default text for the *close popup* icon button.
642 *
643 * For localization purposes, you can use the provided [translations](/guides/localization/).
644 */
645 closeText: _propTypes.default.string,
646
647 /**
648 * If `true`, the popup will ignore the blur event if the input is filled.
649 * You can inspect the popup markup with your browser tools.
650 * Consider this option when you need to customize the component.
651 */
652 debug: _propTypes.default.bool,
653
654 /**
655 * The default input value. Use when the component is not controlled.
656 */
657 defaultValue: _propTypes.default.any,
658
659 /**
660 * If `true`, the input can't be cleared.
661 */
662 disableClearable: _propTypes.default
663 /* @typescript-to-proptypes-ignore */
664 .bool,
665
666 /**
667 * If `true`, the popup won't close when a value is selected.
668 */
669 disableCloseOnSelect: _propTypes.default.bool,
670
671 /**
672 * If `true`, the input will be disabled.
673 */
674 disabled: _propTypes.default.bool,
675
676 /**
677 * If `true`, will allow focus on disabled items.
678 */
679 disabledItemsFocusable: _propTypes.default.bool,
680
681 /**
682 * If `true`, the list box in the popup will not wrap focus.
683 */
684 disableListWrap: _propTypes.default.bool,
685
686 /**
687 * Disable the portal behavior.
688 * The children stay within it's parent DOM hierarchy.
689 */
690 disablePortal: _propTypes.default.bool,
691
692 /**
693 * A filter function that determines the options that are eligible.
694 *
695 * @param {T[]} options The options to render.
696 * @param {object} state The state of the component.
697 * @returns {T[]}
698 */
699 filterOptions: _propTypes.default.func,
700
701 /**
702 * If `true`, hide the selected options from the list box.
703 */
704 filterSelectedOptions: _propTypes.default.bool,
705
706 /**
707 * Force the visibility display of the popup icon.
708 */
709 forcePopupIcon: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.bool]),
710
711 /**
712 * If `true`, the Autocomplete is free solo, meaning that the user input is not bound to provided options.
713 */
714 freeSolo: _propTypes.default
715 /* @typescript-to-proptypes-ignore */
716 .bool,
717
718 /**
719 * If `true`, the input will take up the full width of its container.
720 */
721 fullWidth: _propTypes.default.bool,
722
723 /**
724 * The label to display when the tags are truncated (`limitTags`).
725 *
726 * @param {number} more The number of truncated tags.
727 * @returns {ReactNode}
728 */
729 getLimitTagsText: _propTypes.default.func,
730
731 /**
732 * Used to determine the disabled state for a given option.
733 *
734 * @param {T} option The option to test.
735 * @returns {boolean}
736 */
737 getOptionDisabled: _propTypes.default.func,
738
739 /**
740 * Used to determine the string value for a given option.
741 * It's used to fill the input (and the list box options if `renderOption` is not provided).
742 *
743 * @param {T} option
744 * @returns {string}
745 */
746 getOptionLabel: _propTypes.default.func,
747
748 /**
749 * Used to determine if an option is selected, considering the current value.
750 * Uses strict equality by default.
751 *
752 * @param {T} option The option to test.
753 * @param {T} value The value to test against.
754 * @returns {boolean}
755 */
756 getOptionSelected: _propTypes.default.func,
757
758 /**
759 * If provided, the options will be grouped under the returned string.
760 * The groupBy value is also used as the text for group headings when `renderGroup` is not provided.
761 *
762 * @param {T} options The options to group.
763 * @returns {string}
764 */
765 groupBy: _propTypes.default.func,
766
767 /**
768 * If `true`, the component handles the "Home" and "End" keys when the popup is open.
769 * It should move focus to the first option and last option, respectively.
770 */
771 handleHomeEndKeys: _propTypes.default.bool,
772
773 /**
774 * This prop is used to help implement the accessibility logic.
775 * If you don't provide this prop. It falls back to a randomly generated id.
776 */
777 id: _propTypes.default.string,
778
779 /**
780 * If `true`, the highlight can move to the input.
781 */
782 includeInputInList: _propTypes.default.bool,
783
784 /**
785 * The input value.
786 */
787 inputValue: _propTypes.default.string,
788
789 /**
790 * The maximum number of tags that will be visible when not focused.
791 * Set `-1` to disable the limit.
792 */
793 limitTags: _propTypes.default.number,
794
795 /**
796 * The component used to render the listbox.
797 */
798 ListboxComponent: _propTypes.default.elementType,
799
800 /**
801 * Props applied to the Listbox element.
802 */
803 ListboxProps: _propTypes.default.object,
804
805 /**
806 * If `true`, the component is in a loading state.
807 */
808 loading: _propTypes.default.bool,
809
810 /**
811 * Text to display when in a loading state.
812 *
813 * For localization purposes, you can use the provided [translations](/guides/localization/).
814 */
815 loadingText: _propTypes.default.node,
816
817 /**
818 * If `true`, `value` must be an array and the menu will support multiple selections.
819 */
820 multiple: _propTypes.default
821 /* @typescript-to-proptypes-ignore */
822 .bool,
823
824 /**
825 * Text to display when there are no options.
826 *
827 * For localization purposes, you can use the provided [translations](/guides/localization/).
828 */
829 noOptionsText: _propTypes.default.node,
830
831 /**
832 * Callback fired when the value changes.
833 *
834 * @param {object} event The event source of the callback.
835 * @param {T|T[]} value The new value of the component.
836 * @param {string} reason One of "create-option", "select-option", "remove-option", "blur" or "clear".
837 */
838 onChange: _propTypes.default.func,
839
840 /**
841 * Callback fired when the popup requests to be closed.
842 * Use in controlled mode (see open).
843 *
844 * @param {object} event The event source of the callback.
845 * @param {string} reason Can be: `"toggleInput"`, `"escape"`, `"select-option"`, `"blur"`.
846 */
847 onClose: _propTypes.default.func,
848
849 /**
850 * Callback fired when the highlight option changes.
851 *
852 * @param {object} event The event source of the callback.
853 * @param {T} option The highlighted option.
854 * @param {string} reason Can be: `"keyboard"`, `"auto"`, `"mouse"`.
855 */
856 onHighlightChange: _propTypes.default.func,
857
858 /**
859 * Callback fired when the input value changes.
860 *
861 * @param {object} event The event source of the callback.
862 * @param {string} value The new value of the text input.
863 * @param {string} reason Can be: `"input"` (user input), `"reset"` (programmatic change), `"clear"`.
864 */
865 onInputChange: _propTypes.default.func,
866
867 /**
868 * Callback fired when the popup requests to be opened.
869 * Use in controlled mode (see open).
870 *
871 * @param {object} event The event source of the callback.
872 */
873 onOpen: _propTypes.default.func,
874
875 /**
876 * Control the popup` open state.
877 */
878 open: _propTypes.default.bool,
879
880 /**
881 * If `true`, the popup will open on input focus.
882 */
883 openOnFocus: _propTypes.default.bool,
884
885 /**
886 * Override the default text for the *open popup* icon button.
887 *
888 * For localization purposes, you can use the provided [translations](/guides/localization/).
889 */
890 openText: _propTypes.default.string,
891
892 /**
893 * Array of options.
894 */
895 options: _propTypes.default.array.isRequired,
896
897 /**
898 * The component used to render the body of the popup.
899 */
900 PaperComponent: _propTypes.default.elementType,
901
902 /**
903 * The component used to position the popup.
904 */
905 PopperComponent: _propTypes.default.elementType,
906
907 /**
908 * The icon to display in place of the default popup icon.
909 */
910 popupIcon: _propTypes.default.node,
911
912 /**
913 * Render the group.
914 *
915 * @param {any} option The group to render.
916 * @returns {ReactNode}
917 */
918 renderGroup: _propTypes.default.func,
919
920 /**
921 * Render the input.
922 *
923 * @param {object} params
924 * @returns {ReactNode}
925 */
926 renderInput: _propTypes.default.func.isRequired,
927
928 /**
929 * Render the option, use `getOptionLabel` by default.
930 *
931 * @param {T} option The option to render.
932 * @param {object} state The state of the component.
933 * @returns {ReactNode}
934 */
935 renderOption: _propTypes.default.func,
936
937 /**
938 * Render the selected value.
939 *
940 * @param {T[]} value The `value` provided to the component.
941 * @param {function} getTagProps A tag props getter.
942 * @returns {ReactNode}
943 */
944 renderTags: _propTypes.default.func,
945
946 /**
947 * If `true`, the input's text will be selected on focus.
948 * It helps the user clear the selected value.
949 */
950 selectOnFocus: _propTypes.default.bool,
951
952 /**
953 * The size of the autocomplete.
954 */
955 size: _propTypes.default.oneOf(['medium', 'small']),
956
957 /**
958 * The value of the autocomplete.
959 *
960 * The value must have reference equality with the option in order to be selected.
961 * You can customize the equality behavior with the `getOptionSelected` prop.
962 */
963 value: _propTypes.default.any
964} : void 0;
965
966var _default = (0, _styles.withStyles)(styles, {
967 name: 'MuiAutocomplete'
968})(Autocomplete);
969
970exports.default = _default;
\No newline at end of file