UNPKG

@elastic/eui

Version:

Elastic UI Component Library

801 lines (798 loc) 36.5 kB
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } function _extends() { _extends = Object.assign ? Object.assign.bind() : 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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0 and the Server Side Public License, v 1; you may not use this file except * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ import React, { Component } from 'react'; import PropTypes from "prop-types"; import classNames from 'classnames'; import moment from 'moment'; // eslint-disable-line import/named import dateMath from '@elastic/datemath'; import { isObject } from '../../../services/predicate'; import { EuiI18nConsumer } from '../../context'; import { EuiDatePickerRange } from '../date_picker_range'; import { EuiFormControlLayout } from '../../form'; import { RenderI18nTimeOptions } from './time_options'; import { PrettyDuration, showPrettyDuration } from './pretty_duration'; import { AsyncInterval } from './async_interval'; import { EuiSuperUpdateButton } from './super_update_button'; import { EuiQuickSelectPopover } from './quick_select_popover/quick_select_popover'; import { EuiDatePopoverButton } from './date_popover/date_popover_button'; import { EuiAutoRefresh, EuiAutoRefreshButton } from '../auto_refresh/auto_refresh'; import { jsx as ___EmotionJSX } from "@emotion/react"; function isRangeInvalid(start, end) { if (start === 'now' && end === 'now') { return true; } var startMoment = dateMath.parse(start); var endMoment = dateMath.parse(end, { roundUp: true }); var isInvalid = !startMoment || !endMoment || !startMoment.isValid() || !endMoment.isValid() || !moment(startMoment).isValid() || !moment(endMoment).isValid() || startMoment.isAfter(endMoment); return isInvalid; } export var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) { _inherits(EuiSuperDatePickerInternal, _Component); var _super = _createSuper(EuiSuperDatePickerInternal); function EuiSuperDatePickerInternal() { var _this; _classCallCheck(this, EuiSuperDatePickerInternal); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _defineProperty(_assertThisInitialized(_this), "asyncInterval", void 0); _defineProperty(_assertThisInitialized(_this), "state", { prevProps: { start: _this.props.start, end: _this.props.end }, start: _this.props.start, end: _this.props.end, isInvalid: isRangeInvalid(_this.props.start, _this.props.end), hasChanged: false, showPrettyDuration: showPrettyDuration(_this.props.start, _this.props.end, _this.props.commonlyUsedRanges), isStartDatePopoverOpen: false, isEndDatePopoverOpen: false }); _defineProperty(_assertThisInitialized(_this), "setTime", function (_ref) { var end = _ref.end, start = _ref.start; var isInvalid = isRangeInvalid(start, end); _this.setState({ start: start, end: end, isInvalid: isInvalid, hasChanged: !(_this.state.prevProps.start === start && _this.state.prevProps.end === end) }); if (!_this.props.showUpdateButton) { _this.props.onTimeChange({ start: start, end: end, isQuickSelection: false, isInvalid: isInvalid }); } }); _defineProperty(_assertThisInitialized(_this), "componentDidMount", function () { if (!_this.props.isPaused) { _this.startInterval(_this.props.refreshInterval); } }); _defineProperty(_assertThisInitialized(_this), "componentDidUpdate", function () { _this.stopInterval(); if (!_this.props.isPaused) { _this.startInterval(_this.props.refreshInterval); } }); _defineProperty(_assertThisInitialized(_this), "componentWillUnmount", function () { _this.stopInterval(); }); _defineProperty(_assertThisInitialized(_this), "setStart", function (start) { _this.setTime({ start: start, end: _this.state.end }); }); _defineProperty(_assertThisInitialized(_this), "setEnd", function (end) { _this.setTime({ start: _this.state.start, end: end }); }); _defineProperty(_assertThisInitialized(_this), "applyTime", function () { _this.props.onTimeChange({ start: _this.state.start, end: _this.state.end, isQuickSelection: false, isInvalid: false }); }); _defineProperty(_assertThisInitialized(_this), "applyQuickTime", function (_ref2) { var start = _ref2.start, end = _ref2.end; _this.setState({ showPrettyDuration: showPrettyDuration(start, end, _this.props.commonlyUsedRanges) }); _this.props.onTimeChange({ start: start, end: end, isQuickSelection: true, isInvalid: false }); }); _defineProperty(_assertThisInitialized(_this), "hidePrettyDuration", function () { _this.setState({ showPrettyDuration: false, isStartDatePopoverOpen: true }); }); _defineProperty(_assertThisInitialized(_this), "onStartDatePopoverToggle", function () { _this.setState(function (prevState) { return { isStartDatePopoverOpen: !prevState.isStartDatePopoverOpen }; }); }); _defineProperty(_assertThisInitialized(_this), "onStartDatePopoverClose", function () { _this.setState({ isStartDatePopoverOpen: false }); }); _defineProperty(_assertThisInitialized(_this), "onEndDatePopoverToggle", function () { _this.setState(function (prevState) { return { isEndDatePopoverOpen: !prevState.isEndDatePopoverOpen }; }); }); _defineProperty(_assertThisInitialized(_this), "onEndDatePopoverClose", function () { _this.setState({ isEndDatePopoverOpen: false }); }); _defineProperty(_assertThisInitialized(_this), "onRefreshChange", function (_ref3) { var refreshInterval = _ref3.refreshInterval, isPaused = _ref3.isPaused; _this.stopInterval(); if (!isPaused) { _this.startInterval(refreshInterval); } if (_this.props.onRefreshChange) { _this.props.onRefreshChange({ refreshInterval: refreshInterval, isPaused: isPaused }); } }); _defineProperty(_assertThisInitialized(_this), "stopInterval", function () { if (_this.asyncInterval) { _this.asyncInterval.stop(); } }); _defineProperty(_assertThisInitialized(_this), "startInterval", function (refreshInterval) { var onRefresh = _this.props.onRefresh; if (onRefresh) { var handler = function handler() { var _this$props = _this.props, start = _this$props.start, end = _this$props.end; onRefresh({ start: start, end: end, refreshInterval: refreshInterval }); }; _this.asyncInterval = new AsyncInterval(handler, refreshInterval); } }); _defineProperty(_assertThisInitialized(_this), "renderQuickSelect", function () { var _this$props2 = _this.props, start = _this$props2.start, end = _this$props2.end, customQuickSelectPanels = _this$props2.customQuickSelectPanels, customQuickSelectRender = _this$props2.customQuickSelectRender, commonlyUsedRanges = _this$props2.commonlyUsedRanges, timeOptions = _this$props2.timeOptions, dateFormat = _this$props2.dateFormat, onRefreshChange = _this$props2.onRefreshChange, recentlyUsedRanges = _this$props2.recentlyUsedRanges, refreshInterval = _this$props2.refreshInterval, isPaused = _this$props2.isPaused, isDisabled = _this$props2.isDisabled; return ___EmotionJSX(EuiQuickSelectPopover, { applyRefreshInterval: onRefreshChange ? _this.onRefreshChange : undefined, applyTime: _this.applyQuickTime, commonlyUsedRanges: commonlyUsedRanges, customQuickSelectPanels: customQuickSelectPanels, customQuickSelectRender: customQuickSelectRender, dateFormat: dateFormat, end: end, isDisabled: !!isDisabled, isPaused: isPaused, recentlyUsedRanges: recentlyUsedRanges, refreshInterval: refreshInterval, start: start, timeOptions: timeOptions }); }); _defineProperty(_assertThisInitialized(_this), "renderDatePickerRange", function () { var _this$state = _this.state, end = _this$state.end, hasChanged = _this$state.hasChanged, isEndDatePopoverOpen = _this$state.isEndDatePopoverOpen, isInvalid = _this$state.isInvalid, isStartDatePopoverOpen = _this$state.isStartDatePopoverOpen, showPrettyDuration = _this$state.showPrettyDuration, start = _this$state.start; var _this$props3 = _this.props, isQuickSelectOnly = _this$props3.isQuickSelectOnly, showUpdateButton = _this$props3.showUpdateButton, commonlyUsedRanges = _this$props3.commonlyUsedRanges, timeOptions = _this$props3.timeOptions, dateFormat = _this$props3.dateFormat, refreshInterval = _this$props3.refreshInterval, isPaused = _this$props3.isPaused, isDisabled = _this$props3.isDisabled, isLoading = _this$props3.isLoading, locale = _this$props3.locale, timeFormat = _this$props3.timeFormat, utcOffset = _this$props3.utcOffset, compressed = _this$props3.compressed, onFocus = _this$props3.onFocus; var autoRefreshAppend = !isPaused ? ___EmotionJSX(EuiAutoRefreshButton, { refreshInterval: refreshInterval, isDisabled: !!isDisabled, isPaused: isPaused, onRefreshChange: _this.onRefreshChange, shortHand: true }) : undefined; var formControlLayoutProps = { compressed: compressed, isInvalid: isInvalid, isLoading: isLoading && !showUpdateButton, disabled: !!isDisabled, prepend: _this.renderQuickSelect(), append: autoRefreshAppend }; if (isQuickSelectOnly) { return ___EmotionJSX(EuiFormControlLayout, _extends({ iconsPosition: "static" }, formControlLayoutProps)); } var isDisabledDisplay = isObject(isDisabled) && (isDisabled === null || isDisabled === void 0 ? void 0 : isDisabled.display); if (isDisabledDisplay || showPrettyDuration && !isStartDatePopoverOpen && !isEndDatePopoverOpen) { return ___EmotionJSX(EuiFormControlLayout, formControlLayoutProps, ___EmotionJSX("button", { className: classNames('euiSuperDatePicker__prettyFormat', { 'euiSuperDatePicker__prettyFormat--disabled': isDisabled }), "data-test-subj": "superDatePickerShowDatesButton", disabled: !!isDisabled, onClick: _this.hidePrettyDuration, onFocus: onFocus }, isDisabledDisplay ? isDisabled.display : ___EmotionJSX(PrettyDuration, { timeFrom: start, timeTo: end, quickRanges: commonlyUsedRanges, dateFormat: dateFormat }))); } return ___EmotionJSX(EuiI18nConsumer, null, function (_ref4) { var contextLocale = _ref4.locale; return ___EmotionJSX(EuiDatePickerRange, _extends({}, formControlLayoutProps, { isCustom: true, iconType: false, startDateControl: ___EmotionJSX(EuiDatePopoverButton, { className: "euiSuperDatePicker__startPopoverButton", compressed: compressed, position: "start", needsUpdating: hasChanged, isInvalid: isInvalid, isDisabled: !!isDisabled, onChange: _this.setStart, value: start, dateFormat: dateFormat, utcOffset: utcOffset, timeFormat: timeFormat, locale: locale || contextLocale, isOpen: _this.state.isStartDatePopoverOpen, onPopoverToggle: _this.onStartDatePopoverToggle, onPopoverClose: _this.onStartDatePopoverClose, timeOptions: timeOptions, buttonProps: { onFocus: onFocus } }), endDateControl: ___EmotionJSX(EuiDatePopoverButton, { position: "end", compressed: compressed, needsUpdating: hasChanged, isInvalid: isInvalid, isDisabled: !!isDisabled, onChange: _this.setEnd, value: end, dateFormat: dateFormat, utcOffset: utcOffset, timeFormat: timeFormat, locale: locale || contextLocale, roundUp: true, isOpen: _this.state.isEndDatePopoverOpen, onPopoverToggle: _this.onEndDatePopoverToggle, onPopoverClose: _this.onEndDatePopoverClose, timeOptions: timeOptions, buttonProps: { onFocus: onFocus } }) })); }); }); _defineProperty(_assertThisInitialized(_this), "handleClickUpdateButton", function () { if (!_this.state.hasChanged && _this.props.onRefresh) { var _this$props4 = _this.props, start = _this$props4.start, end = _this$props4.end, refreshInterval = _this$props4.refreshInterval; _this.props.onRefresh({ start: start, end: end, refreshInterval: refreshInterval }); } else { _this.applyTime(); } }); _defineProperty(_assertThisInitialized(_this), "renderUpdateButton", function () { var _this$props5 = _this.props, isLoading = _this$props5.isLoading, isDisabled = _this$props5.isDisabled, updateButtonProps = _this$props5.updateButtonProps, showUpdateButton = _this$props5.showUpdateButton, compressed = _this$props5.compressed; if (!showUpdateButton) return null; return ___EmotionJSX(EuiSuperUpdateButton, _extends({ needsUpdate: _this.state.hasChanged, showTooltip: !_this.state.isStartDatePopoverOpen && !_this.state.isEndDatePopoverOpen, isLoading: isLoading, isDisabled: !!isDisabled || _this.state.isInvalid, onClick: _this.handleClickUpdateButton, "data-test-subj": "superDatePickerApplyTimeButton", size: compressed ? 's' : 'm', iconOnly: showUpdateButton === 'iconOnly' }, updateButtonProps)); }); return _this; } _createClass(EuiSuperDatePickerInternal, [{ key: "render", value: function render() { var _this$props6 = this.props, isAutoRefreshOnly = _this$props6.isAutoRefreshOnly, isDisabled = _this$props6.isDisabled, isPaused = _this$props6.isPaused, onRefreshChange = _this$props6.onRefreshChange, refreshInterval = _this$props6.refreshInterval, showUpdateButton = _this$props6.showUpdateButton, dataTestSubj = _this$props6['data-test-subj'], _width = _this$props6.width, isQuickSelectOnly = _this$props6.isQuickSelectOnly, compressed = _this$props6.compressed, className = _this$props6.className; var _this$state2 = this.state, hasChanged = _this$state2.hasChanged, isInvalid = _this$state2.isInvalid; // Force reduction in width if showing quick select only var width = isQuickSelectOnly ? 'auto' : _width; var classes = classNames('euiSuperDatePicker', className, { 'euiSuperDatePicker--needsUpdating': hasChanged && !isDisabled && !isInvalid, 'euiSuperDatePicker--noUpdateButton': !showUpdateButton, 'euiSuperDatePicker--isAutoRefreshOnly': isAutoRefreshOnly, 'euiSuperDatePicker--isQuickSelectOnly': isQuickSelectOnly, 'euiSuperDatePicker--fullWidth': width === 'full', 'euiSuperDatePicker--autoWidth': width === 'auto' }); return ___EmotionJSX("div", { className: classes, "data-test-subj": dataTestSubj }, isAutoRefreshOnly && onRefreshChange ? ___EmotionJSX(EuiAutoRefresh, { isPaused: isPaused, refreshInterval: refreshInterval, onRefreshChange: onRefreshChange, fullWidth: width === 'full', compressed: compressed, isDisabled: !!isDisabled, className: className }) : ___EmotionJSX(React.Fragment, null, this.renderDatePickerRange(), this.renderUpdateButton())); } }], [{ key: "getDerivedStateFromProps", value: function getDerivedStateFromProps(nextProps, prevState) { if (nextProps.start !== prevState.prevProps.start || nextProps.end !== prevState.prevProps.end) { return { prevProps: { start: nextProps.start, end: nextProps.end }, start: nextProps.start, end: nextProps.end, isInvalid: isRangeInvalid(nextProps.start, nextProps.end), hasChanged: false, showPrettyDuration: showPrettyDuration(nextProps.start, nextProps.end, nextProps.commonlyUsedRanges) }; } return null; } }]); return EuiSuperDatePickerInternal; }(Component); // Because EuiSuperDatePicker is a class component and not a functional component, // we have to use a render prop here in order for us to pass i18n'd strings/objects/etc // to all underlying usages of our timeOptions constants. If someday we convert // EuiSuperDatePicker to an FC, we can likely get rid of this wrapper. _defineProperty(EuiSuperDatePickerInternal, "defaultProps", { dateFormat: 'MMM D, YYYY @ HH:mm:ss.SSS', end: 'now', isAutoRefreshOnly: false, isDisabled: false, isPaused: true, recentlyUsedRanges: [], refreshInterval: 1000, showUpdateButton: true, start: 'now-15m', timeFormat: 'HH:mm', width: 'restricted' }); EuiSuperDatePickerInternal.propTypes = { className: PropTypes.string, "aria-label": PropTypes.string, "data-test-subj": PropTypes.string, css: PropTypes.any, // The below options are marked as required because they have default fallbacks commonlyUsedRanges: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.shape({ end: PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]).isRequired, label: PropTypes.string, start: PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]).isRequired }).isRequired), PropTypes.arrayOf(PropTypes.shape({ end: PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]).isRequired, label: PropTypes.string, start: PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]).isRequired }).isRequired).isRequired]), customQuickSelectPanels: PropTypes.arrayOf(PropTypes.shape({ title: PropTypes.string.isRequired, content: PropTypes.element.isRequired }).isRequired), /** * An optional render prop function that allows customizing the display of the Quick Select menu. * This function passes all default quick select panels within an object, allowing you to * re-order panels, omit certain panels entirely, or pass in your own fully custom content. */ customQuickSelectRender: PropTypes.func, /** * Specifies the formatted used when displaying dates and/or datetimes */ dateFormat: PropTypes.oneOfType([PropTypes.string, PropTypes.string.isRequired]), /** * Set isAutoRefreshOnly to true to limit the component to only display auto refresh content. */ isAutoRefreshOnly: PropTypes.bool, /** * Accepts either a true/false boolean or an object configuration. * * The configuration will render the component as disabled, and allow you to * customize the displayed disabled text. */ isDisabled: PropTypes.oneOfType([PropTypes.bool.isRequired, PropTypes.shape({ display: PropTypes.node.isRequired }).isRequired]), isLoading: PropTypes.bool, isPaused: PropTypes.oneOfType([PropTypes.bool, PropTypes.bool.isRequired]), /** * Sets the overall width by adding sensible min and max widths. * - `auto`: fits width to internal content / time string. * - `restricted`: static width that fits the longest possible time string. * - `full`: expands to 100% of the container. */ width: PropTypes.oneOf(["restricted", "full", "auto"]), /** * Reduces overall height to compressed form size */ compressed: PropTypes.bool, /** * Used to localize e.g. month names, passed to `moment` */ locale: PropTypes.any, /** * Triggered whenever the EuiSuperDatePicker's dates are focused */ onFocus: PropTypes.any, /** * Callback for when the refresh interval is fired. * EuiSuperDatePicker will only manage a refresh interval timer when onRefresh callback is supplied * If a promise is returned, the next refresh interval will not start until the promise has resolved. * If the promise rejects the refresh interval will stop and the error thrown */ onRefresh: PropTypes.func, /** * Callback for when the refresh interval changes. * Supply onRefreshChange to show refresh interval inputs in quick select popover */ onRefreshChange: PropTypes.func, /** * Callback for when the time changes. */ onTimeChange: PropTypes.func.isRequired, recentlyUsedRanges: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.shape({ end: PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]).isRequired, label: PropTypes.string, start: PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]).isRequired }).isRequired), PropTypes.arrayOf(PropTypes.shape({ end: PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]).isRequired, label: PropTypes.string, start: PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]).isRequired }).isRequired).isRequired]), /** * Refresh interval in milliseconds */ refreshInterval: PropTypes.oneOfType([PropTypes.number, PropTypes.number.isRequired]), start: PropTypes.oneOfType([PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]), PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]).isRequired]), end: PropTypes.oneOfType([PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]), PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]).isRequired]), /** * Specifies the formatted used when displaying times */ timeFormat: PropTypes.oneOfType([PropTypes.string, PropTypes.string.isRequired]), utcOffset: PropTypes.number, /** * Set showUpdateButton to false to immediately invoke onTimeChange for all start and end changes. */ showUpdateButton: PropTypes.oneOfType([PropTypes.bool.isRequired, PropTypes.oneOf(["iconOnly"])]), /** * Hides the actual input reducing to just the quick select button. */ isQuickSelectOnly: PropTypes.bool, /** * Props passed to the update button #EuiSuperUpdateButtonProps */ updateButtonProps: PropTypes.shape({ /** * Show the "Click to apply" tooltip */ showTooltip: PropTypes.bool, /** * Passes props to `EuiToolTip` */ toolTipProps: PropTypes.shape({ /** * Passes onto the span wrapping the trigger. */ anchorClassName: PropTypes.string, /** * Passes onto the span wrapping the trigger. */ anchorProps: PropTypes.shape({ className: PropTypes.string, "aria-label": PropTypes.string, "data-test-subj": PropTypes.string, css: PropTypes.any }), /** * The in-view trigger for your tooltip. */ children: PropTypes.element.isRequired, /** * Passes onto the tooltip itself, not the trigger. */ className: PropTypes.string, /** * The main content of your tooltip. */ content: PropTypes.node, /** * Common display alternatives for the anchor wrapper */ display: PropTypes.oneOf(["inlineBlock", "block"]), /** * Delay before showing tooltip. Good for repeatable items. */ delay: PropTypes.oneOf(["regular", "long"]).isRequired, /** * An optional title for your tooltip. */ title: PropTypes.node, /** * Unless you provide one, this will be randomly generated. */ id: PropTypes.string, /** * Suggested position. If there is not enough room for it this will be changed. */ position: PropTypes.oneOf(["top", "right", "bottom", "left"]).isRequired, /** * When `true`, the tooltip's position is re-calculated when the user * scrolls. This supports having fixed-position tooltip anchors. * * When nesting an `EuiTooltip` in a scrollable container, `repositionOnScroll` should be `true` */ repositionOnScroll: PropTypes.bool, /** * If supplied, called when mouse movement causes the tool tip to be * hidden. */ onMouseOut: PropTypes.func }), /** * Returns an IconButton instead */ iconOnly: PropTypes.bool, /** * Forces state to be `iconOnly` when within provided breakpoints. * Remove completely with `false` or provide your own list of breakpoints. */ responsive: PropTypes.oneOfType([PropTypes.oneOf([false]), PropTypes.arrayOf(PropTypes.any.isRequired).isRequired]) }), timeOptions: PropTypes.shape({ timeTenseOptions: PropTypes.arrayOf(PropTypes.any.isRequired).isRequired, timeUnitsOptions: PropTypes.arrayOf(PropTypes.any.isRequired).isRequired, relativeOptions: PropTypes.arrayOf(PropTypes.shape({ text: PropTypes.string.isRequired, value: PropTypes.oneOfType([PropTypes.oneOf(["s", "m", "h", "d", "w", "M", "y"]).isRequired, PropTypes.oneOf(["s+", "m+", "h+", "d+", "w+", "M+", "y+"]).isRequired]).isRequired }).isRequired).isRequired, relativeRoundingLabels: PropTypes.any.isRequired, refreshUnitsOptions: PropTypes.arrayOf(PropTypes.any.isRequired).isRequired, commonDurationRanges: PropTypes.arrayOf(PropTypes.shape({ end: PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]).isRequired, label: PropTypes.string, start: PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]).isRequired }).isRequired).isRequired }).isRequired }; export var EuiSuperDatePicker = function EuiSuperDatePicker(props) { return ___EmotionJSX(RenderI18nTimeOptions, null, function (timeOptions) { return ___EmotionJSX(EuiSuperDatePickerInternal, _extends({}, props, { timeOptions: timeOptions, commonlyUsedRanges: props.commonlyUsedRanges || timeOptions.commonDurationRanges })); }); }; EuiSuperDatePicker.propTypes = { className: PropTypes.string, "aria-label": PropTypes.string, "data-test-subj": PropTypes.string, css: PropTypes.any, commonlyUsedRanges: PropTypes.arrayOf(PropTypes.shape({ end: PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]).isRequired, label: PropTypes.string, start: PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]).isRequired }).isRequired), customQuickSelectPanels: PropTypes.arrayOf(PropTypes.shape({ title: PropTypes.string.isRequired, content: PropTypes.element.isRequired }).isRequired), /** * An optional render prop function that allows customizing the display of the Quick Select menu. * This function passes all default quick select panels within an object, allowing you to * re-order panels, omit certain panels entirely, or pass in your own fully custom content. */ customQuickSelectRender: PropTypes.func, /** * Specifies the formatted used when displaying dates and/or datetimes */ dateFormat: PropTypes.string, /** * Set isAutoRefreshOnly to true to limit the component to only display auto refresh content. */ isAutoRefreshOnly: PropTypes.bool, /** * Accepts either a true/false boolean or an object configuration. * * The configuration will render the component as disabled, and allow you to * customize the displayed disabled text. */ isDisabled: PropTypes.oneOfType([PropTypes.bool.isRequired, PropTypes.shape({ display: PropTypes.node.isRequired }).isRequired]), isLoading: PropTypes.bool, isPaused: PropTypes.bool, /** * Sets the overall width by adding sensible min and max widths. * - `auto`: fits width to internal content / time string. * - `restricted`: static width that fits the longest possible time string. * - `full`: expands to 100% of the container. */ width: PropTypes.oneOf(["restricted", "full", "auto"]), /** * Reduces overall height to compressed form size */ compressed: PropTypes.bool, /** * Used to localize e.g. month names, passed to `moment` */ locale: PropTypes.any, /** * Triggered whenever the EuiSuperDatePicker's dates are focused */ onFocus: PropTypes.any, /** * Callback for when the refresh interval is fired. * EuiSuperDatePicker will only manage a refresh interval timer when onRefresh callback is supplied * If a promise is returned, the next refresh interval will not start until the promise has resolved. * If the promise rejects the refresh interval will stop and the error thrown */ onRefresh: PropTypes.func, /** * Callback for when the refresh interval changes. * Supply onRefreshChange to show refresh interval inputs in quick select popover */ onRefreshChange: PropTypes.func, /** * Callback for when the time changes. */ onTimeChange: PropTypes.func.isRequired, recentlyUsedRanges: PropTypes.arrayOf(PropTypes.shape({ end: PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]).isRequired, label: PropTypes.string, start: PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]).isRequired }).isRequired), /** * Refresh interval in milliseconds */ refreshInterval: PropTypes.number, start: PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]), end: PropTypes.oneOfType([PropTypes.oneOf(["now"]), PropTypes.string.isRequired]), /** * Specifies the formatted used when displaying times */ timeFormat: PropTypes.string, utcOffset: PropTypes.number, /** * Set showUpdateButton to false to immediately invoke onTimeChange for all start and end changes. */ showUpdateButton: PropTypes.oneOfType([PropTypes.bool.isRequired, PropTypes.oneOf(["iconOnly"])]), /** * Hides the actual input reducing to just the quick select button. */ isQuickSelectOnly: PropTypes.bool, /** * Props passed to the update button #EuiSuperUpdateButtonProps */ updateButtonProps: PropTypes.shape({ showTooltip: PropTypes.bool, toolTipProps: PropTypes.shape({ anchorClassName: PropTypes.string, anchorProps: PropTypes.shape({ className: PropTypes.string, "aria-label": PropTypes.string, "data-test-subj": PropTypes.string, css: PropTypes.any }), children: PropTypes.element.isRequired, className: PropTypes.string, content: PropTypes.node, display: PropTypes.oneOf(["inlineBlock", "block"]), delay: PropTypes.oneOf(["regular", "long"]).isRequired, title: PropTypes.node, id: PropTypes.string, position: PropTypes.oneOf(["top", "right", "bottom", "left"]).isRequired, repositionOnScroll: PropTypes.bool, onMouseOut: PropTypes.func }), iconOnly: PropTypes.bool, responsive: PropTypes.oneOfType([PropTypes.oneOf([false]), PropTypes.arrayOf(PropTypes.any.isRequired).isRequired]) }) };