UNPKG

@gooddata/react-components

Version:
81 lines 3.74 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; exports.__esModule = true; var React = require("react"); var GoodData = require("gooddata"); var pick = require("lodash/pick"); var IntlWrapper_1 = require("../../core/base/IntlWrapper"); var react_intl_1 = require("react-intl"); var AttributeDropdown_1 = require("./AttributeDropdown"); var AttributeLoader_1 = require("./AttributeLoader"); var PropTypes = React.PropTypes; var DefaultFilterLoading = react_intl_1.injectIntl(function (_a) { var intl = _a.intl; return (React.createElement("button", { className: "button button-secondary button-small icon-right icon disabled s-button-loading" }, intl.formatMessage({ id: 'gs.filter.loading' }))); }); var DefaultFilterError = react_intl_1.injectIntl(function (_a) { var intl = _a.intl; var text = intl.formatMessage({ id: 'gs.filter.error' }); return React.createElement("div", { className: "gd-message error" }, text); }); var AttributeFilter = /** @class */ (function (_super) { __extends(AttributeFilter, _super); function AttributeFilter() { return _super !== null && _super.apply(this, arguments) || this; } AttributeFilter.prototype.render = function () { var _this = this; var _a = this.props, locale = _a.locale, projectId = _a.projectId, uri = _a.uri, identifier = _a.identifier, metadata = _a.metadata; return (React.createElement(IntlWrapper_1.IntlWrapper, { locale: locale }, React.createElement(AttributeLoader_1.AttributeLoader, { uri: uri, identifier: identifier, projectId: projectId, metadata: metadata }, function (props) { return _this.renderContent(props); }))); }; AttributeFilter.prototype.renderContent = function (_a) { var isLoading = _a.isLoading, attributeDisplayForm = _a.attributeDisplayForm; if (isLoading) { return React.createElement(this.props.FilterLoading, null); } var dropdownProps = pick(this.props, Object.keys(AttributeDropdown_1.AttributeDropdownWrapped.propTypes)); return (React.createElement(AttributeDropdown_1.AttributeDropdown, __assign({ attributeDisplayForm: attributeDisplayForm }, dropdownProps))); }; AttributeFilter.propTypes = { uri: PropTypes.string, identifier: PropTypes.string, projectId: PropTypes.string, FilterLoading: PropTypes.func, FilterError: PropTypes.func, locale: PropTypes.string, metadata: PropTypes.shape({ getObjectUri: PropTypes.func.isRequired, getObjectDetails: PropTypes.func.isRequired }) }; AttributeFilter.defaultProps = { uri: null, identifier: null, projectId: null, locale: 'en-US', metadata: GoodData.md, FilterLoading: DefaultFilterLoading, FilterError: DefaultFilterError }; return AttributeFilter; }(React.PureComponent)); exports.AttributeFilter = AttributeFilter; //# sourceMappingURL=AttributeFilter.js.map