UNPKG

@gooddata/react-components

Version:

GoodData.UI - A powerful JavaScript library for building analytical applications

55 lines 3.26 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { 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 extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); // (C) 2020 GoodData Corporation var React = require("react"); var react_intl_1 = require("react-intl"); var Overlay_1 = require("@gooddata/goodstrap/lib/core/Overlay"); var PresetsDropdownItem_1 = require("./PresetsDropdownItem"); var positioning_1 = require("../../../typings/positioning"); var utils_1 = require("../../../helpers/utils"); var PresetsDropdown = /** @class */ (function (_super) { __extends(PresetsDropdown, _super); function PresetsDropdown() { return _super !== null && _super.apply(this, arguments) || this; } PresetsDropdown.prototype.render = function () { var _this = this; var _a = this.props, presets = _a.presets, anchorEl = _a.anchorEl, onClose = _a.onClose, positioning = _a.positioning; return (React.createElement(Overlay_1.default, { closeOnOutsideClick: true, closeOnParentScroll: true, closeOnMouseDrag: true, alignTo: anchorEl, alignPoints: utils_1.positioningToAlignPoints(positioning), onClose: onClose }, React.createElement("div", { className: "gd-dropdown overlay" }, React.createElement("div", { className: "gd-measure-number-format-dropdown-body s-measure-number-format-dropdown-body" }, presets.map(function (preset, index) { return _this.renderPresetOption(preset, index); }), this.renderCustomFormatItem())))); }; PresetsDropdown.prototype.renderPresetOption = function (preset, index) { var _a = this.props, selectedPreset = _a.selectedPreset, separators = _a.separators, onSelect = _a.onSelect; return (React.createElement(PresetsDropdownItem_1.PresetsDropdownItem, { key: preset.localIdentifier + "_" + index, preset: preset, separators: separators, onClick: onSelect, isSelected: selectedPreset && preset.localIdentifier === selectedPreset.localIdentifier })); }; PresetsDropdown.prototype.renderCustomFormatItem = function () { var _a = this.props, customPreset = _a.customPreset, presets = _a.presets; return this.renderPresetOption(customPreset, presets.length); }; PresetsDropdown.defaultProps = { positioning: [ { snapPoints: { parent: positioning_1.SnapPoint.BottomLeft, child: positioning_1.SnapPoint.TopLeft } }, { snapPoints: { parent: positioning_1.SnapPoint.TopLeft, child: positioning_1.SnapPoint.BottomLeft } }, ], }; return PresetsDropdown; }(React.PureComponent)); exports.PresetsDropdown = PresetsDropdown; exports.default = react_intl_1.injectIntl(PresetsDropdown); //# sourceMappingURL=PresetsDropdown.js.map