@wordpress/compose 8.1.0 → 8.1.2-next.v.202606191442.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -1
- package/README.md +46 -42
- package/build/higher-order/pure/index.cjs +15 -0
- package/build/higher-order/pure/index.cjs.map +3 -3
- package/build/hooks/use-constrained-tabbing/index.cjs +3 -9
- package/build/hooks/use-constrained-tabbing/index.cjs.map +3 -3
- package/build/hooks/use-debounce/index.cjs +1 -1
- package/build/hooks/use-debounce/index.cjs.map +3 -3
- package/build/hooks/use-disabled/index.cjs.map +2 -2
- package/build/hooks/use-dragging/index.cjs +27 -22
- package/build/hooks/use-dragging/index.cjs.map +4 -4
- package/build/hooks/use-dragging/types.cjs +19 -0
- package/build/hooks/use-dragging/types.cjs.map +7 -0
- package/build/hooks/use-drop-zone/index.cjs +2 -5
- package/build/hooks/use-drop-zone/index.cjs.map +3 -3
- package/build/hooks/use-drop-zone/types.cjs +19 -0
- package/build/hooks/use-drop-zone/types.cjs.map +7 -0
- package/build/hooks/use-fixed-window-list/index.cjs +10 -8
- package/build/hooks/use-fixed-window-list/index.cjs.map +3 -3
- package/build/hooks/use-focus-return/index.cjs +12 -9
- package/build/hooks/use-focus-return/index.cjs.map +3 -3
- package/build/hooks/use-isomorphic-layout-effect/index.cjs +1 -1
- package/build/hooks/use-isomorphic-layout-effect/index.cjs.map +1 -1
- package/build/hooks/use-keyboard-shortcut/index.cjs +1 -4
- package/build/hooks/use-keyboard-shortcut/index.cjs.map +3 -3
- package/build/hooks/use-media-query/index.cjs +2 -2
- package/build/hooks/use-media-query/index.cjs.map +2 -2
- package/build/hooks/use-merge-refs/index.cjs +28 -8
- package/build/hooks/use-merge-refs/index.cjs.map +2 -2
- package/build/hooks/use-reduced-motion/index.cjs +1 -1
- package/build/hooks/use-reduced-motion/index.cjs.map +2 -2
- package/build/hooks/use-throttle/index.cjs +1 -1
- package/build/hooks/use-throttle/index.cjs.map +3 -3
- package/build/hooks/use-viewport-match/index.cjs +3 -6
- package/build/hooks/use-viewport-match/index.cjs.map +3 -3
- package/build/hooks/use-warn-on-change/index.cjs +3 -10
- package/build/hooks/use-warn-on-change/index.cjs.map +3 -3
- package/build/utils/subscribe-delegated-listener/index.cjs.map +1 -1
- package/build-module/higher-order/pure/index.mjs +5 -0
- package/build-module/higher-order/pure/index.mjs.map +2 -2
- package/build-module/hooks/use-constrained-tabbing/index.mjs +3 -9
- package/build-module/hooks/use-constrained-tabbing/index.mjs.map +3 -3
- package/build-module/hooks/use-debounce/index.mjs +1 -1
- package/build-module/hooks/use-debounce/index.mjs.map +3 -3
- package/build-module/hooks/use-disabled/index.mjs.map +2 -2
- package/build-module/hooks/use-dragging/index.mjs +27 -22
- package/build-module/hooks/use-dragging/index.mjs.map +4 -4
- package/build-module/hooks/use-dragging/types.mjs +1 -0
- package/build-module/hooks/use-dragging/types.mjs.map +7 -0
- package/build-module/hooks/use-drop-zone/index.mjs +2 -5
- package/build-module/hooks/use-drop-zone/index.mjs.map +3 -3
- package/build-module/hooks/use-drop-zone/types.mjs +1 -0
- package/build-module/hooks/use-drop-zone/types.mjs.map +7 -0
- package/build-module/hooks/use-fixed-window-list/index.mjs +10 -8
- package/build-module/hooks/use-fixed-window-list/index.mjs.map +3 -3
- package/build-module/hooks/use-focus-return/index.mjs +12 -9
- package/build-module/hooks/use-focus-return/index.mjs.map +3 -3
- package/build-module/hooks/use-isomorphic-layout-effect/index.mjs +1 -1
- package/build-module/hooks/use-isomorphic-layout-effect/index.mjs.map +1 -1
- package/build-module/hooks/use-keyboard-shortcut/index.mjs +1 -4
- package/build-module/hooks/use-keyboard-shortcut/index.mjs.map +3 -3
- package/build-module/hooks/use-media-query/index.mjs +2 -2
- package/build-module/hooks/use-media-query/index.mjs.map +2 -2
- package/build-module/hooks/use-merge-refs/index.mjs +28 -8
- package/build-module/hooks/use-merge-refs/index.mjs.map +2 -2
- package/build-module/hooks/use-reduced-motion/index.mjs +1 -1
- package/build-module/hooks/use-reduced-motion/index.mjs.map +2 -2
- package/build-module/hooks/use-throttle/index.mjs +1 -1
- package/build-module/hooks/use-throttle/index.mjs.map +3 -3
- package/build-module/hooks/use-viewport-match/index.mjs +3 -6
- package/build-module/hooks/use-viewport-match/index.mjs.map +3 -3
- package/build-module/hooks/use-warn-on-change/index.mjs +3 -10
- package/build-module/hooks/use-warn-on-change/index.mjs.map +3 -3
- package/build-module/utils/subscribe-delegated-listener/index.mjs.map +1 -1
- package/build-types/higher-order/pure/index.d.ts.map +1 -1
- package/build-types/hooks/use-constrained-tabbing/index.d.ts +2 -2
- package/build-types/hooks/use-constrained-tabbing/index.d.ts.map +1 -1
- package/build-types/hooks/use-debounce/index.d.ts +7 -6
- package/build-types/hooks/use-debounce/index.d.ts.map +1 -1
- package/build-types/hooks/use-disabled/index.d.ts +1 -1
- package/build-types/hooks/use-disabled/index.d.ts.map +1 -1
- package/build-types/hooks/use-dragging/index.d.ts +9 -13
- package/build-types/hooks/use-dragging/index.d.ts.map +1 -1
- package/build-types/hooks/use-dragging/types.d.ts +11 -0
- package/build-types/hooks/use-dragging/types.d.ts.map +1 -0
- package/build-types/hooks/use-drop-zone/index.d.ts +4 -21
- package/build-types/hooks/use-drop-zone/index.d.ts.map +1 -1
- package/build-types/hooks/use-drop-zone/types.d.ts +35 -0
- package/build-types/hooks/use-drop-zone/types.d.ts.map +1 -0
- package/build-types/hooks/use-fixed-window-list/index.d.ts +22 -26
- package/build-types/hooks/use-fixed-window-list/index.d.ts.map +1 -1
- package/build-types/hooks/use-focus-return/index.d.ts +3 -3
- package/build-types/hooks/use-focus-return/index.d.ts.map +1 -1
- package/build-types/hooks/use-isomorphic-layout-effect/index.d.ts.map +1 -1
- package/build-types/hooks/use-keyboard-shortcut/index.d.ts +29 -23
- package/build-types/hooks/use-keyboard-shortcut/index.d.ts.map +1 -1
- package/build-types/hooks/use-media-query/index.d.ts +1 -1
- package/build-types/hooks/use-media-query/index.d.ts.map +1 -1
- package/build-types/hooks/use-merge-refs/index.d.ts +7 -5
- package/build-types/hooks/use-merge-refs/index.d.ts.map +1 -1
- package/build-types/hooks/use-reduced-motion/index.d.ts +1 -1
- package/build-types/hooks/use-reduced-motion/index.d.ts.map +1 -1
- package/build-types/hooks/use-throttle/index.d.ts +8 -6
- package/build-types/hooks/use-throttle/index.d.ts.map +1 -1
- package/build-types/hooks/use-viewport-match/index.d.ts +3 -3
- package/build-types/hooks/use-viewport-match/index.d.ts.map +1 -1
- package/build-types/hooks/use-warn-on-change/index.d.ts +7 -7
- package/build-types/hooks/use-warn-on-change/index.d.ts.map +1 -1
- package/package.json +21 -12
- package/src/higher-order/pure/index.tsx +6 -0
- package/src/higher-order/pure/test/index.js +14 -81
- package/src/hooks/use-constrained-tabbing/{index.js → index.ts} +7 -11
- package/src/hooks/use-debounce/{index.js → index.ts} +11 -6
- package/src/hooks/use-disabled/index.ts +3 -1
- package/src/hooks/use-dragging/index.ts +78 -0
- package/src/hooks/use-dragging/types.ts +11 -0
- package/src/hooks/use-drop-zone/README.md +1 -1
- package/src/hooks/use-drop-zone/{index.js → index.ts} +17 -31
- package/src/hooks/use-drop-zone/types.ts +34 -0
- package/src/hooks/use-fixed-window-list/{index.js → index.ts} +46 -37
- package/src/hooks/use-focus-return/{index.js → index.ts} +26 -21
- package/src/hooks/use-keyboard-shortcut/{index.js → index.ts} +43 -28
- package/src/hooks/use-media-query/index.ts +10 -3
- package/src/hooks/use-media-query/test/ssr.js +47 -0
- package/src/hooks/use-merge-refs/index.ts +49 -18
- package/src/hooks/use-merge-refs/test/index.js +288 -0
- package/src/hooks/use-reduced-motion/{index.js → index.ts} +2 -2
- package/src/hooks/use-throttle/{index.js → index.ts} +12 -6
- package/src/hooks/use-viewport-match/{index.js → index.ts} +33 -26
- package/src/hooks/use-warn-on-change/index.ts +42 -0
- package/src/higher-order/with-network-connectivity/README.md +0 -20
- package/src/higher-order/with-network-connectivity/index.native.js +0 -19
- package/src/higher-order/with-preferred-color-scheme/index.native.js +0 -40
- package/src/hooks/use-constrained-tabbing/index.native.js +0 -14
- package/src/hooks/use-dragging/index.js +0 -74
- package/src/hooks/use-focus-outside/index.native.js +0 -170
- package/src/hooks/use-keyboard-shortcut/index.native.js +0 -2
- package/src/hooks/use-network-connectivity/index.native.js +0 -59
- package/src/hooks/use-network-connectivity/test/index.native.js +0 -87
- package/src/hooks/use-preferred-color-scheme/index.android.js +0 -30
- package/src/hooks/use-preferred-color-scheme/index.ios.js +0 -13
- package/src/hooks/use-preferred-color-scheme-style/index.native.js +0 -33
- package/src/hooks/use-resize-observer/index.native.js +0 -1
- package/src/hooks/use-resize-observer/legacy/index.native.js +0 -59
- package/src/hooks/use-resize-observer/legacy/test/index.native.js +0 -46
- package/src/hooks/use-warn-on-change/index.js +0 -43
- package/src/index.native.js +0 -44
- /package/src/hooks/use-isomorphic-layout-effect/{index.js → index.ts} +0 -0
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Internal dependencies
|
|
3
|
-
*/
|
|
4
|
-
import usePrevious from '../use-previous';
|
|
5
|
-
|
|
6
|
-
// Disable reason: Object and object are distinctly different types in TypeScript and we mean the lowercase object in this case
|
|
7
|
-
// but eslint wants to force us to use `Object`. See https://stackoverflow.com/questions/49464634/difference-between-object-and-object-in-typescript
|
|
8
|
-
/* eslint-disable jsdoc/check-types */
|
|
9
|
-
/**
|
|
10
|
-
* Hook that performs a shallow comparison between the preview value of an object
|
|
11
|
-
* and the new one, if there's a difference, it prints it to the console.
|
|
12
|
-
* this is useful in performance related work, to check why a component re-renders.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
*
|
|
16
|
-
* ```jsx
|
|
17
|
-
* function MyComponent(props) {
|
|
18
|
-
* useWarnOnChange(props);
|
|
19
|
-
*
|
|
20
|
-
* return "Something";
|
|
21
|
-
* }
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @param {object} object Object which changes to compare.
|
|
25
|
-
* @param {string} prefix Just a prefix to show when console logging.
|
|
26
|
-
*/
|
|
27
|
-
function useWarnOnChange( object, prefix = 'Change detection' ) {
|
|
28
|
-
const previousValues = usePrevious( object );
|
|
29
|
-
|
|
30
|
-
Object.entries( previousValues ?? [] ).forEach( ( [ key, value ] ) => {
|
|
31
|
-
if ( value !== object[ /** @type {keyof typeof object} */ ( key ) ] ) {
|
|
32
|
-
// eslint-disable-next-line no-console
|
|
33
|
-
console.warn(
|
|
34
|
-
`${ prefix }: ${ key } key changed:`,
|
|
35
|
-
value,
|
|
36
|
-
object[ /** @type {keyof typeof object} */ ( key ) ]
|
|
37
|
-
/* eslint-enable jsdoc/check-types */
|
|
38
|
-
);
|
|
39
|
-
}
|
|
40
|
-
} );
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default useWarnOnChange;
|
package/src/index.native.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// The `createHigherOrderComponent` helper and helper types.
|
|
2
|
-
export * from './utils/create-higher-order-component';
|
|
3
|
-
// The `debounce` helper and its types.
|
|
4
|
-
export * from './utils/debounce';
|
|
5
|
-
// The `throttle` helper and its types.
|
|
6
|
-
export * from './utils/throttle';
|
|
7
|
-
// The `ObservableMap` data structure
|
|
8
|
-
export * from './utils/observable-map';
|
|
9
|
-
|
|
10
|
-
// The `compose` and `pipe` helpers (inspired by `flowRight` and `flow` from Lodash).
|
|
11
|
-
export { default as compose } from './higher-order/compose';
|
|
12
|
-
export { default as pipe } from './higher-order/pipe';
|
|
13
|
-
|
|
14
|
-
// Higher-order components.
|
|
15
|
-
export { default as ifCondition } from './higher-order/if-condition';
|
|
16
|
-
export { default as pure } from './higher-order/pure';
|
|
17
|
-
export { default as withGlobalEvents } from './higher-order/with-global-events';
|
|
18
|
-
export { default as withInstanceId } from './higher-order/with-instance-id';
|
|
19
|
-
export { default as withSafeTimeout } from './higher-order/with-safe-timeout';
|
|
20
|
-
export { default as withState } from './higher-order/with-state';
|
|
21
|
-
export { default as withPreferredColorScheme } from './higher-order/with-preferred-color-scheme';
|
|
22
|
-
export { default as withNetworkConnectivity } from './higher-order/with-network-connectivity';
|
|
23
|
-
|
|
24
|
-
// Hooks.
|
|
25
|
-
export { default as useConstrainedTabbing } from './hooks/use-constrained-tabbing';
|
|
26
|
-
export { default as __experimentalUseDragging } from './hooks/use-dragging';
|
|
27
|
-
export { default as __experimentalUseFocusOutside } from './hooks/use-focus-outside';
|
|
28
|
-
export { default as useInstanceId } from './hooks/use-instance-id';
|
|
29
|
-
export { default as useIsomorphicLayoutEffect } from './hooks/use-isomorphic-layout-effect';
|
|
30
|
-
export { default as useKeyboardShortcut } from './hooks/use-keyboard-shortcut';
|
|
31
|
-
export { default as useMediaQuery } from './hooks/use-media-query';
|
|
32
|
-
export { default as usePrevious } from './hooks/use-previous';
|
|
33
|
-
export { default as useReducedMotion } from './hooks/use-reduced-motion';
|
|
34
|
-
export { default as useViewportMatch } from './hooks/use-viewport-match';
|
|
35
|
-
export { default as usePreferredColorScheme } from './hooks/use-preferred-color-scheme';
|
|
36
|
-
export { default as usePreferredColorSchemeStyle } from './hooks/use-preferred-color-scheme-style';
|
|
37
|
-
export { default as useResizeObserver } from './hooks/use-resize-observer';
|
|
38
|
-
export { default as useDebounce } from './hooks/use-debounce';
|
|
39
|
-
export { default as useDebouncedInput } from './hooks/use-debounced-input';
|
|
40
|
-
export { default as useThrottle } from './hooks/use-throttle';
|
|
41
|
-
export { default as useMergeRefs } from './hooks/use-merge-refs';
|
|
42
|
-
export { default as useRefEffect } from './hooks/use-ref-effect';
|
|
43
|
-
export { default as useNetworkConnectivity } from './hooks/use-network-connectivity';
|
|
44
|
-
export { default as useObservableValue } from './hooks/use-observable-value';
|
|
File without changes
|