mirror of
https://github.com/imezx/Warp.git
synced 2025-04-24 23:20:02 +00:00
49 lines
No EOL
2.8 KiB
JavaScript
49 lines
No EOL
2.8 KiB
JavaScript
var _excluded = ["translations"];
|
|
|
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
|
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
|
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
|
|
import React from 'react';
|
|
import { ErrorScreen } from './ErrorScreen';
|
|
import { NoResultsScreen } from './NoResultsScreen';
|
|
import { ResultsScreen } from './ResultsScreen';
|
|
import { StartScreen } from './StartScreen';
|
|
export var ScreenState = React.memo(function (_ref) {
|
|
var _ref$translations = _ref.translations,
|
|
translations = _ref$translations === void 0 ? {} : _ref$translations,
|
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
|
|
if (props.state.status === 'error') {
|
|
return /*#__PURE__*/React.createElement(ErrorScreen, {
|
|
translations: translations === null || translations === void 0 ? void 0 : translations.errorScreen
|
|
});
|
|
}
|
|
|
|
var hasCollections = props.state.collections.some(function (collection) {
|
|
return collection.items.length > 0;
|
|
});
|
|
|
|
if (!props.state.query) {
|
|
return /*#__PURE__*/React.createElement(StartScreen, _extends({}, props, {
|
|
hasCollections: hasCollections,
|
|
translations: translations === null || translations === void 0 ? void 0 : translations.startScreen
|
|
}));
|
|
}
|
|
|
|
if (hasCollections === false) {
|
|
return /*#__PURE__*/React.createElement(NoResultsScreen, _extends({}, props, {
|
|
translations: translations === null || translations === void 0 ? void 0 : translations.noResultsScreen
|
|
}));
|
|
}
|
|
|
|
return /*#__PURE__*/React.createElement(ResultsScreen, props);
|
|
}, function areEqual(_prevProps, nextProps) {
|
|
// We don't update the screen when Autocomplete is loading or stalled to
|
|
// avoid UI flashes:
|
|
// - Empty screen → Results screen
|
|
// - NoResults screen → NoResults screen with another query
|
|
return nextProps.state.status === 'loading' || nextProps.state.status === 'stalled';
|
|
}); |