UNPKG

@wix/design-system

Version:

@wix/design-system

57 lines 1.77 kB
import React from 'react'; import Input from '../Input'; import InputWithOptions, { DEFAULT_POPOVER_PROPS, } from '../InputWithOptions/InputWithOptions'; class AutoComplete extends InputWithOptions { dropdownAdditionalProps() { const { options, predicate, emptyStateMessage, onEmptyState } = this.props; const filterFunc = this.state.isEditing ? predicate : () => true; const filtered = options.filter(filterFunc); if (filtered.length === 0) { onEmptyState?.(); return emptyStateMessage ? { options: [ { id: 'empty-state-message', value: emptyStateMessage, disabled: true, }, ], } : { options: [] }; } else { return { options: filtered }; } } } AutoComplete.displayName = 'AutoComplete'; AutoComplete.defaultProps = { predicate: () => true, autoSelect: true, border: 'standard', clearButton: false, closeOnSelect: true, dropdownOffsetLeft: '0', dropdownWidth: null, hasMore: false, hideStatusSuffix: false, inContainer: false, infiniteScroll: false, loadMore: null, markedOption: false, maxHeightPixels: 260, maxLength: 524288, options: [], overflow: 'auto', selectedHighlight: true, showOptionsIfEmptyInput: true, textOverflow: 'clip', onSelect: () => { }, inputElement: React.createElement(Input, null), popoverProps: DEFAULT_POPOVER_PROPS, tabIndex: 0, autocomplete: 'off', }; export default AutoComplete; //# sourceMappingURL=AutoComplete.js.map