Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../js/dist
File: data.js
*/
[4000] Fix | Delete
/** @typedef {import('../../types').MapSelect} MapSelect */
[4001] Fix | Delete
/**
[4002] Fix | Delete
* @typedef {import('../../types').UseSelectReturn<T>} UseSelectReturn
[4003] Fix | Delete
* @template {MapSelect|StoreDescriptor<any>} T
[4004] Fix | Delete
*/
[4005] Fix | Delete
[4006] Fix | Delete
function Store(registry, suspense) {
[4007] Fix | Delete
const select = suspense ? registry.suspendSelect : registry.select;
[4008] Fix | Delete
const queueContext = {};
[4009] Fix | Delete
let lastMapSelect;
[4010] Fix | Delete
let lastMapResult;
[4011] Fix | Delete
let lastMapResultValid = false;
[4012] Fix | Delete
let lastIsAsync;
[4013] Fix | Delete
let subscriber;
[4014] Fix | Delete
let didWarnUnstableReference;
[4015] Fix | Delete
const storeStatesOnMount = new Map();
[4016] Fix | Delete
function getStoreState(name) {
[4017] Fix | Delete
var _registry$stores$name;
[4018] Fix | Delete
// If there's no store property (custom generic store), return an empty
[4019] Fix | Delete
// object. When comparing the state, the empty objects will cause the
[4020] Fix | Delete
// equality check to fail, setting `lastMapResultValid` to false.
[4021] Fix | Delete
return (_registry$stores$name = registry.stores[name]?.store?.getState?.()) !== null && _registry$stores$name !== void 0 ? _registry$stores$name : {};
[4022] Fix | Delete
}
[4023] Fix | Delete
const createSubscriber = stores => {
[4024] Fix | Delete
// The set of stores the `subscribe` function is supposed to subscribe to. Here it is
[4025] Fix | Delete
// initialized, and then the `updateStores` function can add new stores to it.
[4026] Fix | Delete
const activeStores = [...stores];
[4027] Fix | Delete
[4028] Fix | Delete
// The `subscribe` function, which is passed to the `useSyncExternalStore` hook, could
[4029] Fix | Delete
// be called multiple times to establish multiple subscriptions. That's why we need to
[4030] Fix | Delete
// keep a set of active subscriptions;
[4031] Fix | Delete
const activeSubscriptions = new Set();
[4032] Fix | Delete
function subscribe(listener) {
[4033] Fix | Delete
// Maybe invalidate the value right after subscription was created.
[4034] Fix | Delete
// React will call `getValue` after subscribing, to detect store
[4035] Fix | Delete
// updates that happened in the interval between the `getValue` call
[4036] Fix | Delete
// during render and creating the subscription, which is slightly
[4037] Fix | Delete
// delayed. We need to ensure that this second `getValue` call will
[4038] Fix | Delete
// compute a fresh value only if any of the store states have
[4039] Fix | Delete
// changed in the meantime.
[4040] Fix | Delete
if (lastMapResultValid) {
[4041] Fix | Delete
for (const name of activeStores) {
[4042] Fix | Delete
if (storeStatesOnMount.get(name) !== getStoreState(name)) {
[4043] Fix | Delete
lastMapResultValid = false;
[4044] Fix | Delete
}
[4045] Fix | Delete
}
[4046] Fix | Delete
}
[4047] Fix | Delete
storeStatesOnMount.clear();
[4048] Fix | Delete
const onStoreChange = () => {
[4049] Fix | Delete
// Invalidate the value on store update, so that a fresh value is computed.
[4050] Fix | Delete
lastMapResultValid = false;
[4051] Fix | Delete
listener();
[4052] Fix | Delete
};
[4053] Fix | Delete
const onChange = () => {
[4054] Fix | Delete
if (lastIsAsync) {
[4055] Fix | Delete
renderQueue.add(queueContext, onStoreChange);
[4056] Fix | Delete
} else {
[4057] Fix | Delete
onStoreChange();
[4058] Fix | Delete
}
[4059] Fix | Delete
};
[4060] Fix | Delete
const unsubs = [];
[4061] Fix | Delete
function subscribeStore(storeName) {
[4062] Fix | Delete
unsubs.push(registry.subscribe(onChange, storeName));
[4063] Fix | Delete
}
[4064] Fix | Delete
for (const storeName of activeStores) {
[4065] Fix | Delete
subscribeStore(storeName);
[4066] Fix | Delete
}
[4067] Fix | Delete
activeSubscriptions.add(subscribeStore);
[4068] Fix | Delete
return () => {
[4069] Fix | Delete
activeSubscriptions.delete(subscribeStore);
[4070] Fix | Delete
for (const unsub of unsubs.values()) {
[4071] Fix | Delete
// The return value of the subscribe function could be undefined if the store is a custom generic store.
[4072] Fix | Delete
unsub?.();
[4073] Fix | Delete
}
[4074] Fix | Delete
// Cancel existing store updates that were already scheduled.
[4075] Fix | Delete
renderQueue.cancel(queueContext);
[4076] Fix | Delete
};
[4077] Fix | Delete
}
[4078] Fix | Delete
[4079] Fix | Delete
// Check if `newStores` contains some stores we're not subscribed to yet, and add them.
[4080] Fix | Delete
function updateStores(newStores) {
[4081] Fix | Delete
for (const newStore of newStores) {
[4082] Fix | Delete
if (activeStores.includes(newStore)) {
[4083] Fix | Delete
continue;
[4084] Fix | Delete
}
[4085] Fix | Delete
[4086] Fix | Delete
// New `subscribe` calls will subscribe to `newStore`, too.
[4087] Fix | Delete
activeStores.push(newStore);
[4088] Fix | Delete
[4089] Fix | Delete
// Add `newStore` to existing subscriptions.
[4090] Fix | Delete
for (const subscription of activeSubscriptions) {
[4091] Fix | Delete
subscription(newStore);
[4092] Fix | Delete
}
[4093] Fix | Delete
}
[4094] Fix | Delete
}
[4095] Fix | Delete
return {
[4096] Fix | Delete
subscribe,
[4097] Fix | Delete
updateStores
[4098] Fix | Delete
};
[4099] Fix | Delete
};
[4100] Fix | Delete
return (mapSelect, isAsync) => {
[4101] Fix | Delete
function updateValue() {
[4102] Fix | Delete
// If the last value is valid, and the `mapSelect` callback hasn't changed,
[4103] Fix | Delete
// then we can safely return the cached value. The value can change only on
[4104] Fix | Delete
// store update, and in that case value will be invalidated by the listener.
[4105] Fix | Delete
if (lastMapResultValid && mapSelect === lastMapSelect) {
[4106] Fix | Delete
return lastMapResult;
[4107] Fix | Delete
}
[4108] Fix | Delete
const listeningStores = {
[4109] Fix | Delete
current: null
[4110] Fix | Delete
};
[4111] Fix | Delete
const mapResult = registry.__unstableMarkListeningStores(() => mapSelect(select, registry), listeningStores);
[4112] Fix | Delete
if (false) {}
[4113] Fix | Delete
if (!subscriber) {
[4114] Fix | Delete
for (const name of listeningStores.current) {
[4115] Fix | Delete
storeStatesOnMount.set(name, getStoreState(name));
[4116] Fix | Delete
}
[4117] Fix | Delete
subscriber = createSubscriber(listeningStores.current);
[4118] Fix | Delete
} else {
[4119] Fix | Delete
subscriber.updateStores(listeningStores.current);
[4120] Fix | Delete
}
[4121] Fix | Delete
[4122] Fix | Delete
// If the new value is shallow-equal to the old one, keep the old one so
[4123] Fix | Delete
// that we don't trigger unwanted updates that do a `===` check.
[4124] Fix | Delete
if (!external_wp_isShallowEqual_default()(lastMapResult, mapResult)) {
[4125] Fix | Delete
lastMapResult = mapResult;
[4126] Fix | Delete
}
[4127] Fix | Delete
lastMapSelect = mapSelect;
[4128] Fix | Delete
lastMapResultValid = true;
[4129] Fix | Delete
}
[4130] Fix | Delete
function getValue() {
[4131] Fix | Delete
// Update the value in case it's been invalidated or `mapSelect` has changed.
[4132] Fix | Delete
updateValue();
[4133] Fix | Delete
return lastMapResult;
[4134] Fix | Delete
}
[4135] Fix | Delete
[4136] Fix | Delete
// When transitioning from async to sync mode, cancel existing store updates
[4137] Fix | Delete
// that have been scheduled, and invalidate the value so that it's freshly
[4138] Fix | Delete
// computed. It might have been changed by the update we just cancelled.
[4139] Fix | Delete
if (lastIsAsync && !isAsync) {
[4140] Fix | Delete
lastMapResultValid = false;
[4141] Fix | Delete
renderQueue.cancel(queueContext);
[4142] Fix | Delete
}
[4143] Fix | Delete
updateValue();
[4144] Fix | Delete
lastIsAsync = isAsync;
[4145] Fix | Delete
[4146] Fix | Delete
// Return a pair of functions that can be passed to `useSyncExternalStore`.
[4147] Fix | Delete
return {
[4148] Fix | Delete
subscribe: subscriber.subscribe,
[4149] Fix | Delete
getValue
[4150] Fix | Delete
};
[4151] Fix | Delete
};
[4152] Fix | Delete
}
[4153] Fix | Delete
function useStaticSelect(storeName) {
[4154] Fix | Delete
return useRegistry().select(storeName);
[4155] Fix | Delete
}
[4156] Fix | Delete
function useMappingSelect(suspense, mapSelect, deps) {
[4157] Fix | Delete
const registry = useRegistry();
[4158] Fix | Delete
const isAsync = useAsyncMode();
[4159] Fix | Delete
const store = (0,external_wp_element_namespaceObject.useMemo)(() => Store(registry, suspense), [registry, suspense]);
[4160] Fix | Delete
[4161] Fix | Delete
// These are "pass-through" dependencies from the parent hook,
[4162] Fix | Delete
// and the parent should catch any hook rule violations.
[4163] Fix | Delete
// eslint-disable-next-line react-hooks/exhaustive-deps
[4164] Fix | Delete
const selector = (0,external_wp_element_namespaceObject.useCallback)(mapSelect, deps);
[4165] Fix | Delete
const {
[4166] Fix | Delete
subscribe,
[4167] Fix | Delete
getValue
[4168] Fix | Delete
} = store(selector, isAsync);
[4169] Fix | Delete
const result = (0,external_wp_element_namespaceObject.useSyncExternalStore)(subscribe, getValue, getValue);
[4170] Fix | Delete
(0,external_wp_element_namespaceObject.useDebugValue)(result);
[4171] Fix | Delete
return result;
[4172] Fix | Delete
}
[4173] Fix | Delete
[4174] Fix | Delete
/**
[4175] Fix | Delete
* Custom react hook for retrieving props from registered selectors.
[4176] Fix | Delete
*
[4177] Fix | Delete
* In general, this custom React hook follows the
[4178] Fix | Delete
* [rules of hooks](https://reactjs.org/docs/hooks-rules.html).
[4179] Fix | Delete
*
[4180] Fix | Delete
* @template {MapSelect | StoreDescriptor<any>} T
[4181] Fix | Delete
* @param {T} mapSelect Function called on every state change. The returned value is
[4182] Fix | Delete
* exposed to the component implementing this hook. The function
[4183] Fix | Delete
* receives the `registry.select` method on the first argument
[4184] Fix | Delete
* and the `registry` on the second argument.
[4185] Fix | Delete
* When a store key is passed, all selectors for the store will be
[4186] Fix | Delete
* returned. This is only meant for usage of these selectors in event
[4187] Fix | Delete
* callbacks, not for data needed to create the element tree.
[4188] Fix | Delete
* @param {unknown[]} deps If provided, this memoizes the mapSelect so the same `mapSelect` is
[4189] Fix | Delete
* invoked on every state change unless the dependencies change.
[4190] Fix | Delete
*
[4191] Fix | Delete
* @example
[4192] Fix | Delete
* ```js
[4193] Fix | Delete
* import { useSelect } from '@wordpress/data';
[4194] Fix | Delete
* import { store as myCustomStore } from 'my-custom-store';
[4195] Fix | Delete
*
[4196] Fix | Delete
* function HammerPriceDisplay( { currency } ) {
[4197] Fix | Delete
* const price = useSelect( ( select ) => {
[4198] Fix | Delete
* return select( myCustomStore ).getPrice( 'hammer', currency );
[4199] Fix | Delete
* }, [ currency ] );
[4200] Fix | Delete
* return new Intl.NumberFormat( 'en-US', {
[4201] Fix | Delete
* style: 'currency',
[4202] Fix | Delete
* currency,
[4203] Fix | Delete
* } ).format( price );
[4204] Fix | Delete
* }
[4205] Fix | Delete
*
[4206] Fix | Delete
* // Rendered in the application:
[4207] Fix | Delete
* // <HammerPriceDisplay currency="USD" />
[4208] Fix | Delete
* ```
[4209] Fix | Delete
*
[4210] Fix | Delete
* In the above example, when `HammerPriceDisplay` is rendered into an
[4211] Fix | Delete
* application, the price will be retrieved from the store state using the
[4212] Fix | Delete
* `mapSelect` callback on `useSelect`. If the currency prop changes then
[4213] Fix | Delete
* any price in the state for that currency is retrieved. If the currency prop
[4214] Fix | Delete
* doesn't change and other props are passed in that do change, the price will
[4215] Fix | Delete
* not change because the dependency is just the currency.
[4216] Fix | Delete
*
[4217] Fix | Delete
* When data is only used in an event callback, the data should not be retrieved
[4218] Fix | Delete
* on render, so it may be useful to get the selectors function instead.
[4219] Fix | Delete
*
[4220] Fix | Delete
* **Don't use `useSelect` this way when calling the selectors in the render
[4221] Fix | Delete
* function because your component won't re-render on a data change.**
[4222] Fix | Delete
*
[4223] Fix | Delete
* ```js
[4224] Fix | Delete
* import { useSelect } from '@wordpress/data';
[4225] Fix | Delete
* import { store as myCustomStore } from 'my-custom-store';
[4226] Fix | Delete
*
[4227] Fix | Delete
* function Paste( { children } ) {
[4228] Fix | Delete
* const { getSettings } = useSelect( myCustomStore );
[4229] Fix | Delete
* function onPaste() {
[4230] Fix | Delete
* // Do something with the settings.
[4231] Fix | Delete
* const settings = getSettings();
[4232] Fix | Delete
* }
[4233] Fix | Delete
* return <div onPaste={ onPaste }>{ children }</div>;
[4234] Fix | Delete
* }
[4235] Fix | Delete
* ```
[4236] Fix | Delete
* @return {UseSelectReturn<T>} A custom react hook.
[4237] Fix | Delete
*/
[4238] Fix | Delete
function useSelect(mapSelect, deps) {
[4239] Fix | Delete
// On initial call, on mount, determine the mode of this `useSelect` call
[4240] Fix | Delete
// and then never allow it to change on subsequent updates.
[4241] Fix | Delete
const staticSelectMode = typeof mapSelect !== 'function';
[4242] Fix | Delete
const staticSelectModeRef = (0,external_wp_element_namespaceObject.useRef)(staticSelectMode);
[4243] Fix | Delete
if (staticSelectMode !== staticSelectModeRef.current) {
[4244] Fix | Delete
const prevMode = staticSelectModeRef.current ? 'static' : 'mapping';
[4245] Fix | Delete
const nextMode = staticSelectMode ? 'static' : 'mapping';
[4246] Fix | Delete
throw new Error(`Switching useSelect from ${prevMode} to ${nextMode} is not allowed`);
[4247] Fix | Delete
}
[4248] Fix | Delete
[4249] Fix | Delete
/* eslint-disable react-hooks/rules-of-hooks */
[4250] Fix | Delete
// `staticSelectMode` is not allowed to change during the hook instance's,
[4251] Fix | Delete
// lifetime, so the rules of hooks are not really violated.
[4252] Fix | Delete
return staticSelectMode ? useStaticSelect(mapSelect) : useMappingSelect(false, mapSelect, deps);
[4253] Fix | Delete
/* eslint-enable react-hooks/rules-of-hooks */
[4254] Fix | Delete
}
[4255] Fix | Delete
[4256] Fix | Delete
/**
[4257] Fix | Delete
* A variant of the `useSelect` hook that has the same API, but is a compatible
[4258] Fix | Delete
* Suspense-enabled data source.
[4259] Fix | Delete
*
[4260] Fix | Delete
* @template {MapSelect} T
[4261] Fix | Delete
* @param {T} mapSelect Function called on every state change. The
[4262] Fix | Delete
* returned value is exposed to the component
[4263] Fix | Delete
* using this hook. The function receives the
[4264] Fix | Delete
* `registry.suspendSelect` method as the first
[4265] Fix | Delete
* argument and the `registry` as the second one.
[4266] Fix | Delete
* @param {Array} deps A dependency array used to memoize the `mapSelect`
[4267] Fix | Delete
* so that the same `mapSelect` is invoked on every
[4268] Fix | Delete
* state change unless the dependencies change.
[4269] Fix | Delete
*
[4270] Fix | Delete
* @throws {Promise} A suspense Promise that is thrown if any of the called
[4271] Fix | Delete
* selectors is in an unresolved state.
[4272] Fix | Delete
*
[4273] Fix | Delete
* @return {ReturnType<T>} Data object returned by the `mapSelect` function.
[4274] Fix | Delete
*/
[4275] Fix | Delete
function useSuspenseSelect(mapSelect, deps) {
[4276] Fix | Delete
return useMappingSelect(true, mapSelect, deps);
[4277] Fix | Delete
}
[4278] Fix | Delete
[4279] Fix | Delete
;// CONCATENATED MODULE: external "ReactJSXRuntime"
[4280] Fix | Delete
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
[4281] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-select/index.js
[4282] Fix | Delete
/**
[4283] Fix | Delete
* WordPress dependencies
[4284] Fix | Delete
*/
[4285] Fix | Delete
[4286] Fix | Delete
[4287] Fix | Delete
/**
[4288] Fix | Delete
* Internal dependencies
[4289] Fix | Delete
*/
[4290] Fix | Delete
[4291] Fix | Delete
[4292] Fix | Delete
/** @typedef {import('react').ComponentType} ComponentType */
[4293] Fix | Delete
[4294] Fix | Delete
/**
[4295] Fix | Delete
* Higher-order component used to inject state-derived props using registered
[4296] Fix | Delete
* selectors.
[4297] Fix | Delete
*
[4298] Fix | Delete
* @param {Function} mapSelectToProps Function called on every state change,
[4299] Fix | Delete
* expected to return object of props to
[4300] Fix | Delete
* merge with the component's own props.
[4301] Fix | Delete
*
[4302] Fix | Delete
* @example
[4303] Fix | Delete
* ```js
[4304] Fix | Delete
* import { withSelect } from '@wordpress/data';
[4305] Fix | Delete
* import { store as myCustomStore } from 'my-custom-store';
[4306] Fix | Delete
*
[4307] Fix | Delete
* function PriceDisplay( { price, currency } ) {
[4308] Fix | Delete
* return new Intl.NumberFormat( 'en-US', {
[4309] Fix | Delete
* style: 'currency',
[4310] Fix | Delete
* currency,
[4311] Fix | Delete
* } ).format( price );
[4312] Fix | Delete
* }
[4313] Fix | Delete
*
[4314] Fix | Delete
* const HammerPriceDisplay = withSelect( ( select, ownProps ) => {
[4315] Fix | Delete
* const { getPrice } = select( myCustomStore );
[4316] Fix | Delete
* const { currency } = ownProps;
[4317] Fix | Delete
*
[4318] Fix | Delete
* return {
[4319] Fix | Delete
* price: getPrice( 'hammer', currency ),
[4320] Fix | Delete
* };
[4321] Fix | Delete
* } )( PriceDisplay );
[4322] Fix | Delete
*
[4323] Fix | Delete
* // Rendered in the application:
[4324] Fix | Delete
* //
[4325] Fix | Delete
* // <HammerPriceDisplay currency="USD" />
[4326] Fix | Delete
* ```
[4327] Fix | Delete
* In the above example, when `HammerPriceDisplay` is rendered into an
[4328] Fix | Delete
* application, it will pass the price into the underlying `PriceDisplay`
[4329] Fix | Delete
* component and update automatically if the price of a hammer ever changes in
[4330] Fix | Delete
* the store.
[4331] Fix | Delete
*
[4332] Fix | Delete
* @return {ComponentType} Enhanced component with merged state data props.
[4333] Fix | Delete
*/
[4334] Fix | Delete
[4335] Fix | Delete
const withSelect = mapSelectToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => (0,external_wp_compose_namespaceObject.pure)(ownProps => {
[4336] Fix | Delete
const mapSelect = (select, registry) => mapSelectToProps(select, ownProps, registry);
[4337] Fix | Delete
const mergeProps = useSelect(mapSelect);
[4338] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, {
[4339] Fix | Delete
...ownProps,
[4340] Fix | Delete
...mergeProps
[4341] Fix | Delete
});
[4342] Fix | Delete
}), 'withSelect');
[4343] Fix | Delete
/* harmony default export */ const with_select = (withSelect);
[4344] Fix | Delete
[4345] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/use-dispatch/use-dispatch-with-map.js
[4346] Fix | Delete
/**
[4347] Fix | Delete
* WordPress dependencies
[4348] Fix | Delete
*/
[4349] Fix | Delete
[4350] Fix | Delete
[4351] Fix | Delete
[4352] Fix | Delete
/**
[4353] Fix | Delete
* Internal dependencies
[4354] Fix | Delete
*/
[4355] Fix | Delete
[4356] Fix | Delete
[4357] Fix | Delete
/**
[4358] Fix | Delete
* Custom react hook for returning aggregate dispatch actions using the provided
[4359] Fix | Delete
* dispatchMap.
[4360] Fix | Delete
*
[4361] Fix | Delete
* Currently this is an internal api only and is implemented by `withDispatch`
[4362] Fix | Delete
*
[4363] Fix | Delete
* @param {Function} dispatchMap Receives the `registry.dispatch` function as
[4364] Fix | Delete
* the first argument and the `registry` object
[4365] Fix | Delete
* as the second argument. Should return an
[4366] Fix | Delete
* object mapping props to functions.
[4367] Fix | Delete
* @param {Array} deps An array of dependencies for the hook.
[4368] Fix | Delete
* @return {Object} An object mapping props to functions created by the passed
[4369] Fix | Delete
* in dispatchMap.
[4370] Fix | Delete
*/
[4371] Fix | Delete
const useDispatchWithMap = (dispatchMap, deps) => {
[4372] Fix | Delete
const registry = useRegistry();
[4373] Fix | Delete
const currentDispatchMap = (0,external_wp_element_namespaceObject.useRef)(dispatchMap);
[4374] Fix | Delete
(0,external_wp_compose_namespaceObject.useIsomorphicLayoutEffect)(() => {
[4375] Fix | Delete
currentDispatchMap.current = dispatchMap;
[4376] Fix | Delete
});
[4377] Fix | Delete
return (0,external_wp_element_namespaceObject.useMemo)(() => {
[4378] Fix | Delete
const currentDispatchProps = currentDispatchMap.current(registry.dispatch, registry);
[4379] Fix | Delete
return Object.fromEntries(Object.entries(currentDispatchProps).map(([propName, dispatcher]) => {
[4380] Fix | Delete
if (typeof dispatcher !== 'function') {
[4381] Fix | Delete
// eslint-disable-next-line no-console
[4382] Fix | Delete
console.warn(`Property ${propName} returned from dispatchMap in useDispatchWithMap must be a function.`);
[4383] Fix | Delete
}
[4384] Fix | Delete
return [propName, (...args) => currentDispatchMap.current(registry.dispatch, registry)[propName](...args)];
[4385] Fix | Delete
}));
[4386] Fix | Delete
}, [registry, ...deps]);
[4387] Fix | Delete
};
[4388] Fix | Delete
/* harmony default export */ const use_dispatch_with_map = (useDispatchWithMap);
[4389] Fix | Delete
[4390] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-dispatch/index.js
[4391] Fix | Delete
/**
[4392] Fix | Delete
* WordPress dependencies
[4393] Fix | Delete
*/
[4394] Fix | Delete
[4395] Fix | Delete
[4396] Fix | Delete
/**
[4397] Fix | Delete
* Internal dependencies
[4398] Fix | Delete
*/
[4399] Fix | Delete
[4400] Fix | Delete
[4401] Fix | Delete
/** @typedef {import('react').ComponentType} ComponentType */
[4402] Fix | Delete
[4403] Fix | Delete
/**
[4404] Fix | Delete
* Higher-order component used to add dispatch props using registered action
[4405] Fix | Delete
* creators.
[4406] Fix | Delete
*
[4407] Fix | Delete
* @param {Function} mapDispatchToProps A function of returning an object of
[4408] Fix | Delete
* prop names where value is a
[4409] Fix | Delete
* dispatch-bound action creator, or a
[4410] Fix | Delete
* function to be called with the
[4411] Fix | Delete
* component's props and returning an
[4412] Fix | Delete
* action creator.
[4413] Fix | Delete
*
[4414] Fix | Delete
* @example
[4415] Fix | Delete
* ```jsx
[4416] Fix | Delete
* function Button( { onClick, children } ) {
[4417] Fix | Delete
* return <button type="button" onClick={ onClick }>{ children }</button>;
[4418] Fix | Delete
* }
[4419] Fix | Delete
*
[4420] Fix | Delete
* import { withDispatch } from '@wordpress/data';
[4421] Fix | Delete
* import { store as myCustomStore } from 'my-custom-store';
[4422] Fix | Delete
*
[4423] Fix | Delete
* const SaleButton = withDispatch( ( dispatch, ownProps ) => {
[4424] Fix | Delete
* const { startSale } = dispatch( myCustomStore );
[4425] Fix | Delete
* const { discountPercent } = ownProps;
[4426] Fix | Delete
*
[4427] Fix | Delete
* return {
[4428] Fix | Delete
* onClick() {
[4429] Fix | Delete
* startSale( discountPercent );
[4430] Fix | Delete
* },
[4431] Fix | Delete
* };
[4432] Fix | Delete
* } )( Button );
[4433] Fix | Delete
*
[4434] Fix | Delete
* // Rendered in the application:
[4435] Fix | Delete
* //
[4436] Fix | Delete
* // <SaleButton discountPercent="20">Start Sale!</SaleButton>
[4437] Fix | Delete
* ```
[4438] Fix | Delete
*
[4439] Fix | Delete
* @example
[4440] Fix | Delete
* In the majority of cases, it will be sufficient to use only two first params
[4441] Fix | Delete
* passed to `mapDispatchToProps` as illustrated in the previous example.
[4442] Fix | Delete
* However, there might be some very advanced use cases where using the
[4443] Fix | Delete
* `registry` object might be used as a tool to optimize the performance of
[4444] Fix | Delete
* your component. Using `select` function from the registry might be useful
[4445] Fix | Delete
* when you need to fetch some dynamic data from the store at the time when the
[4446] Fix | Delete
* event is fired, but at the same time, you never use it to render your
[4447] Fix | Delete
* component. In such scenario, you can avoid using the `withSelect` higher
[4448] Fix | Delete
* order component to compute such prop, which might lead to unnecessary
[4449] Fix | Delete
* re-renders of your component caused by its frequent value change.
[4450] Fix | Delete
* Keep in mind, that `mapDispatchToProps` must return an object with functions
[4451] Fix | Delete
* only.
[4452] Fix | Delete
*
[4453] Fix | Delete
* ```jsx
[4454] Fix | Delete
* function Button( { onClick, children } ) {
[4455] Fix | Delete
* return <button type="button" onClick={ onClick }>{ children }</button>;
[4456] Fix | Delete
* }
[4457] Fix | Delete
*
[4458] Fix | Delete
* import { withDispatch } from '@wordpress/data';
[4459] Fix | Delete
* import { store as myCustomStore } from 'my-custom-store';
[4460] Fix | Delete
*
[4461] Fix | Delete
* const SaleButton = withDispatch( ( dispatch, ownProps, { select } ) => {
[4462] Fix | Delete
* // Stock number changes frequently.
[4463] Fix | Delete
* const { getStockNumber } = select( myCustomStore );
[4464] Fix | Delete
* const { startSale } = dispatch( myCustomStore );
[4465] Fix | Delete
* return {
[4466] Fix | Delete
* onClick() {
[4467] Fix | Delete
* const discountPercent = getStockNumber() > 50 ? 10 : 20;
[4468] Fix | Delete
* startSale( discountPercent );
[4469] Fix | Delete
* },
[4470] Fix | Delete
* };
[4471] Fix | Delete
* } )( Button );
[4472] Fix | Delete
*
[4473] Fix | Delete
* // Rendered in the application:
[4474] Fix | Delete
* //
[4475] Fix | Delete
* // <SaleButton>Start Sale!</SaleButton>
[4476] Fix | Delete
* ```
[4477] Fix | Delete
*
[4478] Fix | Delete
* _Note:_ It is important that the `mapDispatchToProps` function always
[4479] Fix | Delete
* returns an object with the same keys. For example, it should not contain
[4480] Fix | Delete
* conditions under which a different value would be returned.
[4481] Fix | Delete
*
[4482] Fix | Delete
* @return {ComponentType} Enhanced component with merged dispatcher props.
[4483] Fix | Delete
*/
[4484] Fix | Delete
[4485] Fix | Delete
const withDispatch = mapDispatchToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => ownProps => {
[4486] Fix | Delete
const mapDispatch = (dispatch, registry) => mapDispatchToProps(dispatch, ownProps, registry);
[4487] Fix | Delete
const dispatchProps = use_dispatch_with_map(mapDispatch, []);
[4488] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, {
[4489] Fix | Delete
...ownProps,
[4490] Fix | Delete
...dispatchProps
[4491] Fix | Delete
});
[4492] Fix | Delete
}, 'withDispatch');
[4493] Fix | Delete
/* harmony default export */ const with_dispatch = (withDispatch);
[4494] Fix | Delete
[4495] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/data/build-module/components/with-registry/index.js
[4496] Fix | Delete
/**
[4497] Fix | Delete
* WordPress dependencies
[4498] Fix | Delete
*/
[4499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function