/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
class SearchBox extends PureComponent { static get propTypes() { return {
autocompleteProvider: PropTypes.func,
delay: PropTypes.number,
keyShortcut: PropTypes.string,
learnMoreTitle: PropTypes.string,
learnMoreUrl: PropTypes.string,
onBlur: PropTypes.func,
onChange: PropTypes.func.isRequired,
onClearButtonClick: PropTypes.func,
onFocus: PropTypes.func, // Optional function that will be called on the focus keyboard shortcut, before // setting the focus to the input. If the function returns false, the input won't // get focused.
onFocusKeyboardShortcut: PropTypes.func,
onKeyDown: PropTypes.func,
placeholder: PropTypes.string.isRequired,
summary: PropTypes.string,
summaryId: PropTypes.string,
summaryTooltip: PropTypes.string,
type: PropTypes.string,
value: PropTypes.string,
};
}
if (!this.props.delay) { this.props.onChange(inputValue); return;
}
// Clean up an existing timeout before creating a new one. if (this.searchTimeout) {
clearTimeout(this.searchTimeout);
}
// Execute the search after a timeout. It makes the UX // smoother if the user is typing quickly. this.searchTimeout = setTimeout(() => { this.searchTimeout = null; this.props.onChange(this.state.value);
}, this.props.delay);
}
onClearButtonClick() { this.onChange("");
if (this.props.onClearButtonClick) { this.props.onClearButtonClick();
}
}
onFocus() { if (this.props.onFocus) { this.props.onFocus();
}
this.setState({ focused: true });
}
onBlur() { if (this.props.onBlur) { this.props.onBlur();
}
this.setState({ focused: false });
}
onKeyDown(e) { if (this.props.onKeyDown) { this.props.onKeyDown(e);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.