position = _ref$position === void 0 ? 'bottom right' : _ref$position,
_ref$focusOnMount = _ref.focusOnMount,
focusOnMount = _ref$focusOnMount === void 0 ? 'firstElement' : _ref$focusOnMount,
anchorRef = _ref.anchorRef,
shouldAnchorIncludePadding = _ref.shouldAnchorIncludePadding,
anchorRect = _ref.anchorRect,
getAnchorRect = _ref.getAnchorRect,
expandOnMobile = _ref.expandOnMobile,
_ref$animate = _ref.animate,
animate = _ref$animate === void 0 ? true : _ref$animate,
onClickOutside = _ref.onClickOutside,
onFocusOutside = _ref.onFocusOutside,
__unstableStickyBoundaryElement = _ref.__unstableStickyBoundaryElement,
_ref$__unstableSlotNa = _ref.__unstableSlotName,
__unstableSlotName = _ref$__unstableSlotNa === void 0 ? SLOT_NAME : _ref$__unstableSlotNa,
__unstableObserveElement = _ref.__unstableObserveElement,
__unstableBoundaryParent = _ref.__unstableBoundaryParent,
__unstableForcePosition = _ref.__unstableForcePosition,
contentProps = Object(objectWithoutProperties["a" /* default */])(_ref, ["headerTitle", "onClose", "onKeyDown", "children", "className", "noArrow", "isAlternate", "position", "range", "focusOnMount", "anchorRef", "shouldAnchorIncludePadding", "anchorRect", "getAnchorRect", "expandOnMobile", "animate", "onClickOutside", "onFocusOutside", "__unstableStickyBoundaryElement", "__unstableSlotName", "__unstableObserveElement", "__unstableBoundaryParent", "__unstableForcePosition"]);
var anchorRefFallback = Object(external_wp_element_["useRef"])(null);
var contentRef = Object(external_wp_element_["useRef"])(null);
var containerRef = Object(external_wp_element_["useRef"])();
var isMobileViewport = Object(external_wp_compose_["useViewportMatch"])('medium', '<');
var _useState = Object(external_wp_element_["useState"])(),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
animateOrigin = _useState2[0],
setAnimateOrigin = _useState2[1];
var slot = Object(use_slot["a" /* default */])(__unstableSlotName);
var isExpanded = expandOnMobile && isMobileViewport;
var _useResizeObserver = Object(external_wp_compose_["useResizeObserver"])(),
_useResizeObserver2 = Object(slicedToArray["a" /* default */])(_useResizeObserver, 2),
containerResizeListener = _useResizeObserver2[0],
contentSize = _useResizeObserver2[1];
noArrow = isExpanded || noArrow;
Object(external_wp_element_["useLayoutEffect"])(function () {
setClass(containerRef.current, 'is-without-arrow', noArrow);
setClass(containerRef.current, 'is-alternate', isAlternate);
setAttribute(containerRef.current, 'data-x-axis');
setAttribute(containerRef.current, 'data-y-axis');
setStyle(containerRef.current, 'top');
setStyle(containerRef.current, 'left');
setStyle(contentRef.current, 'maxHeight');
setStyle(contentRef.current, 'maxWidth');
var refresh = function refresh() {
if (!containerRef.current || !contentRef.current) {
var anchor = computeAnchorRect(anchorRefFallback, anchorRect, getAnchorRect, anchorRef, shouldAnchorIncludePadding);
var _containerRef$current = containerRef.current,
offsetParent = _containerRef$current.offsetParent,
ownerDocument = _containerRef$current.ownerDocument;
var relativeOffsetTop = 0; // If there is a positioned ancestor element that is not the body,
// subtract the position from the anchor rect. If the position of
// the popover is fixed, the offset parent is null or the body
// element, in which case the position is relative to the viewport.
// See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent
if (offsetParent && offsetParent !== ownerDocument.body) {
var offsetParentRect = offsetParent.getBoundingClientRect();
relativeOffsetTop = offsetParentRect.top;
anchor = new window.DOMRect(anchor.left - offsetParentRect.left, anchor.top - offsetParentRect.top, anchor.width, anchor.height);
if (__unstableBoundaryParent) {
var _containerRef$current2;
boundaryElement = (_containerRef$current2 = containerRef.current.closest('.popover-slot')) === null || _containerRef$current2 === void 0 ? void 0 : _containerRef$current2.parentNode;
var usedContentSize = !contentSize.height ? contentRef.current.getBoundingClientRect() : contentSize;
var _computePopoverPositi = computePopoverPosition(anchor, usedContentSize, position, __unstableStickyBoundaryElement, containerRef.current, relativeOffsetTop, boundaryElement, __unstableForcePosition),
popoverTop = _computePopoverPositi.popoverTop,
popoverLeft = _computePopoverPositi.popoverLeft,
xAxis = _computePopoverPositi.xAxis,
yAxis = _computePopoverPositi.yAxis,
contentHeight = _computePopoverPositi.contentHeight,
contentWidth = _computePopoverPositi.contentWidth;
if (typeof popoverTop === 'number' && typeof popoverLeft === 'number') {
setStyle(containerRef.current, 'top', popoverTop + 'px');
setStyle(containerRef.current, 'left', popoverLeft + 'px');
setClass(containerRef.current, 'is-without-arrow', noArrow || xAxis === 'center' && yAxis === 'middle');
setClass(containerRef.current, 'is-alternate', isAlternate);
setAttribute(containerRef.current, 'data-x-axis', xAxis);
setAttribute(containerRef.current, 'data-y-axis', yAxis);
setStyle(contentRef.current, 'maxHeight', typeof contentHeight === 'number' ? contentHeight + 'px' : '');
setStyle(contentRef.current, 'maxWidth', typeof contentWidth === 'number' ? contentWidth + 'px' : ''); // Compute the animation position
var animateYAxis = yAxisMapping[yAxis] || 'middle';
var animateXAxis = xAxisMapping[xAxis] || 'center';
setAnimateOrigin(animateXAxis + ' ' + animateYAxis);
var ownerDocument = containerRef.current.ownerDocument;
var defaultView = ownerDocument.defaultView;
* There are sometimes we need to reposition or resize the popover that
* are not handled by the resize/scroll window events (i.e. CSS changes
* in the layout that changes the position of the anchor).
* For these situations, we refresh the popover every 0.5s
var intervalHandle = defaultView.setInterval(refresh, 500);
var refreshOnAnimationFrame = function refreshOnAnimationFrame() {
defaultView.cancelAnimationFrame(rafId);
rafId = defaultView.requestAnimationFrame(refresh);
}; // Sometimes a click trigger a layout change that affects the popover
// position. This is an opportunity to immediately refresh rather than
defaultView.addEventListener('click', refreshOnAnimationFrame);
defaultView.addEventListener('resize', refresh);
defaultView.addEventListener('scroll', refresh, true);
var anchorDocument = getAnchorDocument(anchorRef); // If the anchor is within an iframe, the popover position also needs
// to refrest when the iframe content is scrolled or resized.
if (anchorDocument && anchorDocument !== ownerDocument) {
anchorDocument.defaultView.addEventListener('resize', refresh);
anchorDocument.defaultView.addEventListener('scroll', refresh, true);
if (__unstableObserveElement) {
observer = new defaultView.MutationObserver(refresh);
observer.observe(__unstableObserveElement, {
defaultView.clearInterval(intervalHandle);
defaultView.removeEventListener('resize', refresh);
defaultView.removeEventListener('scroll', refresh, true);
defaultView.removeEventListener('click', refreshOnAnimationFrame);
defaultView.cancelAnimationFrame(rafId);
if (anchorDocument && anchorDocument !== ownerDocument) {
anchorDocument.defaultView.removeEventListener('resize', refresh);
anchorDocument.defaultView.removeEventListener('scroll', refresh, true);
}, [isExpanded, anchorRect, getAnchorRect, anchorRef, shouldAnchorIncludePadding, position, contentSize, __unstableStickyBoundaryElement, __unstableObserveElement, __unstableBoundaryParent]);
var constrainedTabbingRef = Object(external_wp_compose_["useConstrainedTabbing"])();
var focusReturnRef = Object(external_wp_compose_["useFocusReturn"])();
var focusOnMountRef = Object(external_wp_compose_["useFocusOnMount"])(focusOnMount);
var focusOutsideProps = Object(external_wp_compose_["__experimentalUseFocusOutside"])(handleOnFocusOutside);
var allRefs = [containerRef, focusOnMount ? constrainedTabbingRef : null, focusOnMount ? focusReturnRef : null, focusOnMount ? focusOnMountRef : null];
var mergedRefs = Object(external_wp_element_["useCallback"])(Object(react_merge_refs_esm["a" /* default */])(allRefs), allRefs); // Event handlers
var maybeClose = function maybeClose(event) {
if (event.keyCode === external_wp_keycodes_["ESCAPE"] && onClose) {
} // Preserve original content prop behavior
* Shims an onFocusOutside callback to be compatible with a deprecated
* onClickOutside prop function, if provided.
* @param {FocusEvent} event Focus event from onFocusOutside.
function handleOnFocusOutside(event) {
// Defer to given `onFocusOutside` if specified. Call `onClose` only if
// both `onFocusOutside` and `onClickOutside` are unspecified. Doing so
// assures backwards-compatibility for prior `onClickOutside` default.
} else if (!onClickOutside) {
} // Simulate MouseEvent using FocusEvent#relatedTarget as emulated click
// target. MouseEvent constructor is unsupported in Internet Explorer.
clickEvent = new window.MouseEvent('click');
clickEvent = document.createEvent('MouseEvent');
clickEvent.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
Object.defineProperty(clickEvent, 'target', {
return event.relatedTarget;
external_wp_deprecated_default()('Popover onClickOutside prop', {
alternative: 'onFocusOutside'
onClickOutside(clickEvent);
/** @type {false | string} */
var animateClassName = Boolean(animate && animateOrigin) && Object(build_module_animate["b" /* getAnimateClassName */])({
}); // Disable reason: We care to capture the _bubbled_ events from inputs
// within popover as inferring close intent.
var content = // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({
className: classnames_default()('components-popover', className, animateClassName, {
'is-expanded': isExpanded,
'is-without-arrow': noArrow,
'is-alternate': isAlternate
}), isExpanded && Object(external_wp_element_["createElement"])(scroll_lock["a" /* default */], null), isExpanded && Object(external_wp_element_["createElement"])("div", {
className: "components-popover__header"
}, Object(external_wp_element_["createElement"])("span", {
className: "components-popover__header-title"
}, headerTitle), Object(external_wp_element_["createElement"])(build_module_button["a" /* default */], {
className: "components-popover__close",
icon: library_close["a" /* default */],
})), Object(external_wp_element_["createElement"])("div", {
className: "components-popover__content"
}, Object(external_wp_element_["createElement"])("div", {
}, containerResizeListener, children)));
content = Object(external_wp_element_["createElement"])(slot_fill["a" /* Fill */], {
if (anchorRef || anchorRect) {
return Object(external_wp_element_["createElement"])("span", {
var PopoverContainer = popover_Popover;
PopoverContainer.Slot = function (_ref2) {
var _ref2$name = _ref2.name,
name = _ref2$name === void 0 ? SLOT_NAME : _ref2$name;
return Object(external_wp_element_["createElement"])(slot_fill["b" /* Slot */], {
className: "popover-slot"
/* harmony default export */ var popover = __webpack_exports__["a"] = (PopoverContainer);
/***/ (function(module, __webpack_exports__, __webpack_require__) {
__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ ensureFocus; });
// EXTERNAL MODULE: ./node_modules/reakit/node_modules/reakit-utils/es/getActiveElement.js
var getActiveElement = __webpack_require__("z222");
// CONCATENATED MODULE: ./node_modules/reakit/node_modules/reakit-utils/es/hasFocus.js
* Checks if `element` has focus. Elements that are referenced by
* `aria-activedescendant` are also considered.
* import { hasFocus } from "reakit-utils";
* hasFocus(document.getElementById("id"));
function hasFocus(element) {
var activeElement = Object(getActiveElement["a" /* getActiveElement */])(element);
if (!activeElement) return false;
if (activeElement === element) return true;
var activeDescendant = activeElement.getAttribute("aria-activedescendant");
if (!activeDescendant) return false;
return activeDescendant === element.id;
// CONCATENATED MODULE: ./node_modules/reakit/node_modules/reakit-utils/es/ensureFocus.js
* Ensures `element` will receive focus if it's not already.
* import { ensureFocus } from "reakit-utils";
* ensureFocus(document.activeElement); // does nothing
* const element = document.querySelector("input");
* ensureFocus(element); // focuses element
* ensureFocus(element, { preventScroll: true }); // focuses element preventing scroll jump
* function isActive(el) {
* return el.dataset.active === "true";
* ensureFocus(document.querySelector("[data-active='true']"), { isActive }); // does nothing
* @returns {number} `requestAnimationFrame` call ID so it can be passed to `cancelAnimationFrame` if needed.
function ensureFocus(element, _temp) {
var _ref = _temp === void 0 ? {} : _temp,
preventScroll = _ref.preventScroll,
_ref$isActive = _ref.isActive,
isActive = _ref$isActive === void 0 ? hasFocus : _ref$isActive;
if (isActive(element)) return -1;
preventScroll: preventScroll
if (isActive(element)) return -1;
return requestAnimationFrame(function () {
preventScroll: preventScroll
/***/ (function(module, exports, __webpack_require__) {
Object.defineProperty(exports, "__esModule", {
exports['default'] = isSameDay;
var _moment = __webpack_require__("wy2R");
var _moment2 = _interopRequireDefault(_moment);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function isSameDay(a, b) {
if (!_moment2['default'].isMoment(a) || !_moment2['default'].isMoment(b)) return false;
// Compare least significant, most likely to change units first
// Moment's isSame clones moment inputs and is a tad slow
return a.date() === b.date() && a.month() === b.month() && a.year() === b.year();
/***/ (function(module, exports) {
module.exports = _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 _extends.apply(this, arguments);
module.exports = _extends;
/***/ (function(module, exports, __webpack_require__) {
Object.defineProperty(exports, "__esModule", {
exports['default'] = toISODateString;
var _moment = __webpack_require__("wy2R");
var _moment2 = _interopRequireDefault(_moment);
var _toMomentObject = __webpack_require__("WmS1");
var _toMomentObject2 = _interopRequireDefault(_toMomentObject);
var _constants = __webpack_require__("Fv1B");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
function toISODateString(date, currentFormat) {
var dateObj = _moment2['default'].isMoment(date) ? date : (0, _toMomentObject2['default'])(date, currentFormat);
if (!dateObj) return null;
return dateObj.format(_constants.ISO_FORMAT);
/***/ (function(module, __webpack_exports__, __webpack_require__) {
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return isUA; });
/* harmony import */ var _canUseDOM_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("PcbF");
* Checks if a given string exists in the user agent string.
if (!_canUseDOM_js__WEBPACK_IMPORTED_MODULE_0__[/* canUseDOM */ "a"]) return false;
return window.navigator.userAgent.indexOf(string) !== -1;