Edit File by line
/home/barbar84/www/wp-inclu.../js/dist
File: components.js
[17500] Fix | Delete
var initialInputControlState = {
[17501] Fix | Delete
_event: {},
[17502] Fix | Delete
error: null,
[17503] Fix | Delete
initialValue: '',
[17504] Fix | Delete
isDirty: false,
[17505] Fix | Delete
isDragEnabled: false,
[17506] Fix | Delete
isDragging: false,
[17507] Fix | Delete
isPressEnterToChange: false,
[17508] Fix | Delete
value: ''
[17509] Fix | Delete
};
[17510] Fix | Delete
var actionTypes = {
[17511] Fix | Delete
CHANGE: 'CHANGE',
[17512] Fix | Delete
COMMIT: 'COMMIT',
[17513] Fix | Delete
DRAG_END: 'DRAG_END',
[17514] Fix | Delete
DRAG_START: 'DRAG_START',
[17515] Fix | Delete
DRAG: 'DRAG',
[17516] Fix | Delete
INVALIDATE: 'INVALIDATE',
[17517] Fix | Delete
PRESS_DOWN: 'PRESS_DOWN',
[17518] Fix | Delete
PRESS_ENTER: 'PRESS_ENTER',
[17519] Fix | Delete
PRESS_UP: 'PRESS_UP',
[17520] Fix | Delete
RESET: 'RESET',
[17521] Fix | Delete
UPDATE: 'UPDATE'
[17522] Fix | Delete
};
[17523] Fix | Delete
var inputControlActionTypes = actionTypes;
[17524] Fix | Delete
/**
[17525] Fix | Delete
* Prepares initialState for the reducer.
[17526] Fix | Delete
*
[17527] Fix | Delete
* @param {Object} initialState The initial state.
[17528] Fix | Delete
* @return {Object} Prepared initialState for the reducer
[17529] Fix | Delete
*/
[17530] Fix | Delete
[17531] Fix | Delete
function mergeInitialState() {
[17532] Fix | Delete
var initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialInputControlState;
[17533] Fix | Delete
var value = initialState.value;
[17534] Fix | Delete
return state_objectSpread(state_objectSpread(state_objectSpread({}, initialInputControlState), initialState), {}, {
[17535] Fix | Delete
initialValue: value
[17536] Fix | Delete
});
[17537] Fix | Delete
}
[17538] Fix | Delete
/**
[17539] Fix | Delete
* Composes multiple stateReducers into a single stateReducer, building
[17540] Fix | Delete
* the pipeline to control the flow for state and actions.
[17541] Fix | Delete
*
[17542] Fix | Delete
* @param {...Function} fns State reducers.
[17543] Fix | Delete
* @return {Function} The single composed stateReducer.
[17544] Fix | Delete
*/
[17545] Fix | Delete
[17546] Fix | Delete
[17547] Fix | Delete
var state_composeStateReducers = function composeStateReducers() {
[17548] Fix | Delete
for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
[17549] Fix | Delete
fns[_key] = arguments[_key];
[17550] Fix | Delete
}
[17551] Fix | Delete
[17552] Fix | Delete
return function () {
[17553] Fix | Delete
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
[17554] Fix | Delete
args[_key2] = arguments[_key2];
[17555] Fix | Delete
}
[17556] Fix | Delete
[17557] Fix | Delete
return fns.reduceRight(function (state, fn) {
[17558] Fix | Delete
var fnState = fn.apply(void 0, args);
[17559] Fix | Delete
return Object(external_lodash_["isEmpty"])(fnState) ? state : state_objectSpread(state_objectSpread({}, state), fnState);
[17560] Fix | Delete
}, {});
[17561] Fix | Delete
};
[17562] Fix | Delete
};
[17563] Fix | Delete
/**
[17564] Fix | Delete
* Creates a reducer that opens the channel for external state subscription
[17565] Fix | Delete
* and modification.
[17566] Fix | Delete
*
[17567] Fix | Delete
* This technique uses the "stateReducer" design pattern:
[17568] Fix | Delete
* https://kentcdodds.com/blog/the-state-reducer-pattern/
[17569] Fix | Delete
*
[17570] Fix | Delete
* @param {Function} composedStateReducers A custom reducer that can subscribe and modify state.
[17571] Fix | Delete
* @return {Function} The reducer.
[17572] Fix | Delete
*/
[17573] Fix | Delete
[17574] Fix | Delete
function inputControlStateReducer(composedStateReducers) {
[17575] Fix | Delete
return function (state, action) {
[17576] Fix | Delete
var nextState = state_objectSpread({}, state);
[17577] Fix | Delete
[17578] Fix | Delete
var type = action.type,
[17579] Fix | Delete
payload = action.payload;
[17580] Fix | Delete
[17581] Fix | Delete
switch (type) {
[17582] Fix | Delete
/**
[17583] Fix | Delete
* Keyboard events
[17584] Fix | Delete
*/
[17585] Fix | Delete
case actionTypes.PRESS_UP:
[17586] Fix | Delete
nextState.isDirty = false;
[17587] Fix | Delete
break;
[17588] Fix | Delete
[17589] Fix | Delete
case actionTypes.PRESS_DOWN:
[17590] Fix | Delete
nextState.isDirty = false;
[17591] Fix | Delete
break;
[17592] Fix | Delete
[17593] Fix | Delete
/**
[17594] Fix | Delete
* Drag events
[17595] Fix | Delete
*/
[17596] Fix | Delete
[17597] Fix | Delete
case actionTypes.DRAG_START:
[17598] Fix | Delete
nextState.isDragging = true;
[17599] Fix | Delete
break;
[17600] Fix | Delete
[17601] Fix | Delete
case actionTypes.DRAG_END:
[17602] Fix | Delete
nextState.isDragging = false;
[17603] Fix | Delete
break;
[17604] Fix | Delete
[17605] Fix | Delete
/**
[17606] Fix | Delete
* Input events
[17607] Fix | Delete
*/
[17608] Fix | Delete
[17609] Fix | Delete
case actionTypes.CHANGE:
[17610] Fix | Delete
nextState.error = null;
[17611] Fix | Delete
nextState.value = payload.value;
[17612] Fix | Delete
[17613] Fix | Delete
if (state.isPressEnterToChange) {
[17614] Fix | Delete
nextState.isDirty = true;
[17615] Fix | Delete
}
[17616] Fix | Delete
[17617] Fix | Delete
break;
[17618] Fix | Delete
[17619] Fix | Delete
case actionTypes.COMMIT:
[17620] Fix | Delete
nextState.value = payload.value;
[17621] Fix | Delete
nextState.isDirty = false;
[17622] Fix | Delete
break;
[17623] Fix | Delete
[17624] Fix | Delete
case actionTypes.RESET:
[17625] Fix | Delete
nextState.error = null;
[17626] Fix | Delete
nextState.isDirty = false;
[17627] Fix | Delete
nextState.value = payload.value || state.initialValue;
[17628] Fix | Delete
break;
[17629] Fix | Delete
[17630] Fix | Delete
case actionTypes.UPDATE:
[17631] Fix | Delete
nextState.value = payload.value;
[17632] Fix | Delete
nextState.isDirty = false;
[17633] Fix | Delete
break;
[17634] Fix | Delete
[17635] Fix | Delete
/**
[17636] Fix | Delete
* Validation
[17637] Fix | Delete
*/
[17638] Fix | Delete
[17639] Fix | Delete
case actionTypes.INVALIDATE:
[17640] Fix | Delete
nextState.error = payload.error;
[17641] Fix | Delete
break;
[17642] Fix | Delete
}
[17643] Fix | Delete
[17644] Fix | Delete
if (payload.event) {
[17645] Fix | Delete
nextState._event = payload.event;
[17646] Fix | Delete
}
[17647] Fix | Delete
/**
[17648] Fix | Delete
* Send the nextState + action to the composedReducers via
[17649] Fix | Delete
* this "bridge" mechanism. This allows external stateReducers
[17650] Fix | Delete
* to hook into actions, and modify state if needed.
[17651] Fix | Delete
*/
[17652] Fix | Delete
[17653] Fix | Delete
[17654] Fix | Delete
return composedStateReducers(nextState, action);
[17655] Fix | Delete
};
[17656] Fix | Delete
}
[17657] Fix | Delete
/**
[17658] Fix | Delete
* A custom hook that connects and external stateReducer with an internal
[17659] Fix | Delete
* reducer. This hook manages the internal state of InputControl.
[17660] Fix | Delete
* However, by connecting an external stateReducer function, other
[17661] Fix | Delete
* components can react to actions as well as modify state before it is
[17662] Fix | Delete
* applied.
[17663] Fix | Delete
*
[17664] Fix | Delete
* This technique uses the "stateReducer" design pattern:
[17665] Fix | Delete
* https://kentcdodds.com/blog/the-state-reducer-pattern/
[17666] Fix | Delete
*
[17667] Fix | Delete
* @param {Function} stateReducer An external state reducer.
[17668] Fix | Delete
* @param {Object} initialState The initial state for the reducer.
[17669] Fix | Delete
* @return {Object} State, dispatch, and a collection of actions.
[17670] Fix | Delete
*/
[17671] Fix | Delete
[17672] Fix | Delete
[17673] Fix | Delete
function useInputControlStateReducer() {
[17674] Fix | Delete
var stateReducer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialStateReducer;
[17675] Fix | Delete
var initialState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : initialInputControlState;
[17676] Fix | Delete
[17677] Fix | Delete
var _useReducer = Object(external_wp_element_["useReducer"])(inputControlStateReducer(stateReducer), mergeInitialState(initialState)),
[17678] Fix | Delete
_useReducer2 = Object(slicedToArray["a" /* default */])(_useReducer, 2),
[17679] Fix | Delete
state = _useReducer2[0],
[17680] Fix | Delete
dispatch = _useReducer2[1];
[17681] Fix | Delete
[17682] Fix | Delete
var createChangeEvent = function createChangeEvent(type) {
[17683] Fix | Delete
return function (nextValue, event) {
[17684] Fix | Delete
/**
[17685] Fix | Delete
* Persist allows for the (Synthetic) event to be used outside of
[17686] Fix | Delete
* this function call.
[17687] Fix | Delete
* https://reactjs.org/docs/events.html#event-pooling
[17688] Fix | Delete
*/
[17689] Fix | Delete
if (event && event.persist) {
[17690] Fix | Delete
event.persist();
[17691] Fix | Delete
}
[17692] Fix | Delete
[17693] Fix | Delete
dispatch({
[17694] Fix | Delete
type: type,
[17695] Fix | Delete
payload: {
[17696] Fix | Delete
value: nextValue,
[17697] Fix | Delete
event: event
[17698] Fix | Delete
}
[17699] Fix | Delete
});
[17700] Fix | Delete
};
[17701] Fix | Delete
};
[17702] Fix | Delete
[17703] Fix | Delete
var createKeyEvent = function createKeyEvent(type) {
[17704] Fix | Delete
return function (event) {
[17705] Fix | Delete
/**
[17706] Fix | Delete
* Persist allows for the (Synthetic) event to be used outside of
[17707] Fix | Delete
* this function call.
[17708] Fix | Delete
* https://reactjs.org/docs/events.html#event-pooling
[17709] Fix | Delete
*/
[17710] Fix | Delete
if (event && event.persist) {
[17711] Fix | Delete
event.persist();
[17712] Fix | Delete
}
[17713] Fix | Delete
[17714] Fix | Delete
dispatch({
[17715] Fix | Delete
type: type,
[17716] Fix | Delete
payload: {
[17717] Fix | Delete
event: event
[17718] Fix | Delete
}
[17719] Fix | Delete
});
[17720] Fix | Delete
};
[17721] Fix | Delete
};
[17722] Fix | Delete
[17723] Fix | Delete
var createDragEvent = function createDragEvent(type) {
[17724] Fix | Delete
return function (dragProps) {
[17725] Fix | Delete
dispatch({
[17726] Fix | Delete
type: type,
[17727] Fix | Delete
payload: dragProps
[17728] Fix | Delete
});
[17729] Fix | Delete
};
[17730] Fix | Delete
};
[17731] Fix | Delete
/**
[17732] Fix | Delete
* Actions for the reducer
[17733] Fix | Delete
*/
[17734] Fix | Delete
[17735] Fix | Delete
[17736] Fix | Delete
var change = createChangeEvent(actionTypes.CHANGE);
[17737] Fix | Delete
var invalidate = createChangeEvent(actionTypes.INVALIDATE);
[17738] Fix | Delete
var reset = createChangeEvent(actionTypes.RESET);
[17739] Fix | Delete
var commit = createChangeEvent(actionTypes.COMMIT);
[17740] Fix | Delete
var update = createChangeEvent(actionTypes.UPDATE);
[17741] Fix | Delete
var dragStart = createDragEvent(actionTypes.DRAG_START);
[17742] Fix | Delete
var drag = createDragEvent(actionTypes.DRAG);
[17743] Fix | Delete
var dragEnd = createDragEvent(actionTypes.DRAG_END);
[17744] Fix | Delete
var pressUp = createKeyEvent(actionTypes.PRESS_UP);
[17745] Fix | Delete
var pressDown = createKeyEvent(actionTypes.PRESS_DOWN);
[17746] Fix | Delete
var pressEnter = createKeyEvent(actionTypes.PRESS_ENTER);
[17747] Fix | Delete
return {
[17748] Fix | Delete
change: change,
[17749] Fix | Delete
commit: commit,
[17750] Fix | Delete
dispatch: dispatch,
[17751] Fix | Delete
drag: drag,
[17752] Fix | Delete
dragEnd: dragEnd,
[17753] Fix | Delete
dragStart: dragStart,
[17754] Fix | Delete
invalidate: invalidate,
[17755] Fix | Delete
pressDown: pressDown,
[17756] Fix | Delete
pressEnter: pressEnter,
[17757] Fix | Delete
pressUp: pressUp,
[17758] Fix | Delete
reset: reset,
[17759] Fix | Delete
state: state,
[17760] Fix | Delete
update: update
[17761] Fix | Delete
};
[17762] Fix | Delete
}
[17763] Fix | Delete
[17764] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/utils/values.js
[17765] Fix | Delete
/* eslint-disable jsdoc/valid-types */
[17766] Fix | Delete
[17767] Fix | Delete
/**
[17768] Fix | Delete
* Determines if a value is null or undefined.
[17769] Fix | Delete
*
[17770] Fix | Delete
* @template T
[17771] Fix | Delete
*
[17772] Fix | Delete
* @param {T | null | undefined} value The value to check.
[17773] Fix | Delete
* @return {value is T} Whether value is not null or undefined.
[17774] Fix | Delete
*/
[17775] Fix | Delete
function isValueDefined(value) {
[17776] Fix | Delete
return value !== undefined && value !== null;
[17777] Fix | Delete
}
[17778] Fix | Delete
/* eslint-enable jsdoc/valid-types */
[17779] Fix | Delete
[17780] Fix | Delete
/* eslint-disable jsdoc/valid-types */
[17781] Fix | Delete
[17782] Fix | Delete
/**
[17783] Fix | Delete
* Determines if a value is empty, null, or undefined.
[17784] Fix | Delete
*
[17785] Fix | Delete
* @template T
[17786] Fix | Delete
*
[17787] Fix | Delete
* @param {T | "" | null | undefined} value The value to check.
[17788] Fix | Delete
* @return {value is T} Whether value is empty.
[17789] Fix | Delete
*/
[17790] Fix | Delete
[17791] Fix | Delete
function isValueEmpty(value) {
[17792] Fix | Delete
var isEmptyString = value === '';
[17793] Fix | Delete
return !isValueDefined(value) || isEmptyString;
[17794] Fix | Delete
}
[17795] Fix | Delete
/* eslint-enable jsdoc/valid-types */
[17796] Fix | Delete
[17797] Fix | Delete
/**
[17798] Fix | Delete
* Get the first defined/non-null value from an array.
[17799] Fix | Delete
*
[17800] Fix | Delete
* @template T
[17801] Fix | Delete
*
[17802] Fix | Delete
* @param {Array<T | null | undefined>} values Values to derive from.
[17803] Fix | Delete
* @param {T} fallbackValue Fallback value if there are no defined values.
[17804] Fix | Delete
* @return {T} A defined value or the fallback value.
[17805] Fix | Delete
*/
[17806] Fix | Delete
[17807] Fix | Delete
function getDefinedValue() {
[17808] Fix | Delete
var _values$find;
[17809] Fix | Delete
[17810] Fix | Delete
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
[17811] Fix | Delete
var fallbackValue = arguments.length > 1 ? arguments[1] : undefined;
[17812] Fix | Delete
return (_values$find = values.find(isValueDefined)) !== null && _values$find !== void 0 ? _values$find : fallbackValue;
[17813] Fix | Delete
}
[17814] Fix | Delete
[17815] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/utils/hooks/use-update-effect.js
[17816] Fix | Delete
/**
[17817] Fix | Delete
* WordPress dependencies
[17818] Fix | Delete
*/
[17819] Fix | Delete
[17820] Fix | Delete
/**
[17821] Fix | Delete
* A `React.useEffect` that will not run on the first render.
[17822] Fix | Delete
* Source:
[17823] Fix | Delete
* https://github.com/reakit/reakit/blob/HEAD/packages/reakit-utils/src/useUpdateEffect.ts
[17824] Fix | Delete
*
[17825] Fix | Delete
* @param {import('react').EffectCallback} effect
[17826] Fix | Delete
* @param {import('react').DependencyList} deps
[17827] Fix | Delete
*/
[17828] Fix | Delete
[17829] Fix | Delete
function useUpdateEffect(effect, deps) {
[17830] Fix | Delete
var mounted = Object(external_wp_element_["useRef"])(false);
[17831] Fix | Delete
Object(external_wp_element_["useEffect"])(function () {
[17832] Fix | Delete
if (mounted.current) {
[17833] Fix | Delete
return effect();
[17834] Fix | Delete
}
[17835] Fix | Delete
[17836] Fix | Delete
mounted.current = true;
[17837] Fix | Delete
return undefined;
[17838] Fix | Delete
}, deps);
[17839] Fix | Delete
}
[17840] Fix | Delete
[17841] Fix | Delete
/* harmony default export */ var use_update_effect = (useUpdateEffect);
[17842] Fix | Delete
[17843] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/input-control/input-field.js
[17844] Fix | Delete
[17845] Fix | Delete
[17846] Fix | Delete
[17847] Fix | Delete
[17848] Fix | Delete
/**
[17849] Fix | Delete
* External dependencies
[17850] Fix | Delete
*/
[17851] Fix | Delete
[17852] Fix | Delete
[17853] Fix | Delete
/**
[17854] Fix | Delete
* WordPress dependencies
[17855] Fix | Delete
*/
[17856] Fix | Delete
[17857] Fix | Delete
[17858] Fix | Delete
[17859] Fix | Delete
/**
[17860] Fix | Delete
* Internal dependencies
[17861] Fix | Delete
*/
[17862] Fix | Delete
[17863] Fix | Delete
[17864] Fix | Delete
[17865] Fix | Delete
[17866] Fix | Delete
[17867] Fix | Delete
[17868] Fix | Delete
[17869] Fix | Delete
function InputField(_ref, ref) {
[17870] Fix | Delete
var _ref$disabled = _ref.disabled,
[17871] Fix | Delete
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
[17872] Fix | Delete
_ref$dragDirection = _ref.dragDirection,
[17873] Fix | Delete
dragDirection = _ref$dragDirection === void 0 ? 'n' : _ref$dragDirection,
[17874] Fix | Delete
_ref$dragThreshold = _ref.dragThreshold,
[17875] Fix | Delete
dragThreshold = _ref$dragThreshold === void 0 ? 10 : _ref$dragThreshold,
[17876] Fix | Delete
id = _ref.id,
[17877] Fix | Delete
_ref$isDragEnabled = _ref.isDragEnabled,
[17878] Fix | Delete
isDragEnabled = _ref$isDragEnabled === void 0 ? false : _ref$isDragEnabled,
[17879] Fix | Delete
isFocused = _ref.isFocused,
[17880] Fix | Delete
_ref$isPressEnterToCh = _ref.isPressEnterToChange,
[17881] Fix | Delete
isPressEnterToChange = _ref$isPressEnterToCh === void 0 ? false : _ref$isPressEnterToCh,
[17882] Fix | Delete
_ref$onBlur = _ref.onBlur,
[17883] Fix | Delete
onBlur = _ref$onBlur === void 0 ? external_lodash_["noop"] : _ref$onBlur,
[17884] Fix | Delete
_ref$onChange = _ref.onChange,
[17885] Fix | Delete
onChange = _ref$onChange === void 0 ? external_lodash_["noop"] : _ref$onChange,
[17886] Fix | Delete
_ref$onDrag = _ref.onDrag,
[17887] Fix | Delete
onDrag = _ref$onDrag === void 0 ? external_lodash_["noop"] : _ref$onDrag,
[17888] Fix | Delete
_ref$onDragEnd = _ref.onDragEnd,
[17889] Fix | Delete
onDragEnd = _ref$onDragEnd === void 0 ? external_lodash_["noop"] : _ref$onDragEnd,
[17890] Fix | Delete
_ref$onDragStart = _ref.onDragStart,
[17891] Fix | Delete
onDragStart = _ref$onDragStart === void 0 ? external_lodash_["noop"] : _ref$onDragStart,
[17892] Fix | Delete
_ref$onFocus = _ref.onFocus,
[17893] Fix | Delete
onFocus = _ref$onFocus === void 0 ? external_lodash_["noop"] : _ref$onFocus,
[17894] Fix | Delete
_ref$onKeyDown = _ref.onKeyDown,
[17895] Fix | Delete
onKeyDown = _ref$onKeyDown === void 0 ? external_lodash_["noop"] : _ref$onKeyDown,
[17896] Fix | Delete
_ref$onValidate = _ref.onValidate,
[17897] Fix | Delete
onValidate = _ref$onValidate === void 0 ? external_lodash_["noop"] : _ref$onValidate,
[17898] Fix | Delete
_ref$size = _ref.size,
[17899] Fix | Delete
size = _ref$size === void 0 ? 'default' : _ref$size,
[17900] Fix | Delete
setIsFocused = _ref.setIsFocused,
[17901] Fix | Delete
_ref$stateReducer = _ref.stateReducer,
[17902] Fix | Delete
stateReducer = _ref$stateReducer === void 0 ? function (state) {
[17903] Fix | Delete
return state;
[17904] Fix | Delete
} : _ref$stateReducer,
[17905] Fix | Delete
valueProp = _ref.value,
[17906] Fix | Delete
type = _ref.type,
[17907] Fix | Delete
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["disabled", "dragDirection", "dragThreshold", "id", "isDragEnabled", "isFocused", "isPressEnterToChange", "onBlur", "onChange", "onDrag", "onDragEnd", "onDragStart", "onFocus", "onKeyDown", "onValidate", "size", "setIsFocused", "stateReducer", "value", "type"]);
[17908] Fix | Delete
[17909] Fix | Delete
var _useInputControlState = useInputControlStateReducer(stateReducer, {
[17910] Fix | Delete
isDragEnabled: isDragEnabled,
[17911] Fix | Delete
value: valueProp,
[17912] Fix | Delete
isPressEnterToChange: isPressEnterToChange
[17913] Fix | Delete
}),
[17914] Fix | Delete
state = _useInputControlState.state,
[17915] Fix | Delete
change = _useInputControlState.change,
[17916] Fix | Delete
commit = _useInputControlState.commit,
[17917] Fix | Delete
drag = _useInputControlState.drag,
[17918] Fix | Delete
dragEnd = _useInputControlState.dragEnd,
[17919] Fix | Delete
dragStart = _useInputControlState.dragStart,
[17920] Fix | Delete
invalidate = _useInputControlState.invalidate,
[17921] Fix | Delete
pressDown = _useInputControlState.pressDown,
[17922] Fix | Delete
pressEnter = _useInputControlState.pressEnter,
[17923] Fix | Delete
pressUp = _useInputControlState.pressUp,
[17924] Fix | Delete
reset = _useInputControlState.reset,
[17925] Fix | Delete
update = _useInputControlState.update;
[17926] Fix | Delete
[17927] Fix | Delete
var _event = state._event,
[17928] Fix | Delete
value = state.value,
[17929] Fix | Delete
isDragging = state.isDragging,
[17930] Fix | Delete
isDirty = state.isDirty;
[17931] Fix | Delete
var wasDirtyOnBlur = Object(external_wp_element_["useRef"])(false);
[17932] Fix | Delete
var dragCursor = useDragCursor(isDragging, dragDirection);
[17933] Fix | Delete
/*
[17934] Fix | Delete
* Handles syncronization of external and internal value state.
[17935] Fix | Delete
* If not focused and did not hold a dirty value[1] on blur
[17936] Fix | Delete
* updates the value from the props. Otherwise if not holding
[17937] Fix | Delete
* a dirty value[1] propagates the value and event through onChange.
[17938] Fix | Delete
* [1] value is only made dirty if isPressEnterToChange is true
[17939] Fix | Delete
*/
[17940] Fix | Delete
[17941] Fix | Delete
use_update_effect(function () {
[17942] Fix | Delete
if (valueProp === value) {
[17943] Fix | Delete
return;
[17944] Fix | Delete
}
[17945] Fix | Delete
[17946] Fix | Delete
if (!isFocused && !wasDirtyOnBlur.current) {
[17947] Fix | Delete
update(valueProp);
[17948] Fix | Delete
} else if (!isDirty) {
[17949] Fix | Delete
onChange(value, {
[17950] Fix | Delete
event: _event
[17951] Fix | Delete
});
[17952] Fix | Delete
wasDirtyOnBlur.current = false;
[17953] Fix | Delete
}
[17954] Fix | Delete
}, [value, isDirty, isFocused, valueProp]);
[17955] Fix | Delete
[17956] Fix | Delete
var handleOnBlur = function handleOnBlur(event) {
[17957] Fix | Delete
onBlur(event);
[17958] Fix | Delete
setIsFocused(false);
[17959] Fix | Delete
/**
[17960] Fix | Delete
* If isPressEnterToChange is set, this commits the value to
[17961] Fix | Delete
* the onChange callback.
[17962] Fix | Delete
*/
[17963] Fix | Delete
[17964] Fix | Delete
if (isPressEnterToChange && isDirty) {
[17965] Fix | Delete
wasDirtyOnBlur.current = true;
[17966] Fix | Delete
[17967] Fix | Delete
if (!isValueEmpty(value)) {
[17968] Fix | Delete
handleOnCommit(event);
[17969] Fix | Delete
} else {
[17970] Fix | Delete
reset(valueProp);
[17971] Fix | Delete
}
[17972] Fix | Delete
}
[17973] Fix | Delete
};
[17974] Fix | Delete
[17975] Fix | Delete
var handleOnFocus = function handleOnFocus(event) {
[17976] Fix | Delete
onFocus(event);
[17977] Fix | Delete
setIsFocused(true);
[17978] Fix | Delete
};
[17979] Fix | Delete
[17980] Fix | Delete
var handleOnChange = function handleOnChange(event) {
[17981] Fix | Delete
var nextValue = event.target.value;
[17982] Fix | Delete
change(nextValue, event);
[17983] Fix | Delete
};
[17984] Fix | Delete
[17985] Fix | Delete
var handleOnCommit = function handleOnCommit(event) {
[17986] Fix | Delete
var nextValue = event.target.value;
[17987] Fix | Delete
[17988] Fix | Delete
try {
[17989] Fix | Delete
onValidate(nextValue, event);
[17990] Fix | Delete
commit(nextValue, event);
[17991] Fix | Delete
} catch (err) {
[17992] Fix | Delete
invalidate(err, event);
[17993] Fix | Delete
}
[17994] Fix | Delete
};
[17995] Fix | Delete
[17996] Fix | Delete
var handleOnKeyDown = function handleOnKeyDown(event) {
[17997] Fix | Delete
var keyCode = event.keyCode;
[17998] Fix | Delete
onKeyDown(event);
[17999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function