Edit File by line
/home/barbar84/www/wp-inclu.../js/dist
File: components.js
var _this;
[31500] Fix | Delete
[31501] Fix | Delete
Object(classCallCheck["a" /* default */])(this, FocalPointPicker);
[31502] Fix | Delete
[31503] Fix | Delete
_this = _super.apply(this, arguments);
[31504] Fix | Delete
_this.state = {
[31505] Fix | Delete
isDragging: false,
[31506] Fix | Delete
bounds: INITIAL_BOUNDS,
[31507] Fix | Delete
percentages: props.value
[31508] Fix | Delete
};
[31509] Fix | Delete
_this.containerRef = Object(external_wp_element_["createRef"])();
[31510] Fix | Delete
_this.mediaRef = Object(external_wp_element_["createRef"])();
[31511] Fix | Delete
_this.handleOnClick = _this.handleOnClick.bind(Object(assertThisInitialized["a" /* default */])(_this));
[31512] Fix | Delete
_this.handleOnMouseUp = _this.handleOnMouseUp.bind(Object(assertThisInitialized["a" /* default */])(_this));
[31513] Fix | Delete
_this.handleOnKeyDown = _this.handleOnKeyDown.bind(Object(assertThisInitialized["a" /* default */])(_this));
[31514] Fix | Delete
_this.onMouseMove = _this.onMouseMove.bind(Object(assertThisInitialized["a" /* default */])(_this));
[31515] Fix | Delete
_this.updateBounds = _this.updateBounds.bind(Object(assertThisInitialized["a" /* default */])(_this));
[31516] Fix | Delete
_this.updateValue = _this.updateValue.bind(Object(assertThisInitialized["a" /* default */])(_this));
[31517] Fix | Delete
return _this;
[31518] Fix | Delete
}
[31519] Fix | Delete
[31520] Fix | Delete
Object(createClass["a" /* default */])(FocalPointPicker, [{
[31521] Fix | Delete
key: "componentDidMount",
[31522] Fix | Delete
value: function componentDidMount() {
[31523] Fix | Delete
document.addEventListener('mouseup', this.handleOnMouseUp);
[31524] Fix | Delete
window.addEventListener('resize', this.updateBounds);
[31525] Fix | Delete
/*
[31526] Fix | Delete
* Set initial bound values.
[31527] Fix | Delete
*
[31528] Fix | Delete
* This is necessary for Safari:
[31529] Fix | Delete
* https://github.com/WordPress/gutenberg/issues/25814
[31530] Fix | Delete
*/
[31531] Fix | Delete
[31532] Fix | Delete
this.updateBounds();
[31533] Fix | Delete
}
[31534] Fix | Delete
}, {
[31535] Fix | Delete
key: "componentDidUpdate",
[31536] Fix | Delete
value: function componentDidUpdate(prevProps) {
[31537] Fix | Delete
if (prevProps.url !== this.props.url) {
[31538] Fix | Delete
this.setState({
[31539] Fix | Delete
isDragging: false
[31540] Fix | Delete
});
[31541] Fix | Delete
}
[31542] Fix | Delete
/*
[31543] Fix | Delete
* Handles cases where the incoming value changes.
[31544] Fix | Delete
* An example is the values resetting based on an UNDO action.
[31545] Fix | Delete
*/
[31546] Fix | Delete
[31547] Fix | Delete
[31548] Fix | Delete
if (this.props.value.x !== this.state.percentages.x || this.props.value.y !== this.state.percentages.y) {
[31549] Fix | Delete
this.setState({
[31550] Fix | Delete
percentages: this.props.value
[31551] Fix | Delete
});
[31552] Fix | Delete
}
[31553] Fix | Delete
}
[31554] Fix | Delete
}, {
[31555] Fix | Delete
key: "componentWillUnmount",
[31556] Fix | Delete
value: function componentWillUnmount() {
[31557] Fix | Delete
document.removeEventListener('mouseup', this.handleOnMouseUp);
[31558] Fix | Delete
window.removeEventListener('resize', this.updateBounds);
[31559] Fix | Delete
}
[31560] Fix | Delete
}, {
[31561] Fix | Delete
key: "calculateBounds",
[31562] Fix | Delete
value: function calculateBounds() {
[31563] Fix | Delete
var bounds = INITIAL_BOUNDS;
[31564] Fix | Delete
[31565] Fix | Delete
if (!this.mediaRef.current) {
[31566] Fix | Delete
return bounds;
[31567] Fix | Delete
} // Prevent division by zero when updateBounds runs in componentDidMount
[31568] Fix | Delete
[31569] Fix | Delete
[31570] Fix | Delete
if (this.mediaRef.current.clientWidth === 0 || this.mediaRef.current.clientHeight === 0) {
[31571] Fix | Delete
return bounds;
[31572] Fix | Delete
}
[31573] Fix | Delete
[31574] Fix | Delete
var dimensions = {
[31575] Fix | Delete
width: this.mediaRef.current.clientWidth,
[31576] Fix | Delete
height: this.mediaRef.current.clientHeight
[31577] Fix | Delete
};
[31578] Fix | Delete
var pickerDimensions = this.pickerDimensions();
[31579] Fix | Delete
var widthRatio = pickerDimensions.width / dimensions.width;
[31580] Fix | Delete
var heightRatio = pickerDimensions.height / dimensions.height;
[31581] Fix | Delete
[31582] Fix | Delete
if (heightRatio >= widthRatio) {
[31583] Fix | Delete
bounds.width = bounds.right = pickerDimensions.width;
[31584] Fix | Delete
bounds.height = dimensions.height * widthRatio;
[31585] Fix | Delete
bounds.top = (pickerDimensions.height - bounds.height) / 2;
[31586] Fix | Delete
bounds.bottom = bounds.top + bounds.height;
[31587] Fix | Delete
} else {
[31588] Fix | Delete
bounds.height = bounds.bottom = pickerDimensions.height;
[31589] Fix | Delete
bounds.width = dimensions.width * heightRatio;
[31590] Fix | Delete
bounds.left = (pickerDimensions.width - bounds.width) / 2;
[31591] Fix | Delete
bounds.right = bounds.left + bounds.width;
[31592] Fix | Delete
}
[31593] Fix | Delete
[31594] Fix | Delete
return bounds;
[31595] Fix | Delete
}
[31596] Fix | Delete
}, {
[31597] Fix | Delete
key: "updateValue",
[31598] Fix | Delete
value: function updateValue() {
[31599] Fix | Delete
var nextValue = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
[31600] Fix | Delete
var onChange = this.props.onChange;
[31601] Fix | Delete
var x = nextValue.x,
[31602] Fix | Delete
y = nextValue.y;
[31603] Fix | Delete
var nextPercentage = {
[31604] Fix | Delete
x: parseFloat(x).toFixed(2),
[31605] Fix | Delete
y: parseFloat(y).toFixed(2)
[31606] Fix | Delete
};
[31607] Fix | Delete
this.setState({
[31608] Fix | Delete
percentages: nextPercentage
[31609] Fix | Delete
}, function () {
[31610] Fix | Delete
onChange(nextPercentage);
[31611] Fix | Delete
});
[31612] Fix | Delete
}
[31613] Fix | Delete
}, {
[31614] Fix | Delete
key: "updateBounds",
[31615] Fix | Delete
value: function updateBounds() {
[31616] Fix | Delete
this.setState({
[31617] Fix | Delete
bounds: this.calculateBounds()
[31618] Fix | Delete
});
[31619] Fix | Delete
}
[31620] Fix | Delete
}, {
[31621] Fix | Delete
key: "handleOnClick",
[31622] Fix | Delete
value: function handleOnClick(event) {
[31623] Fix | Delete
var _this2 = this;
[31624] Fix | Delete
[31625] Fix | Delete
event.persist();
[31626] Fix | Delete
this.setState({
[31627] Fix | Delete
isDragging: true
[31628] Fix | Delete
}, function () {
[31629] Fix | Delete
_this2.onMouseMove(event);
[31630] Fix | Delete
});
[31631] Fix | Delete
}
[31632] Fix | Delete
}, {
[31633] Fix | Delete
key: "handleOnMouseUp",
[31634] Fix | Delete
value: function handleOnMouseUp() {
[31635] Fix | Delete
this.setState({
[31636] Fix | Delete
isDragging: false
[31637] Fix | Delete
});
[31638] Fix | Delete
}
[31639] Fix | Delete
}, {
[31640] Fix | Delete
key: "handleOnKeyDown",
[31641] Fix | Delete
value: function handleOnKeyDown(event) {
[31642] Fix | Delete
var keyCode = event.keyCode,
[31643] Fix | Delete
shiftKey = event.shiftKey;
[31644] Fix | Delete
if (![external_wp_keycodes_["UP"], external_wp_keycodes_["DOWN"], external_wp_keycodes_["LEFT"], external_wp_keycodes_["RIGHT"]].includes(keyCode)) return;
[31645] Fix | Delete
var _this$state$percentag = this.state.percentages,
[31646] Fix | Delete
x = _this$state$percentag.x,
[31647] Fix | Delete
y = _this$state$percentag.y;
[31648] Fix | Delete
event.preventDefault(); // Normalizing values for incrementing/decrementing based on arrow keys
[31649] Fix | Delete
[31650] Fix | Delete
var nextX = parseFloat(x);
[31651] Fix | Delete
var nextY = parseFloat(y);
[31652] Fix | Delete
var step = shiftKey ? 0.1 : 0.01;
[31653] Fix | Delete
[31654] Fix | Delete
switch (event.keyCode) {
[31655] Fix | Delete
case external_wp_keycodes_["UP"]:
[31656] Fix | Delete
nextY = nextY - step;
[31657] Fix | Delete
break;
[31658] Fix | Delete
[31659] Fix | Delete
case external_wp_keycodes_["DOWN"]:
[31660] Fix | Delete
nextY = nextY + step;
[31661] Fix | Delete
break;
[31662] Fix | Delete
[31663] Fix | Delete
case external_wp_keycodes_["LEFT"]:
[31664] Fix | Delete
nextX = nextX - step;
[31665] Fix | Delete
break;
[31666] Fix | Delete
[31667] Fix | Delete
case external_wp_keycodes_["RIGHT"]:
[31668] Fix | Delete
nextX = nextX + step;
[31669] Fix | Delete
break;
[31670] Fix | Delete
}
[31671] Fix | Delete
[31672] Fix | Delete
nextX = roundClamp(nextX, 0, 1, step);
[31673] Fix | Delete
nextY = roundClamp(nextY, 0, 1, step);
[31674] Fix | Delete
var percentages = {
[31675] Fix | Delete
x: nextX,
[31676] Fix | Delete
y: nextY
[31677] Fix | Delete
};
[31678] Fix | Delete
this.updateValue(percentages);
[31679] Fix | Delete
}
[31680] Fix | Delete
}, {
[31681] Fix | Delete
key: "onMouseMove",
[31682] Fix | Delete
value: function onMouseMove(event) {
[31683] Fix | Delete
var _this$state = this.state,
[31684] Fix | Delete
isDragging = _this$state.isDragging,
[31685] Fix | Delete
bounds = _this$state.bounds;
[31686] Fix | Delete
if (!isDragging) return; // Prevents text-selection when dragging.
[31687] Fix | Delete
[31688] Fix | Delete
event.preventDefault();
[31689] Fix | Delete
var shiftKey = event.shiftKey;
[31690] Fix | Delete
var pickerDimensions = this.pickerDimensions();
[31691] Fix | Delete
var cursorPosition = {
[31692] Fix | Delete
left: event.pageX - pickerDimensions.left,
[31693] Fix | Delete
top: event.pageY - pickerDimensions.top
[31694] Fix | Delete
};
[31695] Fix | Delete
var left = Math.max(bounds.left, Math.min(cursorPosition.left, bounds.right));
[31696] Fix | Delete
var top = Math.max(bounds.top, Math.min(cursorPosition.top, bounds.bottom));
[31697] Fix | Delete
var nextX = (left - bounds.left) / (pickerDimensions.width - bounds.left * 2);
[31698] Fix | Delete
var nextY = (top - bounds.top) / (pickerDimensions.height - bounds.top * 2); // Enables holding shift to jump values by 10%
[31699] Fix | Delete
[31700] Fix | Delete
var step = shiftKey ? 0.1 : 0.01;
[31701] Fix | Delete
nextX = roundClamp(nextX, 0, 1, step);
[31702] Fix | Delete
nextY = roundClamp(nextY, 0, 1, step);
[31703] Fix | Delete
var nextPercentage = {
[31704] Fix | Delete
x: nextX,
[31705] Fix | Delete
y: nextY
[31706] Fix | Delete
};
[31707] Fix | Delete
this.updateValue(nextPercentage);
[31708] Fix | Delete
}
[31709] Fix | Delete
}, {
[31710] Fix | Delete
key: "pickerDimensions",
[31711] Fix | Delete
value: function pickerDimensions() {
[31712] Fix | Delete
var containerNode = this.containerRef.current;
[31713] Fix | Delete
[31714] Fix | Delete
if (!containerNode) {
[31715] Fix | Delete
return {
[31716] Fix | Delete
width: 0,
[31717] Fix | Delete
height: 0,
[31718] Fix | Delete
left: 0,
[31719] Fix | Delete
top: 0
[31720] Fix | Delete
};
[31721] Fix | Delete
}
[31722] Fix | Delete
[31723] Fix | Delete
var clientHeight = containerNode.clientHeight,
[31724] Fix | Delete
clientWidth = containerNode.clientWidth;
[31725] Fix | Delete
[31726] Fix | Delete
var _containerNode$getBou = containerNode.getBoundingClientRect(),
[31727] Fix | Delete
top = _containerNode$getBou.top,
[31728] Fix | Delete
left = _containerNode$getBou.left;
[31729] Fix | Delete
[31730] Fix | Delete
return {
[31731] Fix | Delete
width: clientWidth,
[31732] Fix | Delete
height: clientHeight,
[31733] Fix | Delete
top: top + document.body.scrollTop,
[31734] Fix | Delete
left: left
[31735] Fix | Delete
};
[31736] Fix | Delete
}
[31737] Fix | Delete
}, {
[31738] Fix | Delete
key: "iconCoordinates",
[31739] Fix | Delete
value: function iconCoordinates() {
[31740] Fix | Delete
var value = this.props.value;
[31741] Fix | Delete
var bounds = this.state.bounds;
[31742] Fix | Delete
[31743] Fix | Delete
if (bounds.left === undefined || bounds.top === undefined) {
[31744] Fix | Delete
return {
[31745] Fix | Delete
left: '50%',
[31746] Fix | Delete
top: '50%'
[31747] Fix | Delete
};
[31748] Fix | Delete
}
[31749] Fix | Delete
[31750] Fix | Delete
var pickerDimensions = this.pickerDimensions();
[31751] Fix | Delete
var iconCoordinates = {
[31752] Fix | Delete
left: value.x * (pickerDimensions.width - bounds.left * 2) + bounds.left,
[31753] Fix | Delete
top: value.y * (pickerDimensions.height - bounds.top * 2) + bounds.top
[31754] Fix | Delete
};
[31755] Fix | Delete
return iconCoordinates;
[31756] Fix | Delete
} // Callback method for the withFocusOutside higher-order component
[31757] Fix | Delete
[31758] Fix | Delete
}, {
[31759] Fix | Delete
key: "handleFocusOutside",
[31760] Fix | Delete
value: function handleFocusOutside() {
[31761] Fix | Delete
this.setState({
[31762] Fix | Delete
isDragging: false
[31763] Fix | Delete
});
[31764] Fix | Delete
}
[31765] Fix | Delete
}, {
[31766] Fix | Delete
key: "render",
[31767] Fix | Delete
value: function render() {
[31768] Fix | Delete
var _this3 = this;
[31769] Fix | Delete
[31770] Fix | Delete
var _this$props = this.props,
[31771] Fix | Delete
autoPlay = _this$props.autoPlay,
[31772] Fix | Delete
className = _this$props.className,
[31773] Fix | Delete
help = _this$props.help,
[31774] Fix | Delete
instanceId = _this$props.instanceId,
[31775] Fix | Delete
label = _this$props.label,
[31776] Fix | Delete
_onDragStart = _this$props.onDragStart,
[31777] Fix | Delete
onDragEnd = _this$props.onDragEnd,
[31778] Fix | Delete
url = _this$props.url;
[31779] Fix | Delete
var _this$state2 = this.state,
[31780] Fix | Delete
bounds = _this$state2.bounds,
[31781] Fix | Delete
isDragging = _this$state2.isDragging,
[31782] Fix | Delete
percentages = _this$state2.percentages;
[31783] Fix | Delete
var iconCoordinates = this.iconCoordinates();
[31784] Fix | Delete
var classes = classnames_default()('components-focal-point-picker-control', className);
[31785] Fix | Delete
var id = "inspector-focal-point-picker-control-".concat(instanceId);
[31786] Fix | Delete
return Object(external_wp_element_["createElement"])(base_control, {
[31787] Fix | Delete
label: label,
[31788] Fix | Delete
id: id,
[31789] Fix | Delete
help: help,
[31790] Fix | Delete
className: classes
[31791] Fix | Delete
}, Object(external_wp_element_["createElement"])(MediaWrapper, {
[31792] Fix | Delete
className: "components-focal-point-picker-wrapper"
[31793] Fix | Delete
}, Object(external_wp_element_["createElement"])(MediaContainer, {
[31794] Fix | Delete
className: "components-focal-point-picker",
[31795] Fix | Delete
onDragStart: function onDragStart(event) {
[31796] Fix | Delete
_this3.setState({
[31797] Fix | Delete
isDragging: true
[31798] Fix | Delete
});
[31799] Fix | Delete
[31800] Fix | Delete
_onDragStart(event);
[31801] Fix | Delete
},
[31802] Fix | Delete
onDrop: function onDrop(event) {
[31803] Fix | Delete
_this3.setState({
[31804] Fix | Delete
isDragging: false
[31805] Fix | Delete
});
[31806] Fix | Delete
[31807] Fix | Delete
onDragEnd(event);
[31808] Fix | Delete
},
[31809] Fix | Delete
onKeyDown: this.handleOnKeyDown,
[31810] Fix | Delete
onMouseDown: this.handleOnClick,
[31811] Fix | Delete
onMouseMove: this.onMouseMove,
[31812] Fix | Delete
onMouseUp: this.handleOnMouseUp,
[31813] Fix | Delete
ref: this.containerRef,
[31814] Fix | Delete
role: "button",
[31815] Fix | Delete
tabIndex: "-1"
[31816] Fix | Delete
}, Object(external_wp_element_["createElement"])(FocalPointPickerGrid, {
[31817] Fix | Delete
bounds: bounds,
[31818] Fix | Delete
value: percentages.x + percentages.y
[31819] Fix | Delete
}), Object(external_wp_element_["createElement"])(Media, {
[31820] Fix | Delete
alt: Object(external_wp_i18n_["__"])('Media preview'),
[31821] Fix | Delete
autoPlay: autoPlay,
[31822] Fix | Delete
mediaRef: this.mediaRef,
[31823] Fix | Delete
onLoad: this.updateBounds,
[31824] Fix | Delete
src: url
[31825] Fix | Delete
}), Object(external_wp_element_["createElement"])(FocalPoint, {
[31826] Fix | Delete
coordinates: iconCoordinates,
[31827] Fix | Delete
isDragging: isDragging
[31828] Fix | Delete
}))), Object(external_wp_element_["createElement"])(FocalPointPickerControls, {
[31829] Fix | Delete
percentages: percentages,
[31830] Fix | Delete
onChange: this.updateValue
[31831] Fix | Delete
}));
[31832] Fix | Delete
}
[31833] Fix | Delete
}]);
[31834] Fix | Delete
[31835] Fix | Delete
return FocalPointPicker;
[31836] Fix | Delete
}(external_wp_element_["Component"]);
[31837] Fix | Delete
focal_point_picker_FocalPointPicker.defaultProps = {
[31838] Fix | Delete
autoPlay: true,
[31839] Fix | Delete
onDragStart: external_lodash_["noop"],
[31840] Fix | Delete
onDragEnd: external_lodash_["noop"],
[31841] Fix | Delete
onChange: external_lodash_["noop"],
[31842] Fix | Delete
value: {
[31843] Fix | Delete
x: 0.5,
[31844] Fix | Delete
y: 0.5
[31845] Fix | Delete
},
[31846] Fix | Delete
url: null
[31847] Fix | Delete
};
[31848] Fix | Delete
/* harmony default export */ var focal_point_picker = (Object(external_wp_compose_["compose"])([external_wp_compose_["withInstanceId"], with_focus_outside])(focal_point_picker_FocalPointPicker));
[31849] Fix | Delete
[31850] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/focusable-iframe/index.js
[31851] Fix | Delete
[31852] Fix | Delete
[31853] Fix | Delete
[31854] Fix | Delete
[31855] Fix | Delete
/**
[31856] Fix | Delete
* WordPress dependencies
[31857] Fix | Delete
*/
[31858] Fix | Delete
[31859] Fix | Delete
function FocusableIframe(_ref) {
[31860] Fix | Delete
var iframeRef = _ref.iframeRef,
[31861] Fix | Delete
onFocus = _ref.onFocus,
[31862] Fix | Delete
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["iframeRef", "onFocus"]);
[31863] Fix | Delete
[31864] Fix | Delete
var fallbackRef = Object(external_wp_element_["useRef"])();
[31865] Fix | Delete
var ref = iframeRef || fallbackRef;
[31866] Fix | Delete
Object(external_wp_element_["useEffect"])(function () {
[31867] Fix | Delete
var iframe = ref.current;
[31868] Fix | Delete
var ownerDocument = iframe.ownerDocument;
[31869] Fix | Delete
var defaultView = ownerDocument.defaultView;
[31870] Fix | Delete
var FocusEvent = defaultView.FocusEvent;
[31871] Fix | Delete
/**
[31872] Fix | Delete
* Checks whether the iframe is the activeElement, inferring that it has
[31873] Fix | Delete
* then received focus, and calls the `onFocus` prop callback.
[31874] Fix | Delete
*/
[31875] Fix | Delete
[31876] Fix | Delete
function checkFocus() {
[31877] Fix | Delete
if (ownerDocument.activeElement !== iframe) {
[31878] Fix | Delete
return;
[31879] Fix | Delete
}
[31880] Fix | Delete
[31881] Fix | Delete
var focusEvent = new FocusEvent('focus', {
[31882] Fix | Delete
bubbles: true
[31883] Fix | Delete
});
[31884] Fix | Delete
iframe.dispatchEvent(focusEvent);
[31885] Fix | Delete
[31886] Fix | Delete
if (onFocus) {
[31887] Fix | Delete
onFocus(focusEvent);
[31888] Fix | Delete
}
[31889] Fix | Delete
}
[31890] Fix | Delete
[31891] Fix | Delete
defaultView.addEventListener('blur', checkFocus);
[31892] Fix | Delete
return function () {
[31893] Fix | Delete
defaultView.removeEventListener('blur', checkFocus);
[31894] Fix | Delete
};
[31895] Fix | Delete
}, [onFocus]); // Disable reason: The rendered iframe is a pass-through component,
[31896] Fix | Delete
// assigning props inherited from the rendering parent. It's the
[31897] Fix | Delete
// responsibility of the parent to assign a title.
[31898] Fix | Delete
// eslint-disable-next-line jsx-a11y/iframe-has-title
[31899] Fix | Delete
[31900] Fix | Delete
return Object(external_wp_element_["createElement"])("iframe", Object(esm_extends["a" /* default */])({
[31901] Fix | Delete
ref: ref
[31902] Fix | Delete
}, props));
[31903] Fix | Delete
}
[31904] Fix | Delete
[31905] Fix | Delete
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/text-color.js
[31906] Fix | Delete
var text_color = __webpack_require__("uGfJ");
[31907] Fix | Delete
[31908] Fix | Delete
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/range-control/utils.js
[31909] Fix | Delete
[31910] Fix | Delete
[31911] Fix | Delete
/**
[31912] Fix | Delete
* External dependencies
[31913] Fix | Delete
*/
[31914] Fix | Delete
[31915] Fix | Delete
/**
[31916] Fix | Delete
* WordPress dependencies
[31917] Fix | Delete
*/
[31918] Fix | Delete
[31919] Fix | Delete
[31920] Fix | Delete
/**
[31921] Fix | Delete
* Internal dependencies
[31922] Fix | Delete
*/
[31923] Fix | Delete
[31924] Fix | Delete
[31925] Fix | Delete
/**
[31926] Fix | Delete
* A float supported clamp function for a specific value.
[31927] Fix | Delete
*
[31928] Fix | Delete
* @param {number|null} value The value to clamp.
[31929] Fix | Delete
* @param {number} min The minimum value.
[31930] Fix | Delete
* @param {number} max The maximum value.
[31931] Fix | Delete
*
[31932] Fix | Delete
* @return {number} A (float) number
[31933] Fix | Delete
*/
[31934] Fix | Delete
[31935] Fix | Delete
function floatClamp(value, min, max) {
[31936] Fix | Delete
if (typeof value !== 'number') {
[31937] Fix | Delete
return null;
[31938] Fix | Delete
}
[31939] Fix | Delete
[31940] Fix | Delete
return parseFloat(Object(external_lodash_["clamp"])(value, min, max));
[31941] Fix | Delete
}
[31942] Fix | Delete
/**
[31943] Fix | Delete
* Hook to store a clamped value, derived from props.
[31944] Fix | Delete
*
[31945] Fix | Delete
* @param {Object} settings Hook settings.
[31946] Fix | Delete
* @param {number} settings.min The minimum value.
[31947] Fix | Delete
* @param {number} settings.max The maximum value.
[31948] Fix | Delete
* @param {number} settings.value The current value.
[31949] Fix | Delete
* @param {any} settings.initial The initial value.
[31950] Fix | Delete
*
[31951] Fix | Delete
* @return {[*, Function]} The controlled value and the value setter.
[31952] Fix | Delete
*/
[31953] Fix | Delete
[31954] Fix | Delete
function useControlledRangeValue(_ref) {
[31955] Fix | Delete
var min = _ref.min,
[31956] Fix | Delete
max = _ref.max,
[31957] Fix | Delete
valueProp = _ref.value,
[31958] Fix | Delete
initial = _ref.initial;
[31959] Fix | Delete
[31960] Fix | Delete
var _useControlledState = use_controlled_state(floatClamp(valueProp, min, max), {
[31961] Fix | Delete
initial: initial,
[31962] Fix | Delete
fallback: null
[31963] Fix | Delete
}),
[31964] Fix | Delete
_useControlledState2 = Object(slicedToArray["a" /* default */])(_useControlledState, 2),
[31965] Fix | Delete
state = _useControlledState2[0],
[31966] Fix | Delete
setInternalState = _useControlledState2[1];
[31967] Fix | Delete
[31968] Fix | Delete
var setState = Object(external_wp_element_["useCallback"])(function (nextValue) {
[31969] Fix | Delete
if (nextValue === null) {
[31970] Fix | Delete
setInternalState(null);
[31971] Fix | Delete
} else {
[31972] Fix | Delete
setInternalState(floatClamp(nextValue, min, max));
[31973] Fix | Delete
}
[31974] Fix | Delete
}, [min, max]);
[31975] Fix | Delete
return [state, setState];
[31976] Fix | Delete
}
[31977] Fix | Delete
/**
[31978] Fix | Delete
* Hook to encapsulate the debouncing "hover" to better handle the showing
[31979] Fix | Delete
* and hiding of the Tooltip.
[31980] Fix | Delete
*
[31981] Fix | Delete
* @param {Object} settings Hook settings.
[31982] Fix | Delete
* @param {Function} [settings.onShow=noop] A callback function invoked when the element is shown.
[31983] Fix | Delete
* @param {Function} [settings.onHide=noop] A callback function invoked when the element is hidden.
[31984] Fix | Delete
* @param {Function} [settings.onMouseMove=noop] A callback function invoked when the mouse is moved.
[31985] Fix | Delete
* @param {Function} [settings.onMouseLeave=noop] A callback function invoked when the mouse is moved out of the element.
[31986] Fix | Delete
* @param {number} [settings.timeout=300] Timeout before the element is shown or hidden.
[31987] Fix | Delete
*
[31988] Fix | Delete
* @return {Object} Bound properties for use on a React.Node.
[31989] Fix | Delete
*/
[31990] Fix | Delete
[31991] Fix | Delete
function useDebouncedHoverInteraction(_ref2) {
[31992] Fix | Delete
var _ref2$onHide = _ref2.onHide,
[31993] Fix | Delete
onHide = _ref2$onHide === void 0 ? external_lodash_["noop"] : _ref2$onHide,
[31994] Fix | Delete
_ref2$onMouseLeave = _ref2.onMouseLeave,
[31995] Fix | Delete
onMouseLeave = _ref2$onMouseLeave === void 0 ? external_lodash_["noop"] : _ref2$onMouseLeave,
[31996] Fix | Delete
_ref2$onMouseMove = _ref2.onMouseMove,
[31997] Fix | Delete
onMouseMove = _ref2$onMouseMove === void 0 ? external_lodash_["noop"] : _ref2$onMouseMove,
[31998] Fix | Delete
_ref2$onShow = _ref2.onShow,
[31999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function