Edit File by line
/home/barbar84/www/wp-inclu.../js/dist
File: components.js
inputValue: inputValue,
[26000] Fix | Delete
isOpen: isOpen,
[26001] Fix | Delete
selectedItem: selectedItem
[26002] Fix | Delete
};
[26003] Fix | Delete
} //////////////////////////// ROOT
[26004] Fix | Delete
;
[26005] Fix | Delete
[26006] Fix | Delete
_proto.componentDidMount = function componentDidMount() {
[26007] Fix | Delete
var _this7 = this;
[26008] Fix | Delete
[26009] Fix | Delete
/* istanbul ignore if (react-native) */
[26010] Fix | Delete
if (false) {}
[26011] Fix | Delete
/* istanbul ignore if (react-native) */
[26012] Fix | Delete
[26013] Fix | Delete
[26014] Fix | Delete
{
[26015] Fix | Delete
// this.isMouseDown helps us track whether the mouse is currently held down.
[26016] Fix | Delete
// This is useful when the user clicks on an item in the list, but holds the mouse
[26017] Fix | Delete
// down long enough for the list to disappear (because the blur event fires on the input)
[26018] Fix | Delete
// this.isMouseDown is used in the blur handler on the input to determine whether the blur event should
[26019] Fix | Delete
// trigger hiding the menu.
[26020] Fix | Delete
var onMouseDown = function onMouseDown() {
[26021] Fix | Delete
_this7.isMouseDown = true;
[26022] Fix | Delete
};
[26023] Fix | Delete
[26024] Fix | Delete
var onMouseUp = function onMouseUp(event) {
[26025] Fix | Delete
_this7.isMouseDown = false; // if the target element or the activeElement is within a downshift node
[26026] Fix | Delete
// then we don't want to reset downshift
[26027] Fix | Delete
[26028] Fix | Delete
var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment);
[26029] Fix | Delete
[26030] Fix | Delete
if (!contextWithinDownshift && _this7.getState().isOpen) {
[26031] Fix | Delete
_this7.reset({
[26032] Fix | Delete
type: mouseUp
[26033] Fix | Delete
}, function () {
[26034] Fix | Delete
return _this7.props.onOuterClick(_this7.getStateAndHelpers());
[26035] Fix | Delete
});
[26036] Fix | Delete
}
[26037] Fix | Delete
}; // Touching an element in iOS gives focus and hover states, but touching out of
[26038] Fix | Delete
// the element will remove hover, and persist the focus state, resulting in the
[26039] Fix | Delete
// blur event not being triggered.
[26040] Fix | Delete
// this.isTouchMove helps us track whether the user is tapping or swiping on a touch screen.
[26041] Fix | Delete
// If the user taps outside of Downshift, the component should be reset,
[26042] Fix | Delete
// but not if the user is swiping
[26043] Fix | Delete
[26044] Fix | Delete
[26045] Fix | Delete
var onTouchStart = function onTouchStart() {
[26046] Fix | Delete
_this7.isTouchMove = false;
[26047] Fix | Delete
};
[26048] Fix | Delete
[26049] Fix | Delete
var onTouchMove = function onTouchMove() {
[26050] Fix | Delete
_this7.isTouchMove = true;
[26051] Fix | Delete
};
[26052] Fix | Delete
[26053] Fix | Delete
var onTouchEnd = function onTouchEnd(event) {
[26054] Fix | Delete
var contextWithinDownshift = targetWithinDownshift(event.target, [_this7._rootNode, _this7._menuNode], _this7.props.environment, false);
[26055] Fix | Delete
[26056] Fix | Delete
if (!_this7.isTouchMove && !contextWithinDownshift && _this7.getState().isOpen) {
[26057] Fix | Delete
_this7.reset({
[26058] Fix | Delete
type: touchEnd
[26059] Fix | Delete
}, function () {
[26060] Fix | Delete
return _this7.props.onOuterClick(_this7.getStateAndHelpers());
[26061] Fix | Delete
});
[26062] Fix | Delete
}
[26063] Fix | Delete
};
[26064] Fix | Delete
[26065] Fix | Delete
var environment = this.props.environment;
[26066] Fix | Delete
environment.addEventListener('mousedown', onMouseDown);
[26067] Fix | Delete
environment.addEventListener('mouseup', onMouseUp);
[26068] Fix | Delete
environment.addEventListener('touchstart', onTouchStart);
[26069] Fix | Delete
environment.addEventListener('touchmove', onTouchMove);
[26070] Fix | Delete
environment.addEventListener('touchend', onTouchEnd);
[26071] Fix | Delete
[26072] Fix | Delete
this.cleanup = function () {
[26073] Fix | Delete
_this7.internalClearTimeouts();
[26074] Fix | Delete
[26075] Fix | Delete
_this7.updateStatus.cancel();
[26076] Fix | Delete
[26077] Fix | Delete
environment.removeEventListener('mousedown', onMouseDown);
[26078] Fix | Delete
environment.removeEventListener('mouseup', onMouseUp);
[26079] Fix | Delete
environment.removeEventListener('touchstart', onTouchStart);
[26080] Fix | Delete
environment.removeEventListener('touchmove', onTouchMove);
[26081] Fix | Delete
environment.removeEventListener('touchend', onTouchEnd);
[26082] Fix | Delete
};
[26083] Fix | Delete
}
[26084] Fix | Delete
};
[26085] Fix | Delete
[26086] Fix | Delete
_proto.shouldScroll = function shouldScroll(prevState, prevProps) {
[26087] Fix | Delete
var _ref10 = this.props.highlightedIndex === undefined ? this.getState() : this.props,
[26088] Fix | Delete
currentHighlightedIndex = _ref10.highlightedIndex;
[26089] Fix | Delete
[26090] Fix | Delete
var _ref11 = prevProps.highlightedIndex === undefined ? prevState : prevProps,
[26091] Fix | Delete
prevHighlightedIndex = _ref11.highlightedIndex;
[26092] Fix | Delete
[26093] Fix | Delete
var scrollWhenOpen = currentHighlightedIndex && this.getState().isOpen && !prevState.isOpen;
[26094] Fix | Delete
var scrollWhenNavigating = currentHighlightedIndex !== prevHighlightedIndex;
[26095] Fix | Delete
return scrollWhenOpen || scrollWhenNavigating;
[26096] Fix | Delete
};
[26097] Fix | Delete
[26098] Fix | Delete
_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
[26099] Fix | Delete
if (false) {}
[26100] Fix | Delete
[26101] Fix | Delete
if (isControlledProp(this.props, 'selectedItem') && this.props.selectedItemChanged(prevProps.selectedItem, this.props.selectedItem)) {
[26102] Fix | Delete
this.internalSetState({
[26103] Fix | Delete
type: controlledPropUpdatedSelectedItem,
[26104] Fix | Delete
inputValue: this.props.itemToString(this.props.selectedItem)
[26105] Fix | Delete
});
[26106] Fix | Delete
}
[26107] Fix | Delete
[26108] Fix | Delete
if (!this.avoidScrolling && this.shouldScroll(prevState, prevProps)) {
[26109] Fix | Delete
this.scrollHighlightedItemIntoView();
[26110] Fix | Delete
}
[26111] Fix | Delete
/* istanbul ignore else (react-native) */
[26112] Fix | Delete
[26113] Fix | Delete
[26114] Fix | Delete
{
[26115] Fix | Delete
this.updateStatus();
[26116] Fix | Delete
}
[26117] Fix | Delete
};
[26118] Fix | Delete
[26119] Fix | Delete
_proto.componentWillUnmount = function componentWillUnmount() {
[26120] Fix | Delete
this.cleanup(); // avoids memory leak
[26121] Fix | Delete
};
[26122] Fix | Delete
[26123] Fix | Delete
_proto.render = function render() {
[26124] Fix | Delete
var children = unwrapArray(this.props.children, downshift_esm_noop); // because the items are rerendered every time we call the children
[26125] Fix | Delete
// we clear this out each render and it will be populated again as
[26126] Fix | Delete
// getItemProps is called.
[26127] Fix | Delete
[26128] Fix | Delete
this.clearItems(); // we reset this so we know whether the user calls getRootProps during
[26129] Fix | Delete
// this render. If they do then we don't need to do anything,
[26130] Fix | Delete
// if they don't then we need to clone the element they return and
[26131] Fix | Delete
// apply the props for them.
[26132] Fix | Delete
[26133] Fix | Delete
this.getRootProps.called = false;
[26134] Fix | Delete
this.getRootProps.refKey = undefined;
[26135] Fix | Delete
this.getRootProps.suppressRefError = undefined; // we do something similar for getMenuProps
[26136] Fix | Delete
[26137] Fix | Delete
this.getMenuProps.called = false;
[26138] Fix | Delete
this.getMenuProps.refKey = undefined;
[26139] Fix | Delete
this.getMenuProps.suppressRefError = undefined; // we do something similar for getLabelProps
[26140] Fix | Delete
[26141] Fix | Delete
this.getLabelProps.called = false; // and something similar for getInputProps
[26142] Fix | Delete
[26143] Fix | Delete
this.getInputProps.called = false;
[26144] Fix | Delete
var element = unwrapArray(children(this.getStateAndHelpers()));
[26145] Fix | Delete
[26146] Fix | Delete
if (!element) {
[26147] Fix | Delete
return null;
[26148] Fix | Delete
}
[26149] Fix | Delete
[26150] Fix | Delete
if (this.getRootProps.called || this.props.suppressRefError) {
[26151] Fix | Delete
if (false) {}
[26152] Fix | Delete
[26153] Fix | Delete
return element;
[26154] Fix | Delete
} else if (isDOMElement(element)) {
[26155] Fix | Delete
// they didn't apply the root props, but we can clone
[26156] Fix | Delete
// this and apply the props ourselves
[26157] Fix | Delete
return /*#__PURE__*/Object(external_React_["cloneElement"])(element, this.getRootProps(getElementProps(element)));
[26158] Fix | Delete
}
[26159] Fix | Delete
/* istanbul ignore else */
[26160] Fix | Delete
[26161] Fix | Delete
[26162] Fix | Delete
if (false) {}
[26163] Fix | Delete
/* istanbul ignore next */
[26164] Fix | Delete
[26165] Fix | Delete
[26166] Fix | Delete
return undefined;
[26167] Fix | Delete
};
[26168] Fix | Delete
[26169] Fix | Delete
return Downshift;
[26170] Fix | Delete
}(external_React_["Component"]);
[26171] Fix | Delete
[26172] Fix | Delete
Downshift.defaultProps = {
[26173] Fix | Delete
defaultHighlightedIndex: null,
[26174] Fix | Delete
defaultIsOpen: false,
[26175] Fix | Delete
getA11yStatusMessage: getA11yStatusMessage$1,
[26176] Fix | Delete
itemToString: function itemToString(i) {
[26177] Fix | Delete
if (i == null) {
[26178] Fix | Delete
return '';
[26179] Fix | Delete
}
[26180] Fix | Delete
[26181] Fix | Delete
if (false) {}
[26182] Fix | Delete
[26183] Fix | Delete
return String(i);
[26184] Fix | Delete
},
[26185] Fix | Delete
onStateChange: downshift_esm_noop,
[26186] Fix | Delete
onInputValueChange: downshift_esm_noop,
[26187] Fix | Delete
onUserAction: downshift_esm_noop,
[26188] Fix | Delete
onChange: downshift_esm_noop,
[26189] Fix | Delete
onSelect: downshift_esm_noop,
[26190] Fix | Delete
onOuterClick: downshift_esm_noop,
[26191] Fix | Delete
selectedItemChanged: function selectedItemChanged(prevItem, item) {
[26192] Fix | Delete
return prevItem !== item;
[26193] Fix | Delete
},
[26194] Fix | Delete
environment:
[26195] Fix | Delete
/* istanbul ignore next (ssr) */
[26196] Fix | Delete
typeof window === 'undefined' ? {} : window,
[26197] Fix | Delete
stateReducer: function stateReducer(state, stateToSet) {
[26198] Fix | Delete
return stateToSet;
[26199] Fix | Delete
},
[26200] Fix | Delete
suppressRefError: false,
[26201] Fix | Delete
scrollIntoView: downshift_esm_scrollIntoView
[26202] Fix | Delete
};
[26203] Fix | Delete
Downshift.stateChangeTypes = stateChangeTypes$3;
[26204] Fix | Delete
return Downshift;
[26205] Fix | Delete
}();
[26206] Fix | Delete
[26207] Fix | Delete
false ? undefined : void 0;
[26208] Fix | Delete
var Downshift$1 = downshift_esm_Downshift;
[26209] Fix | Delete
[26210] Fix | Delete
function validateGetMenuPropsCalledCorrectly(node, _ref12) {
[26211] Fix | Delete
var refKey = _ref12.refKey;
[26212] Fix | Delete
[26213] Fix | Delete
if (!node) {
[26214] Fix | Delete
// eslint-disable-next-line no-console
[26215] Fix | Delete
console.error("downshift: The ref prop \"" + refKey + "\" from getMenuProps was not applied correctly on your menu element.");
[26216] Fix | Delete
}
[26217] Fix | Delete
}
[26218] Fix | Delete
[26219] Fix | Delete
function validateGetRootPropsCalledCorrectly(element, _ref13) {
[26220] Fix | Delete
var refKey = _ref13.refKey;
[26221] Fix | Delete
var refKeySpecified = refKey !== 'ref';
[26222] Fix | Delete
var isComposite = !isDOMElement(element);
[26223] Fix | Delete
[26224] Fix | Delete
if (isComposite && !refKeySpecified && !Object(react_is["isForwardRef"])(element)) {
[26225] Fix | Delete
// eslint-disable-next-line no-console
[26226] Fix | Delete
console.error('downshift: You returned a non-DOM element. You must specify a refKey in getRootProps');
[26227] Fix | Delete
} else if (!isComposite && refKeySpecified) {
[26228] Fix | Delete
// eslint-disable-next-line no-console
[26229] Fix | Delete
console.error("downshift: You returned a DOM element. You should not specify a refKey in getRootProps. You specified \"" + refKey + "\"");
[26230] Fix | Delete
}
[26231] Fix | Delete
[26232] Fix | Delete
if (!Object(react_is["isForwardRef"])(element) && !getElementProps(element)[refKey]) {
[26233] Fix | Delete
// eslint-disable-next-line no-console
[26234] Fix | Delete
console.error("downshift: You must apply the ref prop \"" + refKey + "\" from getRootProps onto your root element.");
[26235] Fix | Delete
}
[26236] Fix | Delete
}
[26237] Fix | Delete
[26238] Fix | Delete
var _excluded$3 = ["isInitialMount", "highlightedIndex", "items", "environment"];
[26239] Fix | Delete
var dropdownDefaultStateValues = {
[26240] Fix | Delete
highlightedIndex: -1,
[26241] Fix | Delete
isOpen: false,
[26242] Fix | Delete
selectedItem: null,
[26243] Fix | Delete
inputValue: ''
[26244] Fix | Delete
};
[26245] Fix | Delete
[26246] Fix | Delete
function callOnChangeProps(action, state, newState) {
[26247] Fix | Delete
var props = action.props,
[26248] Fix | Delete
type = action.type;
[26249] Fix | Delete
var changes = {};
[26250] Fix | Delete
Object.keys(state).forEach(function (key) {
[26251] Fix | Delete
invokeOnChangeHandler(key, action, state, newState);
[26252] Fix | Delete
[26253] Fix | Delete
if (newState[key] !== state[key]) {
[26254] Fix | Delete
changes[key] = newState[key];
[26255] Fix | Delete
}
[26256] Fix | Delete
});
[26257] Fix | Delete
[26258] Fix | Delete
if (props.onStateChange && Object.keys(changes).length) {
[26259] Fix | Delete
props.onStateChange(extends_extends({
[26260] Fix | Delete
type: type
[26261] Fix | Delete
}, changes));
[26262] Fix | Delete
}
[26263] Fix | Delete
}
[26264] Fix | Delete
[26265] Fix | Delete
function invokeOnChangeHandler(key, action, state, newState) {
[26266] Fix | Delete
var props = action.props,
[26267] Fix | Delete
type = action.type;
[26268] Fix | Delete
var handler = "on" + capitalizeString(key) + "Change";
[26269] Fix | Delete
[26270] Fix | Delete
if (props[handler] && newState[key] !== undefined && newState[key] !== state[key]) {
[26271] Fix | Delete
props[handler](extends_extends({
[26272] Fix | Delete
type: type
[26273] Fix | Delete
}, newState));
[26274] Fix | Delete
}
[26275] Fix | Delete
}
[26276] Fix | Delete
/**
[26277] Fix | Delete
* Default state reducer that returns the changes.
[26278] Fix | Delete
*
[26279] Fix | Delete
* @param {Object} s state.
[26280] Fix | Delete
* @param {Object} a action with changes.
[26281] Fix | Delete
* @returns {Object} changes.
[26282] Fix | Delete
*/
[26283] Fix | Delete
[26284] Fix | Delete
[26285] Fix | Delete
function downshift_esm_stateReducer(s, a) {
[26286] Fix | Delete
return a.changes;
[26287] Fix | Delete
}
[26288] Fix | Delete
/**
[26289] Fix | Delete
* Returns a message to be added to aria-live region when item is selected.
[26290] Fix | Delete
*
[26291] Fix | Delete
* @param {Object} selectionParameters Parameters required to build the message.
[26292] Fix | Delete
* @returns {string} The a11y message.
[26293] Fix | Delete
*/
[26294] Fix | Delete
[26295] Fix | Delete
[26296] Fix | Delete
function downshift_esm_getA11ySelectionMessage(selectionParameters) {
[26297] Fix | Delete
var selectedItem = selectionParameters.selectedItem,
[26298] Fix | Delete
itemToStringLocal = selectionParameters.itemToString;
[26299] Fix | Delete
return selectedItem ? itemToStringLocal(selectedItem) + " has been selected." : '';
[26300] Fix | Delete
}
[26301] Fix | Delete
/**
[26302] Fix | Delete
* Debounced call for updating the a11y message.
[26303] Fix | Delete
*/
[26304] Fix | Delete
[26305] Fix | Delete
[26306] Fix | Delete
var updateA11yStatus = debounce(function (getA11yMessage, document) {
[26307] Fix | Delete
setStatus(getA11yMessage(), document);
[26308] Fix | Delete
}, 200); // istanbul ignore next
[26309] Fix | Delete
[26310] Fix | Delete
var useIsomorphicLayoutEffect = typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined' ? external_React_["useLayoutEffect"] : external_React_["useEffect"];
[26311] Fix | Delete
[26312] Fix | Delete
function useElementIds(_ref) {
[26313] Fix | Delete
var _ref$id = _ref.id,
[26314] Fix | Delete
id = _ref$id === void 0 ? "downshift-" + downshift_esm_generateId() : _ref$id,
[26315] Fix | Delete
labelId = _ref.labelId,
[26316] Fix | Delete
menuId = _ref.menuId,
[26317] Fix | Delete
getItemId = _ref.getItemId,
[26318] Fix | Delete
toggleButtonId = _ref.toggleButtonId,
[26319] Fix | Delete
inputId = _ref.inputId;
[26320] Fix | Delete
var elementIdsRef = Object(external_React_["useRef"])({
[26321] Fix | Delete
labelId: labelId || id + "-label",
[26322] Fix | Delete
menuId: menuId || id + "-menu",
[26323] Fix | Delete
getItemId: getItemId || function (index) {
[26324] Fix | Delete
return id + "-item-" + index;
[26325] Fix | Delete
},
[26326] Fix | Delete
toggleButtonId: toggleButtonId || id + "-toggle-button",
[26327] Fix | Delete
inputId: inputId || id + "-input"
[26328] Fix | Delete
});
[26329] Fix | Delete
return elementIdsRef.current;
[26330] Fix | Delete
}
[26331] Fix | Delete
[26332] Fix | Delete
function getItemIndex(index, item, items) {
[26333] Fix | Delete
if (index !== undefined) {
[26334] Fix | Delete
return index;
[26335] Fix | Delete
}
[26336] Fix | Delete
[26337] Fix | Delete
if (items.length === 0) {
[26338] Fix | Delete
return -1;
[26339] Fix | Delete
}
[26340] Fix | Delete
[26341] Fix | Delete
return items.indexOf(item);
[26342] Fix | Delete
}
[26343] Fix | Delete
[26344] Fix | Delete
function downshift_esm_itemToString(item) {
[26345] Fix | Delete
return item ? String(item) : '';
[26346] Fix | Delete
}
[26347] Fix | Delete
[26348] Fix | Delete
function isAcceptedCharacterKey(key) {
[26349] Fix | Delete
return /^\S{1}$/.test(key);
[26350] Fix | Delete
}
[26351] Fix | Delete
[26352] Fix | Delete
function capitalizeString(string) {
[26353] Fix | Delete
return "" + string.slice(0, 1).toUpperCase() + string.slice(1);
[26354] Fix | Delete
}
[26355] Fix | Delete
[26356] Fix | Delete
function useLatestRef(val) {
[26357] Fix | Delete
var ref = Object(external_React_["useRef"])(val); // technically this is not "concurrent mode safe" because we're manipulating
[26358] Fix | Delete
// the value during render (so it's not idempotent). However, the places this
[26359] Fix | Delete
// hook is used is to support memoizing callbacks which will be called
[26360] Fix | Delete
// *during* render, so we need the latest values *during* render.
[26361] Fix | Delete
// If not for this, then we'd probably want to use useLayoutEffect instead.
[26362] Fix | Delete
[26363] Fix | Delete
ref.current = val;
[26364] Fix | Delete
return ref;
[26365] Fix | Delete
}
[26366] Fix | Delete
/**
[26367] Fix | Delete
* Computes the controlled state using a the previous state, props,
[26368] Fix | Delete
* two reducers, one from downshift and an optional one from the user.
[26369] Fix | Delete
* Also calls the onChange handlers for state values that have changed.
[26370] Fix | Delete
*
[26371] Fix | Delete
* @param {Function} reducer Reducer function from downshift.
[26372] Fix | Delete
* @param {Object} initialState Initial state of the hook.
[26373] Fix | Delete
* @param {Object} props The hook props.
[26374] Fix | Delete
* @returns {Array} An array with the state and an action dispatcher.
[26375] Fix | Delete
*/
[26376] Fix | Delete
[26377] Fix | Delete
[26378] Fix | Delete
function useEnhancedReducer(reducer, initialState, props) {
[26379] Fix | Delete
var prevStateRef = Object(external_React_["useRef"])();
[26380] Fix | Delete
var actionRef = Object(external_React_["useRef"])();
[26381] Fix | Delete
var enhancedReducer = Object(external_React_["useCallback"])(function (state, action) {
[26382] Fix | Delete
actionRef.current = action;
[26383] Fix | Delete
state = getState(state, action.props);
[26384] Fix | Delete
var changes = reducer(state, action);
[26385] Fix | Delete
var newState = action.props.stateReducer(state, extends_extends({}, action, {
[26386] Fix | Delete
changes: changes
[26387] Fix | Delete
}));
[26388] Fix | Delete
return newState;
[26389] Fix | Delete
}, [reducer]);
[26390] Fix | Delete
[26391] Fix | Delete
var _useReducer = Object(external_React_["useReducer"])(enhancedReducer, initialState),
[26392] Fix | Delete
state = _useReducer[0],
[26393] Fix | Delete
dispatch = _useReducer[1];
[26394] Fix | Delete
[26395] Fix | Delete
var propsRef = useLatestRef(props);
[26396] Fix | Delete
var dispatchWithProps = Object(external_React_["useCallback"])(function (action) {
[26397] Fix | Delete
return dispatch(extends_extends({
[26398] Fix | Delete
props: propsRef.current
[26399] Fix | Delete
}, action));
[26400] Fix | Delete
}, [propsRef]);
[26401] Fix | Delete
var action = actionRef.current;
[26402] Fix | Delete
Object(external_React_["useEffect"])(function () {
[26403] Fix | Delete
if (action && prevStateRef.current && prevStateRef.current !== state) {
[26404] Fix | Delete
callOnChangeProps(action, getState(prevStateRef.current, action.props), state);
[26405] Fix | Delete
}
[26406] Fix | Delete
[26407] Fix | Delete
prevStateRef.current = state;
[26408] Fix | Delete
}, [state, props, action]);
[26409] Fix | Delete
return [state, dispatchWithProps];
[26410] Fix | Delete
}
[26411] Fix | Delete
/**
[26412] Fix | Delete
* Wraps the useEnhancedReducer and applies the controlled prop values before
[26413] Fix | Delete
* returning the new state.
[26414] Fix | Delete
*
[26415] Fix | Delete
* @param {Function} reducer Reducer function from downshift.
[26416] Fix | Delete
* @param {Object} initialState Initial state of the hook.
[26417] Fix | Delete
* @param {Object} props The hook props.
[26418] Fix | Delete
* @returns {Array} An array with the state and an action dispatcher.
[26419] Fix | Delete
*/
[26420] Fix | Delete
[26421] Fix | Delete
[26422] Fix | Delete
function useControlledReducer$1(reducer, initialState, props) {
[26423] Fix | Delete
var _useEnhancedReducer = useEnhancedReducer(reducer, initialState, props),
[26424] Fix | Delete
state = _useEnhancedReducer[0],
[26425] Fix | Delete
dispatch = _useEnhancedReducer[1];
[26426] Fix | Delete
[26427] Fix | Delete
return [getState(state, props), dispatch];
[26428] Fix | Delete
}
[26429] Fix | Delete
[26430] Fix | Delete
var defaultProps$3 = {
[26431] Fix | Delete
itemToString: downshift_esm_itemToString,
[26432] Fix | Delete
stateReducer: downshift_esm_stateReducer,
[26433] Fix | Delete
getA11ySelectionMessage: downshift_esm_getA11ySelectionMessage,
[26434] Fix | Delete
scrollIntoView: downshift_esm_scrollIntoView,
[26435] Fix | Delete
circularNavigation: false,
[26436] Fix | Delete
environment:
[26437] Fix | Delete
/* istanbul ignore next (ssr) */
[26438] Fix | Delete
typeof window === 'undefined' ? {} : window
[26439] Fix | Delete
};
[26440] Fix | Delete
[26441] Fix | Delete
function getDefaultValue$1(props, propKey, defaultStateValues) {
[26442] Fix | Delete
if (defaultStateValues === void 0) {
[26443] Fix | Delete
defaultStateValues = dropdownDefaultStateValues;
[26444] Fix | Delete
}
[26445] Fix | Delete
[26446] Fix | Delete
var defaultPropKey = "default" + capitalizeString(propKey);
[26447] Fix | Delete
[26448] Fix | Delete
if (defaultPropKey in props) {
[26449] Fix | Delete
return props[defaultPropKey];
[26450] Fix | Delete
}
[26451] Fix | Delete
[26452] Fix | Delete
return defaultStateValues[propKey];
[26453] Fix | Delete
}
[26454] Fix | Delete
[26455] Fix | Delete
function getInitialValue$1(props, propKey, defaultStateValues) {
[26456] Fix | Delete
if (defaultStateValues === void 0) {
[26457] Fix | Delete
defaultStateValues = dropdownDefaultStateValues;
[26458] Fix | Delete
}
[26459] Fix | Delete
[26460] Fix | Delete
if (propKey in props) {
[26461] Fix | Delete
return props[propKey];
[26462] Fix | Delete
}
[26463] Fix | Delete
[26464] Fix | Delete
var initialPropKey = "initial" + capitalizeString(propKey);
[26465] Fix | Delete
[26466] Fix | Delete
if (initialPropKey in props) {
[26467] Fix | Delete
return props[initialPropKey];
[26468] Fix | Delete
}
[26469] Fix | Delete
[26470] Fix | Delete
return getDefaultValue$1(props, propKey, defaultStateValues);
[26471] Fix | Delete
}
[26472] Fix | Delete
[26473] Fix | Delete
function getInitialState$2(props) {
[26474] Fix | Delete
var selectedItem = getInitialValue$1(props, 'selectedItem');
[26475] Fix | Delete
var isOpen = getInitialValue$1(props, 'isOpen');
[26476] Fix | Delete
var highlightedIndex = getInitialValue$1(props, 'highlightedIndex');
[26477] Fix | Delete
var inputValue = getInitialValue$1(props, 'inputValue');
[26478] Fix | Delete
return {
[26479] Fix | Delete
highlightedIndex: highlightedIndex < 0 && selectedItem && isOpen ? props.items.indexOf(selectedItem) : highlightedIndex,
[26480] Fix | Delete
isOpen: isOpen,
[26481] Fix | Delete
selectedItem: selectedItem,
[26482] Fix | Delete
inputValue: inputValue
[26483] Fix | Delete
};
[26484] Fix | Delete
}
[26485] Fix | Delete
[26486] Fix | Delete
function getHighlightedIndexOnOpen(props, state, offset, getItemNodeFromIndex) {
[26487] Fix | Delete
var items = props.items,
[26488] Fix | Delete
initialHighlightedIndex = props.initialHighlightedIndex,
[26489] Fix | Delete
defaultHighlightedIndex = props.defaultHighlightedIndex;
[26490] Fix | Delete
var selectedItem = state.selectedItem,
[26491] Fix | Delete
highlightedIndex = state.highlightedIndex;
[26492] Fix | Delete
[26493] Fix | Delete
if (items.length === 0) {
[26494] Fix | Delete
return -1;
[26495] Fix | Delete
} // initialHighlightedIndex will give value to highlightedIndex on initial state only.
[26496] Fix | Delete
[26497] Fix | Delete
[26498] Fix | Delete
if (initialHighlightedIndex !== undefined && highlightedIndex === initialHighlightedIndex) {
[26499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function