Edit File by line
/home/barbar84/www/wp-inclu.../js/dist
File: components.js
return;
[28500] Fix | Delete
}
[28501] Fix | Delete
[28502] Fix | Delete
if (selectedItems.length < previousSelectedItemsRef.current.length) {
[28503] Fix | Delete
var removedSelectedItem = previousSelectedItemsRef.current.find(function (item) {
[28504] Fix | Delete
return selectedItems.indexOf(item) < 0;
[28505] Fix | Delete
});
[28506] Fix | Delete
setStatus(getA11yRemovalMessage({
[28507] Fix | Delete
itemToString: itemToString,
[28508] Fix | Delete
resultCount: selectedItems.length,
[28509] Fix | Delete
removedSelectedItem: removedSelectedItem,
[28510] Fix | Delete
activeIndex: activeIndex,
[28511] Fix | Delete
activeSelectedItem: selectedItems[activeIndex]
[28512] Fix | Delete
}), environment.document);
[28513] Fix | Delete
}
[28514] Fix | Delete
[28515] Fix | Delete
previousSelectedItemsRef.current = selectedItems; // eslint-disable-next-line react-hooks/exhaustive-deps
[28516] Fix | Delete
}, [selectedItems.length]); // Sets focus on active item.
[28517] Fix | Delete
[28518] Fix | Delete
Object(external_React_["useEffect"])(function () {
[28519] Fix | Delete
if (isInitialMountRef.current) {
[28520] Fix | Delete
return;
[28521] Fix | Delete
}
[28522] Fix | Delete
[28523] Fix | Delete
if (activeIndex === -1 && dropdownRef.current) {
[28524] Fix | Delete
dropdownRef.current.focus();
[28525] Fix | Delete
} else if (selectedItemRefs.current[activeIndex]) {
[28526] Fix | Delete
selectedItemRefs.current[activeIndex].focus();
[28527] Fix | Delete
}
[28528] Fix | Delete
}, [activeIndex]);
[28529] Fix | Delete
useControlPropsValidator({
[28530] Fix | Delete
isInitialMount: isInitialMountRef.current,
[28531] Fix | Delete
props: props,
[28532] Fix | Delete
state: state
[28533] Fix | Delete
});
[28534] Fix | Delete
var setGetterPropCallInfo = useGetterPropsCalledChecker('getDropdownProps'); // Make initial ref false.
[28535] Fix | Delete
[28536] Fix | Delete
Object(external_React_["useEffect"])(function () {
[28537] Fix | Delete
isInitialMountRef.current = false;
[28538] Fix | Delete
}, []); // Event handler functions.
[28539] Fix | Delete
[28540] Fix | Delete
var selectedItemKeyDownHandlers = Object(external_React_["useMemo"])(function () {
[28541] Fix | Delete
var _ref;
[28542] Fix | Delete
[28543] Fix | Delete
return _ref = {}, _ref[keyNavigationPrevious] = function () {
[28544] Fix | Delete
dispatch({
[28545] Fix | Delete
type: SelectedItemKeyDownNavigationPrevious
[28546] Fix | Delete
});
[28547] Fix | Delete
}, _ref[keyNavigationNext] = function () {
[28548] Fix | Delete
dispatch({
[28549] Fix | Delete
type: SelectedItemKeyDownNavigationNext
[28550] Fix | Delete
});
[28551] Fix | Delete
}, _ref.Delete = function Delete() {
[28552] Fix | Delete
dispatch({
[28553] Fix | Delete
type: SelectedItemKeyDownDelete
[28554] Fix | Delete
});
[28555] Fix | Delete
}, _ref.Backspace = function Backspace() {
[28556] Fix | Delete
dispatch({
[28557] Fix | Delete
type: SelectedItemKeyDownBackspace
[28558] Fix | Delete
});
[28559] Fix | Delete
}, _ref;
[28560] Fix | Delete
}, [dispatch, keyNavigationNext, keyNavigationPrevious]);
[28561] Fix | Delete
var dropdownKeyDownHandlers = Object(external_React_["useMemo"])(function () {
[28562] Fix | Delete
var _ref2;
[28563] Fix | Delete
[28564] Fix | Delete
return _ref2 = {}, _ref2[keyNavigationPrevious] = function (event) {
[28565] Fix | Delete
if (isKeyDownOperationPermitted(event)) {
[28566] Fix | Delete
dispatch({
[28567] Fix | Delete
type: DropdownKeyDownNavigationPrevious
[28568] Fix | Delete
});
[28569] Fix | Delete
}
[28570] Fix | Delete
}, _ref2.Backspace = function Backspace(event) {
[28571] Fix | Delete
if (isKeyDownOperationPermitted(event)) {
[28572] Fix | Delete
dispatch({
[28573] Fix | Delete
type: DropdownKeyDownBackspace
[28574] Fix | Delete
});
[28575] Fix | Delete
}
[28576] Fix | Delete
}, _ref2;
[28577] Fix | Delete
}, [dispatch, keyNavigationPrevious]); // Getter props.
[28578] Fix | Delete
[28579] Fix | Delete
var getSelectedItemProps = Object(external_React_["useCallback"])(function (_temp) {
[28580] Fix | Delete
var _extends2;
[28581] Fix | Delete
[28582] Fix | Delete
var _ref3 = _temp === void 0 ? {} : _temp,
[28583] Fix | Delete
_ref3$refKey = _ref3.refKey,
[28584] Fix | Delete
refKey = _ref3$refKey === void 0 ? 'ref' : _ref3$refKey,
[28585] Fix | Delete
ref = _ref3.ref,
[28586] Fix | Delete
onClick = _ref3.onClick,
[28587] Fix | Delete
onKeyDown = _ref3.onKeyDown,
[28588] Fix | Delete
selectedItem = _ref3.selectedItem,
[28589] Fix | Delete
index = _ref3.index,
[28590] Fix | Delete
rest = objectWithoutPropertiesLoose_objectWithoutPropertiesLoose(_ref3, _excluded);
[28591] Fix | Delete
[28592] Fix | Delete
var latestState = latest.current.state;
[28593] Fix | Delete
var itemIndex = getItemIndex(index, selectedItem, latestState.selectedItems);
[28594] Fix | Delete
[28595] Fix | Delete
if (itemIndex < 0) {
[28596] Fix | Delete
throw new Error('Pass either selectedItem or index in getSelectedItemProps!');
[28597] Fix | Delete
}
[28598] Fix | Delete
[28599] Fix | Delete
var selectedItemHandleClick = function selectedItemHandleClick() {
[28600] Fix | Delete
dispatch({
[28601] Fix | Delete
type: SelectedItemClick,
[28602] Fix | Delete
index: index
[28603] Fix | Delete
});
[28604] Fix | Delete
};
[28605] Fix | Delete
[28606] Fix | Delete
var selectedItemHandleKeyDown = function selectedItemHandleKeyDown(event) {
[28607] Fix | Delete
var key = normalizeArrowKey(event);
[28608] Fix | Delete
[28609] Fix | Delete
if (key && selectedItemKeyDownHandlers[key]) {
[28610] Fix | Delete
selectedItemKeyDownHandlers[key](event);
[28611] Fix | Delete
}
[28612] Fix | Delete
};
[28613] Fix | Delete
[28614] Fix | Delete
return extends_extends((_extends2 = {}, _extends2[refKey] = handleRefs(ref, function (selectedItemNode) {
[28615] Fix | Delete
if (selectedItemNode) {
[28616] Fix | Delete
selectedItemRefs.current.push(selectedItemNode);
[28617] Fix | Delete
}
[28618] Fix | Delete
}), _extends2.tabIndex = index === latestState.activeIndex ? 0 : -1, _extends2.onClick = callAllEventHandlers(onClick, selectedItemHandleClick), _extends2.onKeyDown = callAllEventHandlers(onKeyDown, selectedItemHandleKeyDown), _extends2), rest);
[28619] Fix | Delete
}, [dispatch, latest, selectedItemKeyDownHandlers]);
[28620] Fix | Delete
var getDropdownProps = Object(external_React_["useCallback"])(function (_temp2, _temp3) {
[28621] Fix | Delete
var _extends3;
[28622] Fix | Delete
[28623] Fix | Delete
var _ref4 = _temp2 === void 0 ? {} : _temp2,
[28624] Fix | Delete
_ref4$refKey = _ref4.refKey,
[28625] Fix | Delete
refKey = _ref4$refKey === void 0 ? 'ref' : _ref4$refKey,
[28626] Fix | Delete
ref = _ref4.ref,
[28627] Fix | Delete
onKeyDown = _ref4.onKeyDown,
[28628] Fix | Delete
onClick = _ref4.onClick,
[28629] Fix | Delete
_ref4$preventKeyActio = _ref4.preventKeyAction,
[28630] Fix | Delete
preventKeyAction = _ref4$preventKeyActio === void 0 ? false : _ref4$preventKeyActio,
[28631] Fix | Delete
rest = objectWithoutPropertiesLoose_objectWithoutPropertiesLoose(_ref4, _excluded2);
[28632] Fix | Delete
[28633] Fix | Delete
var _ref5 = _temp3 === void 0 ? {} : _temp3,
[28634] Fix | Delete
_ref5$suppressRefErro = _ref5.suppressRefError,
[28635] Fix | Delete
suppressRefError = _ref5$suppressRefErro === void 0 ? false : _ref5$suppressRefErro;
[28636] Fix | Delete
[28637] Fix | Delete
setGetterPropCallInfo('getDropdownProps', suppressRefError, refKey, dropdownRef);
[28638] Fix | Delete
[28639] Fix | Delete
var dropdownHandleKeyDown = function dropdownHandleKeyDown(event) {
[28640] Fix | Delete
var key = normalizeArrowKey(event);
[28641] Fix | Delete
[28642] Fix | Delete
if (key && dropdownKeyDownHandlers[key]) {
[28643] Fix | Delete
dropdownKeyDownHandlers[key](event);
[28644] Fix | Delete
}
[28645] Fix | Delete
};
[28646] Fix | Delete
[28647] Fix | Delete
var dropdownHandleClick = function dropdownHandleClick() {
[28648] Fix | Delete
dispatch({
[28649] Fix | Delete
type: DropdownClick
[28650] Fix | Delete
});
[28651] Fix | Delete
};
[28652] Fix | Delete
[28653] Fix | Delete
return extends_extends((_extends3 = {}, _extends3[refKey] = handleRefs(ref, function (dropdownNode) {
[28654] Fix | Delete
if (dropdownNode) {
[28655] Fix | Delete
dropdownRef.current = dropdownNode;
[28656] Fix | Delete
}
[28657] Fix | Delete
}), _extends3), !preventKeyAction && {
[28658] Fix | Delete
onKeyDown: callAllEventHandlers(onKeyDown, dropdownHandleKeyDown),
[28659] Fix | Delete
onClick: callAllEventHandlers(onClick, dropdownHandleClick)
[28660] Fix | Delete
}, rest);
[28661] Fix | Delete
}, [dispatch, dropdownKeyDownHandlers, setGetterPropCallInfo]); // returns
[28662] Fix | Delete
[28663] Fix | Delete
var addSelectedItem = Object(external_React_["useCallback"])(function (selectedItem) {
[28664] Fix | Delete
dispatch({
[28665] Fix | Delete
type: FunctionAddSelectedItem,
[28666] Fix | Delete
selectedItem: selectedItem
[28667] Fix | Delete
});
[28668] Fix | Delete
}, [dispatch]);
[28669] Fix | Delete
var removeSelectedItem = Object(external_React_["useCallback"])(function (selectedItem) {
[28670] Fix | Delete
dispatch({
[28671] Fix | Delete
type: FunctionRemoveSelectedItem,
[28672] Fix | Delete
selectedItem: selectedItem
[28673] Fix | Delete
});
[28674] Fix | Delete
}, [dispatch]);
[28675] Fix | Delete
var setSelectedItems = Object(external_React_["useCallback"])(function (newSelectedItems) {
[28676] Fix | Delete
dispatch({
[28677] Fix | Delete
type: FunctionSetSelectedItems,
[28678] Fix | Delete
selectedItems: newSelectedItems
[28679] Fix | Delete
});
[28680] Fix | Delete
}, [dispatch]);
[28681] Fix | Delete
var setActiveIndex = Object(external_React_["useCallback"])(function (newActiveIndex) {
[28682] Fix | Delete
dispatch({
[28683] Fix | Delete
type: FunctionSetActiveIndex,
[28684] Fix | Delete
activeIndex: newActiveIndex
[28685] Fix | Delete
});
[28686] Fix | Delete
}, [dispatch]);
[28687] Fix | Delete
var reset = Object(external_React_["useCallback"])(function () {
[28688] Fix | Delete
dispatch({
[28689] Fix | Delete
type: FunctionReset
[28690] Fix | Delete
});
[28691] Fix | Delete
}, [dispatch]);
[28692] Fix | Delete
return {
[28693] Fix | Delete
getSelectedItemProps: getSelectedItemProps,
[28694] Fix | Delete
getDropdownProps: getDropdownProps,
[28695] Fix | Delete
addSelectedItem: addSelectedItem,
[28696] Fix | Delete
removeSelectedItem: removeSelectedItem,
[28697] Fix | Delete
setSelectedItems: setSelectedItems,
[28698] Fix | Delete
setActiveIndex: setActiveIndex,
[28699] Fix | Delete
reset: reset,
[28700] Fix | Delete
selectedItems: selectedItems,
[28701] Fix | Delete
activeIndex: activeIndex
[28702] Fix | Delete
};
[28703] Fix | Delete
}
[28704] Fix | Delete
[28705] Fix | Delete
[28706] Fix | Delete
[28707] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/custom-select-control/index.js
[28708] Fix | Delete
[28709] Fix | Delete
[28710] Fix | Delete
[28711] Fix | Delete
/**
[28712] Fix | Delete
* External dependencies
[28713] Fix | Delete
*/
[28714] Fix | Delete
[28715] Fix | Delete
[28716] Fix | Delete
/**
[28717] Fix | Delete
* WordPress dependencies
[28718] Fix | Delete
*/
[28719] Fix | Delete
[28720] Fix | Delete
[28721] Fix | Delete
/**
[28722] Fix | Delete
* Internal dependencies
[28723] Fix | Delete
*/
[28724] Fix | Delete
[28725] Fix | Delete
[28726] Fix | Delete
[28727] Fix | Delete
var custom_select_control_itemToString = function itemToString(item) {
[28728] Fix | Delete
return item && item.name;
[28729] Fix | Delete
}; // This is needed so that in Windows, where
[28730] Fix | Delete
// the menu does not necessarily open on
[28731] Fix | Delete
// key up/down, you can still switch between
[28732] Fix | Delete
// options with the menu closed.
[28733] Fix | Delete
[28734] Fix | Delete
[28735] Fix | Delete
var custom_select_control_stateReducer = function stateReducer(_ref, _ref2) {
[28736] Fix | Delete
var selectedItem = _ref.selectedItem;
[28737] Fix | Delete
var type = _ref2.type,
[28738] Fix | Delete
changes = _ref2.changes,
[28739] Fix | Delete
items = _ref2.props.items;
[28740] Fix | Delete
[28741] Fix | Delete
switch (type) {
[28742] Fix | Delete
case useSelect.stateChangeTypes.ToggleButtonKeyDownArrowDown:
[28743] Fix | Delete
// If we already have a selected item, try to select the next one,
[28744] Fix | Delete
// without circular navigation. Otherwise, select the first item.
[28745] Fix | Delete
return {
[28746] Fix | Delete
selectedItem: items[selectedItem ? Math.min(items.indexOf(selectedItem) + 1, items.length - 1) : 0]
[28747] Fix | Delete
};
[28748] Fix | Delete
[28749] Fix | Delete
case useSelect.stateChangeTypes.ToggleButtonKeyDownArrowUp:
[28750] Fix | Delete
// If we already have a selected item, try to select the previous one,
[28751] Fix | Delete
// without circular navigation. Otherwise, select the last item.
[28752] Fix | Delete
return {
[28753] Fix | Delete
selectedItem: items[selectedItem ? Math.max(items.indexOf(selectedItem) - 1, 0) : items.length - 1]
[28754] Fix | Delete
};
[28755] Fix | Delete
[28756] Fix | Delete
default:
[28757] Fix | Delete
return changes;
[28758] Fix | Delete
}
[28759] Fix | Delete
};
[28760] Fix | Delete
[28761] Fix | Delete
function CustomSelectControl(_ref3) {
[28762] Fix | Delete
var className = _ref3.className,
[28763] Fix | Delete
hideLabelFromVision = _ref3.hideLabelFromVision,
[28764] Fix | Delete
label = _ref3.label,
[28765] Fix | Delete
items = _ref3.options,
[28766] Fix | Delete
onSelectedItemChange = _ref3.onChange,
[28767] Fix | Delete
_selectedItem = _ref3.value;
[28768] Fix | Delete
[28769] Fix | Delete
var _useSelect = useSelect({
[28770] Fix | Delete
initialSelectedItem: items[0],
[28771] Fix | Delete
items: items,
[28772] Fix | Delete
itemToString: custom_select_control_itemToString,
[28773] Fix | Delete
onSelectedItemChange: onSelectedItemChange,
[28774] Fix | Delete
selectedItem: _selectedItem,
[28775] Fix | Delete
stateReducer: custom_select_control_stateReducer
[28776] Fix | Delete
}),
[28777] Fix | Delete
getLabelProps = _useSelect.getLabelProps,
[28778] Fix | Delete
getToggleButtonProps = _useSelect.getToggleButtonProps,
[28779] Fix | Delete
getMenuProps = _useSelect.getMenuProps,
[28780] Fix | Delete
getItemProps = _useSelect.getItemProps,
[28781] Fix | Delete
isOpen = _useSelect.isOpen,
[28782] Fix | Delete
highlightedIndex = _useSelect.highlightedIndex,
[28783] Fix | Delete
selectedItem = _useSelect.selectedItem;
[28784] Fix | Delete
[28785] Fix | Delete
var menuProps = getMenuProps({
[28786] Fix | Delete
className: 'components-custom-select-control__menu',
[28787] Fix | Delete
'aria-hidden': !isOpen
[28788] Fix | Delete
}); // We need this here, because the null active descendant is not
[28789] Fix | Delete
// fully ARIA compliant.
[28790] Fix | Delete
[28791] Fix | Delete
if (menuProps['aria-activedescendant'] && menuProps['aria-activedescendant'].slice(0, 'downshift-null'.length) === 'downshift-null') {
[28792] Fix | Delete
delete menuProps['aria-activedescendant'];
[28793] Fix | Delete
}
[28794] Fix | Delete
[28795] Fix | Delete
return Object(external_wp_element_["createElement"])("div", {
[28796] Fix | Delete
className: classnames_default()('components-custom-select-control', className)
[28797] Fix | Delete
}, hideLabelFromVision ? Object(external_wp_element_["createElement"])(visually_hidden["a" /* default */], Object(esm_extends["a" /* default */])({
[28798] Fix | Delete
as: "label"
[28799] Fix | Delete
}, getLabelProps()), label) :
[28800] Fix | Delete
/* eslint-disable-next-line jsx-a11y/label-has-associated-control, jsx-a11y/label-has-for */
[28801] Fix | Delete
Object(external_wp_element_["createElement"])("label", getLabelProps({
[28802] Fix | Delete
className: 'components-custom-select-control__label'
[28803] Fix | Delete
}), label), Object(external_wp_element_["createElement"])(build_module_button["a" /* default */], getToggleButtonProps({
[28804] Fix | Delete
// This is needed because some speech recognition software don't support `aria-labelledby`.
[28805] Fix | Delete
'aria-label': label,
[28806] Fix | Delete
'aria-labelledby': undefined,
[28807] Fix | Delete
className: 'components-custom-select-control__button',
[28808] Fix | Delete
isSmall: true
[28809] Fix | Delete
}), custom_select_control_itemToString(selectedItem), Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
[28810] Fix | Delete
icon: chevron_down["a" /* default */],
[28811] Fix | Delete
className: "components-custom-select-control__button-icon"
[28812] Fix | Delete
})), Object(external_wp_element_["createElement"])("ul", menuProps, isOpen && items.map(function (item, index) {
[28813] Fix | Delete
return (// eslint-disable-next-line react/jsx-key
[28814] Fix | Delete
Object(external_wp_element_["createElement"])("li", getItemProps({
[28815] Fix | Delete
item: item,
[28816] Fix | Delete
index: index,
[28817] Fix | Delete
key: item.key,
[28818] Fix | Delete
className: classnames_default()(item.className, 'components-custom-select-control__item', {
[28819] Fix | Delete
'is-highlighted': index === highlightedIndex
[28820] Fix | Delete
}),
[28821] Fix | Delete
style: item.style
[28822] Fix | Delete
}), item.name, item === selectedItem && Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
[28823] Fix | Delete
icon: check["a" /* default */],
[28824] Fix | Delete
className: "components-custom-select-control__item-icon"
[28825] Fix | Delete
}))
[28826] Fix | Delete
);
[28827] Fix | Delete
})));
[28828] Fix | Delete
}
[28829] Fix | Delete
[28830] Fix | Delete
// EXTERNAL MODULE: ./node_modules/@wordpress/components/build-module/dashicon/index.js
[28831] Fix | Delete
var dashicon = __webpack_require__("vUUf");
[28832] Fix | Delete
[28833] Fix | Delete
// EXTERNAL MODULE: ./node_modules/react-dates/initialize.js
[28834] Fix | Delete
var initialize = __webpack_require__("GG7f");
[28835] Fix | Delete
[28836] Fix | Delete
// EXTERNAL MODULE: external "moment"
[28837] Fix | Delete
var external_moment_ = __webpack_require__("wy2R");
[28838] Fix | Delete
var external_moment_default = /*#__PURE__*/__webpack_require__.n(external_moment_);
[28839] Fix | Delete
[28840] Fix | Delete
// EXTERNAL MODULE: ./node_modules/react-dates/lib/components/DayPickerSingleDateController.js
[28841] Fix | Delete
var DayPickerSingleDateController = __webpack_require__("Xtko");
[28842] Fix | Delete
var DayPickerSingleDateController_default = /*#__PURE__*/__webpack_require__.n(DayPickerSingleDateController);
[28843] Fix | Delete
[28844] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/date-time/date.js
[28845] Fix | Delete
[28846] Fix | Delete
[28847] Fix | Delete
[28848] Fix | Delete
[28849] Fix | Delete
[28850] Fix | Delete
[28851] Fix | Delete
[28852] Fix | Delete
[28853] Fix | Delete
function date_createSuper(Derived) { var hasNativeReflectConstruct = date_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; }
[28854] Fix | Delete
[28855] Fix | Delete
function date_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
[28856] Fix | Delete
[28857] Fix | Delete
/**
[28858] Fix | Delete
* External dependencies
[28859] Fix | Delete
*/
[28860] Fix | Delete
// react-dates doesn't tree-shake correctly, so we import from the individual
[28861] Fix | Delete
// component here, to avoid including too much of the library
[28862] Fix | Delete
[28863] Fix | Delete
[28864] Fix | Delete
/**
[28865] Fix | Delete
* WordPress dependencies
[28866] Fix | Delete
*/
[28867] Fix | Delete
[28868] Fix | Delete
[28869] Fix | Delete
[28870] Fix | Delete
/**
[28871] Fix | Delete
* Module Constants
[28872] Fix | Delete
*/
[28873] Fix | Delete
[28874] Fix | Delete
var TIMEZONELESS_FORMAT = 'YYYY-MM-DDTHH:mm:ss';
[28875] Fix | Delete
[28876] Fix | Delete
var date_DatePicker = /*#__PURE__*/function (_Component) {
[28877] Fix | Delete
Object(inherits["a" /* default */])(DatePicker, _Component);
[28878] Fix | Delete
[28879] Fix | Delete
var _super = date_createSuper(DatePicker);
[28880] Fix | Delete
[28881] Fix | Delete
function DatePicker() {
[28882] Fix | Delete
var _this;
[28883] Fix | Delete
[28884] Fix | Delete
Object(classCallCheck["a" /* default */])(this, DatePicker);
[28885] Fix | Delete
[28886] Fix | Delete
_this = _super.apply(this, arguments);
[28887] Fix | Delete
_this.onChangeMoment = _this.onChangeMoment.bind(Object(assertThisInitialized["a" /* default */])(_this));
[28888] Fix | Delete
_this.nodeRef = Object(external_wp_element_["createRef"])();
[28889] Fix | Delete
_this.keepFocusInside = _this.keepFocusInside.bind(Object(assertThisInitialized["a" /* default */])(_this));
[28890] Fix | Delete
_this.isDayHighlighted = _this.isDayHighlighted.bind(Object(assertThisInitialized["a" /* default */])(_this));
[28891] Fix | Delete
return _this;
[28892] Fix | Delete
}
[28893] Fix | Delete
/*
[28894] Fix | Delete
* Todo: We should remove this function ASAP.
[28895] Fix | Delete
* It is kept because focus is lost when we click on the previous and next month buttons.
[28896] Fix | Delete
* This focus loss closes the date picker popover.
[28897] Fix | Delete
* Ideally we should add an upstream commit on react-dates to fix this issue.
[28898] Fix | Delete
*/
[28899] Fix | Delete
[28900] Fix | Delete
[28901] Fix | Delete
Object(createClass["a" /* default */])(DatePicker, [{
[28902] Fix | Delete
key: "keepFocusInside",
[28903] Fix | Delete
value: function keepFocusInside() {
[28904] Fix | Delete
if (!this.nodeRef.current) {
[28905] Fix | Delete
return;
[28906] Fix | Delete
}
[28907] Fix | Delete
[28908] Fix | Delete
var ownerDocument = this.nodeRef.current.ownerDocument;
[28909] Fix | Delete
var activeElement = ownerDocument.activeElement; // If focus was lost.
[28910] Fix | Delete
[28911] Fix | Delete
if (!activeElement || !this.nodeRef.current.contains(ownerDocument.activeElement)) {
[28912] Fix | Delete
// Retrieve the focus region div.
[28913] Fix | Delete
var focusRegion = this.nodeRef.current.querySelector('.DayPicker_focusRegion');
[28914] Fix | Delete
[28915] Fix | Delete
if (!focusRegion) {
[28916] Fix | Delete
return;
[28917] Fix | Delete
} // Keep the focus on focus region.
[28918] Fix | Delete
[28919] Fix | Delete
[28920] Fix | Delete
focusRegion.focus();
[28921] Fix | Delete
}
[28922] Fix | Delete
}
[28923] Fix | Delete
}, {
[28924] Fix | Delete
key: "onChangeMoment",
[28925] Fix | Delete
value: function onChangeMoment(newDate) {
[28926] Fix | Delete
var _this$props = this.props,
[28927] Fix | Delete
currentDate = _this$props.currentDate,
[28928] Fix | Delete
onChange = _this$props.onChange; // If currentDate is null, use now as momentTime to designate hours, minutes, seconds.
[28929] Fix | Delete
[28930] Fix | Delete
var momentDate = currentDate ? external_moment_default()(currentDate) : external_moment_default()();
[28931] Fix | Delete
var momentTime = {
[28932] Fix | Delete
hours: momentDate.hours(),
[28933] Fix | Delete
minutes: momentDate.minutes(),
[28934] Fix | Delete
seconds: 0
[28935] Fix | Delete
};
[28936] Fix | Delete
onChange(newDate.set(momentTime).format(TIMEZONELESS_FORMAT));
[28937] Fix | Delete
}
[28938] Fix | Delete
/**
[28939] Fix | Delete
* Create a Moment object from a date string. With no currentDate supplied, default to a Moment
[28940] Fix | Delete
* object representing now. If a null value is passed, return a null value.
[28941] Fix | Delete
*
[28942] Fix | Delete
* @param {?string} currentDate Date representing the currently selected date or null to signify no selection.
[28943] Fix | Delete
* @return {?moment.Moment} Moment object for selected date or null.
[28944] Fix | Delete
*/
[28945] Fix | Delete
[28946] Fix | Delete
}, {
[28947] Fix | Delete
key: "getMomentDate",
[28948] Fix | Delete
value: function getMomentDate(currentDate) {
[28949] Fix | Delete
if (null === currentDate) {
[28950] Fix | Delete
return null;
[28951] Fix | Delete
}
[28952] Fix | Delete
[28953] Fix | Delete
return currentDate ? external_moment_default()(currentDate) : external_moment_default()();
[28954] Fix | Delete
} // todo change reference to `isDayHighlighted` every time, `events` prop change
[28955] Fix | Delete
[28956] Fix | Delete
}, {
[28957] Fix | Delete
key: "isDayHighlighted",
[28958] Fix | Delete
value: function isDayHighlighted(date) {
[28959] Fix | Delete
var _this$props$events;
[28960] Fix | Delete
[28961] Fix | Delete
// Do not highlight when no events.
[28962] Fix | Delete
if (!((_this$props$events = this.props.events) !== null && _this$props$events !== void 0 && _this$props$events.length)) {
[28963] Fix | Delete
return false;
[28964] Fix | Delete
}
[28965] Fix | Delete
[28966] Fix | Delete
if (this.props.onMonthPreviewed) {
[28967] Fix | Delete
this.props.onMonthPreviewed(date.toDate());
[28968] Fix | Delete
} // Compare date against highlighted events.
[28969] Fix | Delete
[28970] Fix | Delete
[28971] Fix | Delete
return this.props.events.some(function (highlighted) {
[28972] Fix | Delete
return date.isSame(highlighted.date, 'day');
[28973] Fix | Delete
});
[28974] Fix | Delete
}
[28975] Fix | Delete
}, {
[28976] Fix | Delete
key: "render",
[28977] Fix | Delete
value: function render() {
[28978] Fix | Delete
var _this$props2 = this.props,
[28979] Fix | Delete
currentDate = _this$props2.currentDate,
[28980] Fix | Delete
isInvalidDate = _this$props2.isInvalidDate;
[28981] Fix | Delete
var momentDate = this.getMomentDate(currentDate);
[28982] Fix | Delete
return Object(external_wp_element_["createElement"])("div", {
[28983] Fix | Delete
className: "components-datetime__date",
[28984] Fix | Delete
ref: this.nodeRef
[28985] Fix | Delete
}, Object(external_wp_element_["createElement"])(DayPickerSingleDateController_default.a, {
[28986] Fix | Delete
date: momentDate,
[28987] Fix | Delete
daySize: 30,
[28988] Fix | Delete
focused: true,
[28989] Fix | Delete
hideKeyboardShortcutsPanel: true // This is a hack to force the calendar to update on month or year change
[28990] Fix | Delete
// https://github.com/airbnb/react-dates/issues/240#issuecomment-361776665
[28991] Fix | Delete
,
[28992] Fix | Delete
key: "datepicker-controller-".concat(momentDate ? momentDate.format('MM-YYYY') : 'null'),
[28993] Fix | Delete
noBorder: true,
[28994] Fix | Delete
numberOfMonths: 1,
[28995] Fix | Delete
onDateChange: this.onChangeMoment,
[28996] Fix | Delete
transitionDuration: 0,
[28997] Fix | Delete
weekDayFormat: "ddd",
[28998] Fix | Delete
isRTL: Object(external_wp_i18n_["isRTL"])(),
[28999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function