@wordpress/compose 7.6.0 → 7.8.1-next.1f6eadc42.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 +11 -2
- package/README.md +41 -11
- package/build/hooks/use-copy-on-click/index.js +5 -5
- package/build/hooks/use-copy-on-click/index.js.map +1 -1
- package/build/hooks/use-drop-zone/index.js +1 -0
- package/build/hooks/use-drop-zone/index.js.map +1 -1
- package/build/hooks/use-event/index.js +51 -0
- package/build/hooks/use-event/index.js.map +1 -0
- package/build/hooks/use-focus-on-mount/index.js +11 -11
- package/build/hooks/use-focus-on-mount/index.js.map +1 -1
- package/build/hooks/use-focus-outside/index.js +11 -11
- package/build/hooks/use-focus-outside/index.js.map +1 -1
- package/build/hooks/use-keyboard-shortcut/index.js +3 -3
- package/build/hooks/use-keyboard-shortcut/index.js.map +1 -1
- package/build/hooks/use-merge-refs/index.js +12 -12
- package/build/hooks/use-merge-refs/index.js.map +1 -1
- package/build/hooks/use-ref-effect/index.js +4 -4
- package/build/hooks/use-ref-effect/index.js.map +1 -1
- package/build/hooks/use-resize-observer/_legacy/index.js +139 -0
- package/build/hooks/use-resize-observer/_legacy/index.js.map +1 -0
- package/build/hooks/use-resize-observer/_legacy/index.native.js.map +1 -0
- package/build/hooks/use-resize-observer/index.js +70 -212
- package/build/hooks/use-resize-observer/index.js.map +1 -1
- package/build/index.js +8 -0
- package/build/index.js.map +1 -1
- package/build-module/hooks/use-copy-on-click/index.js +5 -5
- package/build-module/hooks/use-copy-on-click/index.js.map +1 -1
- package/build-module/hooks/use-drop-zone/index.js +1 -0
- package/build-module/hooks/use-drop-zone/index.js.map +1 -1
- package/build-module/hooks/use-event/index.js +45 -0
- package/build-module/hooks/use-event/index.js.map +1 -0
- package/build-module/hooks/use-focus-on-mount/index.js +11 -11
- package/build-module/hooks/use-focus-on-mount/index.js.map +1 -1
- package/build-module/hooks/use-focus-outside/index.js +11 -11
- package/build-module/hooks/use-focus-outside/index.js.map +1 -1
- package/build-module/hooks/use-keyboard-shortcut/index.js +3 -3
- package/build-module/hooks/use-keyboard-shortcut/index.js.map +1 -1
- package/build-module/hooks/use-merge-refs/index.js +12 -12
- package/build-module/hooks/use-merge-refs/index.js.map +1 -1
- package/build-module/hooks/use-ref-effect/index.js +4 -4
- package/build-module/hooks/use-ref-effect/index.js.map +1 -1
- package/build-module/hooks/use-resize-observer/_legacy/index.js +130 -0
- package/build-module/hooks/use-resize-observer/_legacy/index.js.map +1 -0
- package/build-module/hooks/use-resize-observer/_legacy/index.native.js.map +1 -0
- package/build-module/hooks/use-resize-observer/index.js +69 -213
- package/build-module/hooks/use-resize-observer/index.js.map +1 -1
- package/build-module/index.js +1 -0
- package/build-module/index.js.map +1 -1
- package/build-types/hooks/use-drop-zone/index.d.ts.map +1 -1
- package/build-types/hooks/use-event/index.d.ts +32 -0
- package/build-types/hooks/use-event/index.d.ts.map +1 -0
- package/build-types/hooks/use-focus-on-mount/index.d.ts.map +1 -1
- package/build-types/hooks/use-merge-refs/index.d.ts.map +1 -1
- package/build-types/hooks/use-resize-observer/_legacy/index.d.ts +32 -0
- package/build-types/hooks/use-resize-observer/_legacy/index.d.ts.map +1 -0
- package/build-types/hooks/use-resize-observer/index.d.ts +42 -14
- package/build-types/hooks/use-resize-observer/index.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -0
- package/package.json +9 -9
- package/src/hooks/use-copy-on-click/index.js +5 -5
- package/src/hooks/use-drop-zone/index.js +2 -0
- package/src/hooks/use-event/index.ts +51 -0
- package/src/hooks/use-focus-on-mount/index.js +11 -13
- package/src/hooks/use-focus-outside/index.ts +11 -11
- package/src/hooks/use-keyboard-shortcut/index.js +3 -3
- package/src/hooks/use-merge-refs/index.js +15 -13
- package/src/hooks/use-ref-effect/index.ts +4 -4
- package/src/hooks/use-resize-observer/_legacy/index.tsx +143 -0
- package/src/hooks/use-resize-observer/{test → _legacy/test}/index.native.js +1 -1
- package/src/hooks/use-resize-observer/index.ts +119 -0
- package/src/index.js +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/hooks/use-resize-observer/index.native.js.map +0 -1
- package/build-module/hooks/use-resize-observer/index.native.js.map +0 -1
- package/src/hooks/use-resize-observer/index.tsx +0 -362
- /package/build/hooks/use-resize-observer/{index.native.js → _legacy/index.native.js} +0 -0
- /package/build-module/hooks/use-resize-observer/{index.native.js → _legacy/index.native.js} +0 -0
- /package/src/hooks/use-resize-observer/{index.native.js → _legacy/index.native.js} +0 -0
|
@@ -27,12 +27,12 @@ import { useCallback, useRef } from '@wordpress/element';
|
|
|
27
27
|
* @return Ref callback.
|
|
28
28
|
*/
|
|
29
29
|
export default function useRefEffect(callback, dependencies) {
|
|
30
|
-
const
|
|
30
|
+
const cleanupRef = useRef();
|
|
31
31
|
return useCallback(node => {
|
|
32
32
|
if (node) {
|
|
33
|
-
|
|
34
|
-
} else if (
|
|
35
|
-
|
|
33
|
+
cleanupRef.current = callback(node);
|
|
34
|
+
} else if (cleanupRef.current) {
|
|
35
|
+
cleanupRef.current();
|
|
36
36
|
}
|
|
37
37
|
}, dependencies);
|
|
38
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useCallback","useRef","useRefEffect","callback","dependencies","
|
|
1
|
+
{"version":3,"names":["useCallback","useRef","useRefEffect","callback","dependencies","cleanupRef","node","current"],"sources":["@wordpress/compose/src/hooks/use-ref-effect/index.ts"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { DependencyList, RefCallback } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useRef } from '@wordpress/element';\n\n/**\n * Effect-like ref callback. Just like with `useEffect`, this allows you to\n * return a cleanup function to be run if the ref changes or one of the\n * dependencies changes. The ref is provided as an argument to the callback\n * functions. The main difference between this and `useEffect` is that\n * the `useEffect` callback is not called when the ref changes, but this is.\n * Pass the returned ref callback as the component's ref and merge multiple refs\n * with `useMergeRefs`.\n *\n * It's worth noting that if the dependencies array is empty, there's not\n * strictly a need to clean up event handlers for example, because the node is\n * to be removed. It *is* necessary if you add dependencies because the ref\n * callback will be called multiple times for the same node.\n *\n * @param callback Callback with ref as argument.\n * @param dependencies Dependencies of the callback.\n *\n * @return Ref callback.\n */\nexport default function useRefEffect< TElement = Node >(\n\tcallback: ( node: TElement ) => ( () => void ) | void,\n\tdependencies: DependencyList\n): RefCallback< TElement | null > {\n\tconst cleanupRef = useRef< ( () => void ) | void >();\n\treturn useCallback( ( node: TElement | null ) => {\n\t\tif ( node ) {\n\t\t\tcleanupRef.current = callback( node );\n\t\t} else if ( cleanupRef.current ) {\n\t\t\tcleanupRef.current();\n\t\t}\n\t}, dependencies );\n}\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,MAAM,QAAQ,oBAAoB;;AAExD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,YAAYA,CACnCC,QAAqD,EACrDC,YAA4B,EACK;EACjC,MAAMC,UAAU,GAAGJ,MAAM,CAA0B,CAAC;EACpD,OAAOD,WAAW,CAAIM,IAAqB,IAAM;IAChD,IAAKA,IAAI,EAAG;MACXD,UAAU,CAACE,OAAO,GAAGJ,QAAQ,CAAEG,IAAK,CAAC;IACtC,CAAC,MAAM,IAAKD,UAAU,CAACE,OAAO,EAAG;MAChCF,UAAU,CAACE,OAAO,CAAC,CAAC;IACrB;EACD,CAAC,EAAEH,YAAa,CAAC;AAClB","ignoreList":[]}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* WordPress dependencies
|
|
7
|
+
*/
|
|
8
|
+
import { useCallback, useRef, useState } from '@wordpress/element';
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import useResizeObserver from '../index';
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
// We're only using the first element of the size sequences, until future versions of the spec solidify on how
|
|
15
|
+
// exactly it'll be used for fragments in multi-column scenarios:
|
|
16
|
+
// From the spec:
|
|
17
|
+
// > The box size properties are exposed as FrozenArray in order to support elements that have multiple fragments,
|
|
18
|
+
// > which occur in multi-column scenarios. However the current definitions of content rect and border box do not
|
|
19
|
+
// > mention how those boxes are affected by multi-column layout. In this spec, there will only be a single
|
|
20
|
+
// > ResizeObserverSize returned in the FrozenArray, which will correspond to the dimensions of the first column.
|
|
21
|
+
// > A future version of this spec will extend the returned FrozenArray to contain the per-fragment size information.
|
|
22
|
+
// (https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface)
|
|
23
|
+
//
|
|
24
|
+
// Also, testing these new box options revealed that in both Chrome and FF everything is returned in the callback,
|
|
25
|
+
// regardless of the "box" option.
|
|
26
|
+
// The spec states the following on this:
|
|
27
|
+
// > This does not have any impact on which box dimensions are returned to the defined callback when the event
|
|
28
|
+
// > is fired, it solely defines which box the author wishes to observe layout changes on.
|
|
29
|
+
// (https://drafts.csswg.org/resize-observer/#resize-observer-interface)
|
|
30
|
+
// I'm not exactly clear on what this means, especially when you consider a later section stating the following:
|
|
31
|
+
// > This section is non-normative. An author may desire to observe more than one CSS box.
|
|
32
|
+
// > In this case, author will need to use multiple ResizeObservers.
|
|
33
|
+
// (https://drafts.csswg.org/resize-observer/#resize-observer-interface)
|
|
34
|
+
// Which is clearly not how current browser implementations behave, and seems to contradict the previous quote.
|
|
35
|
+
// For this reason I decided to only return the requested size,
|
|
36
|
+
// even though it seems we have access to results for all box types.
|
|
37
|
+
// This also means that we get to keep the current api, being able to return a simple { width, height } pair,
|
|
38
|
+
// regardless of box option.
|
|
39
|
+
const extractSize = entry => {
|
|
40
|
+
let entrySize;
|
|
41
|
+
if (!entry.contentBoxSize) {
|
|
42
|
+
// The dimensions in `contentBoxSize` and `contentRect` are equivalent according to the spec.
|
|
43
|
+
// See the 6th step in the description for the RO algorithm:
|
|
44
|
+
// https://drafts.csswg.org/resize-observer/#create-and-populate-resizeobserverentry-h
|
|
45
|
+
// > Set this.contentRect to logical this.contentBoxSize given target and observedBox of "content-box".
|
|
46
|
+
// In real browser implementations of course these objects differ, but the width/height values should be equivalent.
|
|
47
|
+
entrySize = [entry.contentRect.width, entry.contentRect.height];
|
|
48
|
+
} else if (entry.contentBoxSize[0]) {
|
|
49
|
+
const contentBoxSize = entry.contentBoxSize[0];
|
|
50
|
+
entrySize = [contentBoxSize.inlineSize, contentBoxSize.blockSize];
|
|
51
|
+
} else {
|
|
52
|
+
// TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's buggy
|
|
53
|
+
// behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`.
|
|
54
|
+
const contentBoxSize = entry.contentBoxSize;
|
|
55
|
+
entrySize = [contentBoxSize.inlineSize, contentBoxSize.blockSize];
|
|
56
|
+
}
|
|
57
|
+
const [width, height] = entrySize.map(d => Math.round(d));
|
|
58
|
+
return {
|
|
59
|
+
width,
|
|
60
|
+
height
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
const RESIZE_ELEMENT_STYLES = {
|
|
64
|
+
position: 'absolute',
|
|
65
|
+
top: 0,
|
|
66
|
+
left: 0,
|
|
67
|
+
right: 0,
|
|
68
|
+
bottom: 0,
|
|
69
|
+
pointerEvents: 'none',
|
|
70
|
+
opacity: 0,
|
|
71
|
+
overflow: 'hidden',
|
|
72
|
+
zIndex: -1
|
|
73
|
+
};
|
|
74
|
+
function ResizeElement({
|
|
75
|
+
onResize
|
|
76
|
+
}) {
|
|
77
|
+
const resizeElementRef = useResizeObserver(entries => {
|
|
78
|
+
const newSize = extractSize(entries.at(-1)); // Entries are never empty.
|
|
79
|
+
onResize(newSize);
|
|
80
|
+
});
|
|
81
|
+
return /*#__PURE__*/_jsx("div", {
|
|
82
|
+
ref: resizeElementRef,
|
|
83
|
+
style: RESIZE_ELEMENT_STYLES,
|
|
84
|
+
"aria-hidden": "true"
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function sizeEquals(a, b) {
|
|
88
|
+
return a.width === b.width && a.height === b.height;
|
|
89
|
+
}
|
|
90
|
+
const NULL_SIZE = {
|
|
91
|
+
width: null,
|
|
92
|
+
height: null
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Hook which allows to listen to the resize event of any target element when it changes size.
|
|
97
|
+
* _Note: `useResizeObserver` will report `null` sizes until after first render.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
*
|
|
101
|
+
* ```js
|
|
102
|
+
* const App = () => {
|
|
103
|
+
* const [ resizeListener, sizes ] = useResizeObserver();
|
|
104
|
+
*
|
|
105
|
+
* return (
|
|
106
|
+
* <div>
|
|
107
|
+
* { resizeListener }
|
|
108
|
+
* Your content here
|
|
109
|
+
* </div>
|
|
110
|
+
* );
|
|
111
|
+
* };
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export default function useLegacyResizeObserver() {
|
|
115
|
+
const [size, setSize] = useState(NULL_SIZE);
|
|
116
|
+
|
|
117
|
+
// Using a ref to track the previous width / height to avoid unnecessary renders.
|
|
118
|
+
const previousSizeRef = useRef(NULL_SIZE);
|
|
119
|
+
const handleResize = useCallback(newSize => {
|
|
120
|
+
if (!sizeEquals(previousSizeRef.current, newSize)) {
|
|
121
|
+
previousSizeRef.current = newSize;
|
|
122
|
+
setSize(newSize);
|
|
123
|
+
}
|
|
124
|
+
}, []);
|
|
125
|
+
const resizeElement = /*#__PURE__*/_jsx(ResizeElement, {
|
|
126
|
+
onResize: handleResize
|
|
127
|
+
});
|
|
128
|
+
return [resizeElement, size];
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useRef","useState","useResizeObserver","jsx","_jsx","extractSize","entry","entrySize","contentBoxSize","contentRect","width","height","inlineSize","blockSize","map","d","Math","round","RESIZE_ELEMENT_STYLES","position","top","left","right","bottom","pointerEvents","opacity","overflow","zIndex","ResizeElement","onResize","resizeElementRef","entries","newSize","at","ref","style","sizeEquals","a","b","NULL_SIZE","useLegacyResizeObserver","size","setSize","previousSizeRef","handleResize","current","resizeElement"],"sources":["@wordpress/compose/src/hooks/use-resize-observer/_legacy/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactElement } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useRef, useState } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport useResizeObserver from '../index';\n\nexport type ObservedSize = {\n\twidth: number | null;\n\theight: number | null;\n};\n\n// We're only using the first element of the size sequences, until future versions of the spec solidify on how\n// exactly it'll be used for fragments in multi-column scenarios:\n// From the spec:\n// > The box size properties are exposed as FrozenArray in order to support elements that have multiple fragments,\n// > which occur in multi-column scenarios. However the current definitions of content rect and border box do not\n// > mention how those boxes are affected by multi-column layout. In this spec, there will only be a single\n// > ResizeObserverSize returned in the FrozenArray, which will correspond to the dimensions of the first column.\n// > A future version of this spec will extend the returned FrozenArray to contain the per-fragment size information.\n// (https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface)\n//\n// Also, testing these new box options revealed that in both Chrome and FF everything is returned in the callback,\n// regardless of the \"box\" option.\n// The spec states the following on this:\n// > This does not have any impact on which box dimensions are returned to the defined callback when the event\n// > is fired, it solely defines which box the author wishes to observe layout changes on.\n// (https://drafts.csswg.org/resize-observer/#resize-observer-interface)\n// I'm not exactly clear on what this means, especially when you consider a later section stating the following:\n// > This section is non-normative. An author may desire to observe more than one CSS box.\n// > In this case, author will need to use multiple ResizeObservers.\n// (https://drafts.csswg.org/resize-observer/#resize-observer-interface)\n// Which is clearly not how current browser implementations behave, and seems to contradict the previous quote.\n// For this reason I decided to only return the requested size,\n// even though it seems we have access to results for all box types.\n// This also means that we get to keep the current api, being able to return a simple { width, height } pair,\n// regardless of box option.\nconst extractSize = ( entry: ResizeObserverEntry ): ObservedSize => {\n\tlet entrySize;\n\tif ( ! entry.contentBoxSize ) {\n\t\t// The dimensions in `contentBoxSize` and `contentRect` are equivalent according to the spec.\n\t\t// See the 6th step in the description for the RO algorithm:\n\t\t// https://drafts.csswg.org/resize-observer/#create-and-populate-resizeobserverentry-h\n\t\t// > Set this.contentRect to logical this.contentBoxSize given target and observedBox of \"content-box\".\n\t\t// In real browser implementations of course these objects differ, but the width/height values should be equivalent.\n\t\tentrySize = [ entry.contentRect.width, entry.contentRect.height ];\n\t} else if ( entry.contentBoxSize[ 0 ] ) {\n\t\tconst contentBoxSize = entry.contentBoxSize[ 0 ];\n\t\tentrySize = [ contentBoxSize.inlineSize, contentBoxSize.blockSize ];\n\t} else {\n\t\t// TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's buggy\n\t\t// behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`.\n\t\tconst contentBoxSize =\n\t\t\tentry.contentBoxSize as unknown as ResizeObserverSize;\n\t\tentrySize = [ contentBoxSize.inlineSize, contentBoxSize.blockSize ];\n\t}\n\n\tconst [ width, height ] = entrySize.map( ( d ) => Math.round( d ) );\n\treturn { width, height };\n};\n\nconst RESIZE_ELEMENT_STYLES = {\n\tposition: 'absolute',\n\ttop: 0,\n\tleft: 0,\n\tright: 0,\n\tbottom: 0,\n\tpointerEvents: 'none',\n\topacity: 0,\n\toverflow: 'hidden',\n\tzIndex: -1,\n} as const;\n\ntype ResizeElementProps = {\n\tonResize: ( s: ObservedSize ) => void;\n};\n\nfunction ResizeElement( { onResize }: ResizeElementProps ) {\n\tconst resizeElementRef = useResizeObserver( ( entries ) => {\n\t\tconst newSize = extractSize( entries.at( -1 )! ); // Entries are never empty.\n\t\tonResize( newSize );\n\t} );\n\n\treturn (\n\t\t<div\n\t\t\tref={ resizeElementRef }\n\t\t\tstyle={ RESIZE_ELEMENT_STYLES }\n\t\t\taria-hidden=\"true\"\n\t\t/>\n\t);\n}\n\nfunction sizeEquals( a: ObservedSize, b: ObservedSize ) {\n\treturn a.width === b.width && a.height === b.height;\n}\n\nconst NULL_SIZE: ObservedSize = { width: null, height: null };\n\n/**\n * Hook which allows to listen to the resize event of any target element when it changes size.\n * _Note: `useResizeObserver` will report `null` sizes until after first render.\n *\n * @example\n *\n * ```js\n * const App = () => {\n * \tconst [ resizeListener, sizes ] = useResizeObserver();\n *\n * \treturn (\n * \t\t<div>\n * \t\t\t{ resizeListener }\n * \t\t\tYour content here\n * \t\t</div>\n * \t);\n * };\n * ```\n */\nexport default function useLegacyResizeObserver(): [\n\tReactElement,\n\tObservedSize,\n] {\n\tconst [ size, setSize ] = useState( NULL_SIZE );\n\n\t// Using a ref to track the previous width / height to avoid unnecessary renders.\n\tconst previousSizeRef = useRef( NULL_SIZE );\n\n\tconst handleResize = useCallback( ( newSize: ObservedSize ) => {\n\t\tif ( ! sizeEquals( previousSizeRef.current, newSize ) ) {\n\t\t\tpreviousSizeRef.current = newSize;\n\t\t\tsetSize( newSize );\n\t\t}\n\t}, [] );\n\n\tconst resizeElement = <ResizeElement onResize={ handleResize } />;\n\treturn [ resizeElement, size ];\n}\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AAClE;AACA;AACA;AACA,OAAOC,iBAAiB,MAAM,UAAU;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAOzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAAKC,KAA0B,IAAoB;EACnE,IAAIC,SAAS;EACb,IAAK,CAAED,KAAK,CAACE,cAAc,EAAG;IAC7B;IACA;IACA;IACA;IACA;IACAD,SAAS,GAAG,CAAED,KAAK,CAACG,WAAW,CAACC,KAAK,EAA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CAAC;AAEJ;AAEA,SAASkB,UAAUA,CAAEC,CAAe,EAAEC,CAAe,EAAG;EACvD,OAAOD,CAAC,CAAC3B,KAAK,KAAK4B,CAAC,CAAC5B,KAAK,IAAI2B,CAAC,CAAC1B,MAAM,KAAK2B,CAAC,CAAC3B,MAAM;AACpD;AAEA,MAAM4B,SAAuB,GAAG;EAAE7B,KAAK,EAAE,IAAI;EAAEC,MAAM,EAAE;AAAK,CAAC;;AAE7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAAS6B,uBAAuBA,CAAA,EAG7C;EACD,MAAM,CAAEC,IAAI,EAAEC,OAAO,CAAE,GAAGzC,QAAQ,CAAEsC,SAAU,CAAC;;EAE/C;EACA,MAAMI,eAAe,GAAG3C,MAAM,CAAEuC,SAAU,CAAC;EAE3C,MAAMK,YAAY,GAAG7C,WAAW,CAAIiC,OAAqB,IAAM;IAC9D,IAAK,CAAEI,UAAU,CAAEO,eAAe,CAACE,OAAO,EAAEb,OAAQ,CAAC,EAAG;MACvDW,eAAe,CAACE,OAAO,GAAGb,OAAO;MACjCU,OAAO,CAAEV,OAAQ,CAAC;IACnB;EACD,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMc,aAAa,gBAAG1C,IAAA,CAACwB,aAAa;IAACC,QAAQ,EAAGe;EAAc,CAAE,CAAC;EACjE,OAAO,CAAEE,aAAa,EAAEL,IAAI,CAAE;AAC/B","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["View","StyleSheet","useState","useCallback","jsx","_jsx","useResizeObserver","measurements","setMeasurements","onLayout","nativeEvent","width","height","layout","prevState","Math","floor","observer","testID","style","absoluteFill"],"sources":["@wordpress/compose/src/hooks/use-resize-observer/_legacy/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View, StyleSheet } from 'react-native';\n/**\n * WordPress dependencies\n */\nimport { useState, useCallback } from '@wordpress/element';\n\n/**\n * Hook which allows to listen the resize event of any target element when it changes sizes.\n *\n * @example\n *\n * ```js\n * const App = () => {\n * \tconst [ resizeListener, sizes ] = useResizeObserver();\n *\n * \treturn (\n * \t\t<View>\n * \t\t\t{ resizeListener }\n * \t\t\tYour content here\n * \t\t</View>\n * \t);\n * };\n * ```\n */\nconst useResizeObserver = () => {\n\tconst [ measurements, setMeasurements ] = useState( null );\n\n\tconst onLayout = useCallback( ( { nativeEvent } ) => {\n\t\tconst { width, height } = nativeEvent.layout;\n\t\tsetMeasurements( ( prevState ) => {\n\t\t\tif (\n\t\t\t\t! prevState ||\n\t\t\t\tprevState.width !== width ||\n\t\t\t\tprevState.height !== height\n\t\t\t) {\n\t\t\t\treturn {\n\t\t\t\t\twidth: Math.floor( width ),\n\t\t\t\t\theight: Math.floor( height ),\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn prevState;\n\t\t} );\n\t}, [] );\n\n\tconst observer = (\n\t\t<View\n\t\t\ttestID=\"resize-observer\"\n\t\t\tstyle={ StyleSheet.absoluteFill }\n\t\t\tonLayout={ onLayout }\n\t\t/>\n\t);\n\n\treturn [ observer, measurements ];\n};\n\nexport default useResizeObserver;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,EAAEC,UAAU,QAAQ,cAAc;AAC/C;AACA;AACA;AACA,SAASC,QAAQ,EAAEC,WAAW,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAjBA,SAAAC,GAAA,IAAAC,IAAA;AAkBA,MAAMC,iBAAiB,GAAGA,CAAA,KAAM;EAC/B,MAAM,CAAEC,YAAY,EAAEC,eAAe,CAAE,GAAGN,QAAQ,CAAE,IAAK,CAAC;EAE1D,MAAMO,QAAQ,GAAGN,WAAW,CAAE,CAAE;IAAEO;EAAY,CAAC,KAAM;IACpD,MAAM;MAAEC,KAAK;MAAEC;IAAO,CAAC,GAAGF,WAAW,CAACG,MAAM;IAC5CL,eAAe,CAAIM,SAAS,IAAM;MACjC,IACC,CAAEA,SAAS,IACXA,SAAS,CAACH,KAAK,KAAKA,KAAK,IACzBG,SAAS,CAACF,MAAM,KAAKA,MAAM,EAC1B;QACD,OAAO;UACND,KAAK,EAAEI,IAAI,CAACC,KAAK,CAAEL,KAAM,CAAC;UAC1BC,MAAM,EAAEG,IAAI,CAACC,KAAK,CAAEJ,MAAO;QAC5B,CAAC;MACF;MACA,OAAOE,SAAS;IACjB,CAAE,CAAC;EACJ,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMG,QAAQ,gBACbZ,IAAA,CAACL,IAAI;IACJkB,MAAM,EAAC,iBAAiB;IACxBC,KAAK,EAAGlB,UAAU,CAACmB,YAAc;IACjCX,QAAQ,EAAGA;EAAU,CACrB,CACD;EAED,OAAO,CAAEQ,QAAQ,EAAEV,YAAY,CAAE;AAClC,CAAC;AAED,eAAeD,iBAAiB","ignoreList":[]}
|
|
@@ -1,202 +1,83 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
import { useRef } from '@wordpress/element';
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import useEvent from '../use-event';
|
|
9
|
+
import _useLegacyResizeObserver from './_legacy';
|
|
10
|
+
/**
|
|
11
|
+
* External dependencies
|
|
7
12
|
*/
|
|
8
|
-
import { useMemo, useRef, useCallback, useEffect, useState } from '@wordpress/element';
|
|
9
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
// This of course could've been more streamlined with internal state instead of
|
|
11
|
-
// refs, but then host hooks / components could not opt out of renders.
|
|
12
|
-
// This could've been exported to its own module, but the current build doesn't
|
|
13
|
-
// seem to work with module imports and I had no more time to spend on this...
|
|
14
|
-
function useResolvedElement(subscriber, refOrElement) {
|
|
15
|
-
const callbackRefElement = useRef(null);
|
|
16
|
-
const lastReportRef = useRef(null);
|
|
17
|
-
const cleanupRef = useRef();
|
|
18
|
-
const callSubscriber = useCallback(() => {
|
|
19
|
-
let element = null;
|
|
20
|
-
if (callbackRefElement.current) {
|
|
21
|
-
element = callbackRefElement.current;
|
|
22
|
-
} else if (refOrElement) {
|
|
23
|
-
if (refOrElement instanceof HTMLElement) {
|
|
24
|
-
element = refOrElement;
|
|
25
|
-
} else {
|
|
26
|
-
element = refOrElement.current;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (lastReportRef.current && lastReportRef.current.element === element && lastReportRef.current.reporter === callSubscriber) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (cleanupRef.current) {
|
|
33
|
-
cleanupRef.current();
|
|
34
|
-
// Making sure the cleanup is not called accidentally multiple times.
|
|
35
|
-
cleanupRef.current = null;
|
|
36
|
-
}
|
|
37
|
-
lastReportRef.current = {
|
|
38
|
-
reporter: callSubscriber,
|
|
39
|
-
element
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
// Only calling the subscriber, if there's an actual element to report.
|
|
43
|
-
if (element) {
|
|
44
|
-
cleanupRef.current = subscriber(element);
|
|
45
|
-
}
|
|
46
|
-
}, [refOrElement, subscriber]);
|
|
47
|
-
|
|
48
|
-
// On each render, we check whether a ref changed, or if we got a new raw
|
|
49
|
-
// element.
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
// With this we're *technically* supporting cases where ref objects' current value changes, but only if there's a
|
|
52
|
-
// render accompanying that change as well.
|
|
53
|
-
// To guarantee we always have the right element, one must use the ref callback provided instead, but we support
|
|
54
|
-
// RefObjects to make the hook API more convenient in certain cases.
|
|
55
|
-
callSubscriber();
|
|
56
|
-
}, [callSubscriber]);
|
|
57
|
-
return useCallback(element => {
|
|
58
|
-
callbackRefElement.current = element;
|
|
59
|
-
callSubscriber();
|
|
60
|
-
}, [callSubscriber]);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Declaring my own type here instead of using the one provided by TS (available since 4.2.2), because this way I'm not
|
|
64
|
-
// forcing consumers to use a specific TS version.
|
|
65
13
|
|
|
66
|
-
//
|
|
67
|
-
// exactly it'll be used for fragments in multi-column scenarios:
|
|
68
|
-
// From the spec:
|
|
69
|
-
// > The box size properties are exposed as FrozenArray in order to support elements that have multiple fragments,
|
|
70
|
-
// > which occur in multi-column scenarios. However the current definitions of content rect and border box do not
|
|
71
|
-
// > mention how those boxes are affected by multi-column layout. In this spec, there will only be a single
|
|
72
|
-
// > ResizeObserverSize returned in the FrozenArray, which will correspond to the dimensions of the first column.
|
|
73
|
-
// > A future version of this spec will extend the returned FrozenArray to contain the per-fragment size information.
|
|
74
|
-
// (https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface)
|
|
14
|
+
// This is the current implementation of `useResizeObserver`.
|
|
75
15
|
//
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// I'm not exactly clear on what this means, especially when you consider a later section stating the following:
|
|
83
|
-
// > This section is non-normative. An author may desire to observe more than one CSS box.
|
|
84
|
-
// > In this case, author will need to use multiple ResizeObservers.
|
|
85
|
-
// (https://drafts.csswg.org/resize-observer/#resize-observer-interface)
|
|
86
|
-
// Which is clearly not how current browser implementations behave, and seems to contradict the previous quote.
|
|
87
|
-
// For this reason I decided to only return the requested size,
|
|
88
|
-
// even though it seems we have access to results for all box types.
|
|
89
|
-
// This also means that we get to keep the current api, being able to return a simple { width, height } pair,
|
|
90
|
-
// regardless of box option.
|
|
91
|
-
const extractSize = (entry, boxProp, sizeType) => {
|
|
92
|
-
if (!entry[boxProp]) {
|
|
93
|
-
if (boxProp === 'contentBoxSize') {
|
|
94
|
-
// The dimensions in `contentBoxSize` and `contentRect` are equivalent according to the spec.
|
|
95
|
-
// See the 6th step in the description for the RO algorithm:
|
|
96
|
-
// https://drafts.csswg.org/resize-observer/#create-and-populate-resizeobserverentry-h
|
|
97
|
-
// > Set this.contentRect to logical this.contentBoxSize given target and observedBox of "content-box".
|
|
98
|
-
// In real browser implementations of course these objects differ, but the width/height values should be equivalent.
|
|
99
|
-
return entry.contentRect[sizeType === 'inlineSize' ? 'width' : 'height'];
|
|
100
|
-
}
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// A couple bytes smaller than calling Array.isArray() and just as effective here.
|
|
105
|
-
return entry[boxProp][0] ? entry[boxProp][0][sizeType] :
|
|
106
|
-
// TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's current
|
|
107
|
-
// behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`.
|
|
108
|
-
// @ts-ignore
|
|
109
|
-
entry[boxProp][sizeType];
|
|
110
|
-
};
|
|
111
|
-
function useResizeObserver(opts = {}) {
|
|
112
|
-
// Saving the callback as a ref. With this, I don't need to put onResize in the
|
|
113
|
-
// effect dep array, and just passing in an anonymous function without memoising
|
|
114
|
-
// will not reinstantiate the hook's ResizeObserver.
|
|
115
|
-
const onResize = opts.onResize;
|
|
116
|
-
const onResizeRef = useRef(undefined);
|
|
117
|
-
onResizeRef.current = onResize;
|
|
118
|
-
const round = opts.round || Math.round;
|
|
119
|
-
|
|
120
|
-
// Using a single instance throughout the hook's lifetime
|
|
16
|
+
// The legacy implementation is still supported for backwards compatibility.
|
|
17
|
+
// This is achieved by overloading the exported function with both signatures,
|
|
18
|
+
// and detecting which API is being used at runtime.
|
|
19
|
+
function _useResizeObserver(callback, resizeObserverOptions = {}) {
|
|
20
|
+
const callbackEvent = useEvent(callback);
|
|
21
|
+
const observedElementRef = useRef();
|
|
121
22
|
const resizeObserverRef = useRef();
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
23
|
+
return useEvent(element => {
|
|
24
|
+
var _resizeObserverRef$cu;
|
|
25
|
+
if (element === observedElementRef.current) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
observedElementRef.current = element;
|
|
126
29
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
return () => {
|
|
133
|
-
didUnmount.current = true;
|
|
134
|
-
};
|
|
135
|
-
}, []);
|
|
30
|
+
// Set up `ResizeObserver`.
|
|
31
|
+
(_resizeObserverRef$cu = resizeObserverRef.current) !== null && _resizeObserverRef$cu !== void 0 ? _resizeObserverRef$cu : resizeObserverRef.current = new ResizeObserver(callbackEvent);
|
|
32
|
+
const {
|
|
33
|
+
current: resizeObserver
|
|
34
|
+
} = resizeObserverRef;
|
|
136
35
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
});
|
|
36
|
+
// Unobserve previous element.
|
|
37
|
+
if (observedElementRef.current) {
|
|
38
|
+
resizeObserver.unobserve(observedElementRef.current);
|
|
39
|
+
}
|
|
142
40
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
const refCallback = useResolvedElement(useCallback(element => {
|
|
147
|
-
// We only use a single Resize Observer instance, and we're instantiating it on demand, only once there's something to observe.
|
|
148
|
-
// This instance is also recreated when the `box` option changes, so that a new observation is fired if there was a previously observed element with a different box option.
|
|
149
|
-
if (!resizeObserverRef.current || resizeObserverRef.current.box !== opts.box || resizeObserverRef.current.round !== round) {
|
|
150
|
-
resizeObserverRef.current = {
|
|
151
|
-
box: opts.box,
|
|
152
|
-
round,
|
|
153
|
-
instance: new ResizeObserver(entries => {
|
|
154
|
-
const entry = entries[0];
|
|
155
|
-
let boxProp = 'borderBoxSize';
|
|
156
|
-
if (opts.box === 'border-box') {
|
|
157
|
-
boxProp = 'borderBoxSize';
|
|
158
|
-
} else {
|
|
159
|
-
boxProp = opts.box === 'device-pixel-content-box' ? 'devicePixelContentBoxSize' : 'contentBoxSize';
|
|
160
|
-
}
|
|
161
|
-
const reportedWidth = extractSize(entry, boxProp, 'inlineSize');
|
|
162
|
-
const reportedHeight = extractSize(entry, boxProp, 'blockSize');
|
|
163
|
-
const newWidth = reportedWidth ? round(reportedWidth) : undefined;
|
|
164
|
-
const newHeight = reportedHeight ? round(reportedHeight) : undefined;
|
|
165
|
-
if (previous.current.width !== newWidth || previous.current.height !== newHeight) {
|
|
166
|
-
const newSize = {
|
|
167
|
-
width: newWidth,
|
|
168
|
-
height: newHeight
|
|
169
|
-
};
|
|
170
|
-
previous.current.width = newWidth;
|
|
171
|
-
previous.current.height = newHeight;
|
|
172
|
-
if (onResizeRef.current) {
|
|
173
|
-
onResizeRef.current(newSize);
|
|
174
|
-
} else if (!didUnmount.current) {
|
|
175
|
-
setSize(newSize);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
})
|
|
179
|
-
};
|
|
41
|
+
// Observe new element.
|
|
42
|
+
if (element) {
|
|
43
|
+
resizeObserver.observe(element, resizeObserverOptions);
|
|
180
44
|
}
|
|
181
|
-
|
|
182
|
-
box: opts.box
|
|
183
|
-
});
|
|
184
|
-
return () => {
|
|
185
|
-
if (resizeObserverRef.current) {
|
|
186
|
-
resizeObserverRef.current.instance.unobserve(element);
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
}, [opts.box, round]), opts.ref);
|
|
190
|
-
return useMemo(() => ({
|
|
191
|
-
ref: refCallback,
|
|
192
|
-
width: size.width,
|
|
193
|
-
height: size.height
|
|
194
|
-
}), [refCallback, size ? size.width : null, size ? size.height : null]);
|
|
45
|
+
});
|
|
195
46
|
}
|
|
196
47
|
|
|
197
48
|
/**
|
|
198
|
-
*
|
|
199
|
-
*
|
|
49
|
+
* Sets up a [`ResizeObserver`](https://developer.mozilla.org/en-US/docs/Web/API/Resize_Observer_API)
|
|
50
|
+
* for an HTML or SVG element.
|
|
51
|
+
*
|
|
52
|
+
* Pass the returned setter as a callback ref to the React element you want
|
|
53
|
+
* to observe, or use it in layout effects for advanced use cases.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
*
|
|
57
|
+
* ```tsx
|
|
58
|
+
* const setElement = useResizeObserver(
|
|
59
|
+
* ( resizeObserverEntries ) => console.log( resizeObserverEntries ),
|
|
60
|
+
* { box: 'border-box' }
|
|
61
|
+
* );
|
|
62
|
+
* <div ref={ setElement } />;
|
|
63
|
+
*
|
|
64
|
+
* // The setter can be used in other ways, for example:
|
|
65
|
+
* useLayoutEffect( () => {
|
|
66
|
+
* setElement( document.querySelector( `data-element-id="${ elementId }"` ) );
|
|
67
|
+
* }, [ elementId ] );
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @param callback The `ResizeObserver` callback - [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/ResizeObserver#callback).
|
|
71
|
+
* @param options Options passed to `ResizeObserver.observe` when called - [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/observe#options). Changes will be ignored.
|
|
72
|
+
*/
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* **This is a legacy API and should not be used.**
|
|
76
|
+
*
|
|
77
|
+
* @deprecated Use the other `useResizeObserver` API instead: `const ref = useResizeObserver( ( entries ) => { ... } )`.
|
|
78
|
+
*
|
|
79
|
+
* Hook which allows to listen to the resize event of any target element when it changes size.
|
|
80
|
+
* _Note: `useResizeObserver` will report `null` sizes until after first render.
|
|
200
81
|
*
|
|
201
82
|
* @example
|
|
202
83
|
*
|
|
@@ -213,33 +94,8 @@ function useResizeObserver(opts = {}) {
|
|
|
213
94
|
* };
|
|
214
95
|
* ```
|
|
215
96
|
*/
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
width,
|
|
220
|
-
height
|
|
221
|
-
} = useResizeObserver();
|
|
222
|
-
const sizes = useMemo(() => {
|
|
223
|
-
return {
|
|
224
|
-
width: width !== null && width !== void 0 ? width : null,
|
|
225
|
-
height: height !== null && height !== void 0 ? height : null
|
|
226
|
-
};
|
|
227
|
-
}, [width, height]);
|
|
228
|
-
const resizeListener = /*#__PURE__*/_jsx("div", {
|
|
229
|
-
style: {
|
|
230
|
-
position: 'absolute',
|
|
231
|
-
top: 0,
|
|
232
|
-
left: 0,
|
|
233
|
-
right: 0,
|
|
234
|
-
bottom: 0,
|
|
235
|
-
pointerEvents: 'none',
|
|
236
|
-
opacity: 0,
|
|
237
|
-
overflow: 'hidden',
|
|
238
|
-
zIndex: -1
|
|
239
|
-
},
|
|
240
|
-
"aria-hidden": "true",
|
|
241
|
-
ref: ref
|
|
242
|
-
});
|
|
243
|
-
return [resizeListener, sizes];
|
|
97
|
+
|
|
98
|
+
export default function useResizeObserver(callback, options = {}) {
|
|
99
|
+
return callback ? _useResizeObserver(callback, options) : _useLegacyResizeObserver();
|
|
244
100
|
}
|
|
245
101
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useRef","useCallback","useEffect","useState","jsx","_jsx","useResolvedElement","subscriber","refOrElement","callbackRefElement","lastReportRef","cleanupRef","callSubscriber","element","current","HTMLElement","reporter","extractSize","entry","boxProp","sizeType","contentRect","undefined","useResizeObserver","opts","onResize","onResizeRef","round","Math","resizeObserverRef","size","setSize","width","height","didUnmount","previous","refCallback","box","instance","ResizeObserver","entries","reportedWidth","reportedHeight","newWidth","newHeight","newSize","observe","unobserve","ref","useResizeAware","sizes","resizeListener","style","position","top","left","right","bottom","pointerEvents","opacity","overflow","zIndex"],"sources":["@wordpress/compose/src/hooks/use-resize-observer/index.tsx"],"sourcesContent":["/**\n * External dependencies\n */\nimport type { ReactElement, RefCallback, RefObject } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseMemo,\n\tuseRef,\n\tuseCallback,\n\tuseEffect,\n\tuseState,\n} from '@wordpress/element';\n\ntype SubscriberCleanup = () => void;\ntype SubscriberResponse = SubscriberCleanup | void;\n\n// This of course could've been more streamlined with internal state instead of\n// refs, but then host hooks / components could not opt out of renders.\n// This could've been exported to its own module, but the current build doesn't\n// seem to work with module imports and I had no more time to spend on this...\nfunction useResolvedElement< T extends HTMLElement >(\n\tsubscriber: ( element: T ) => SubscriberResponse,\n\trefOrElement?: T | RefObject< T > | null\n): RefCallback< T > {\n\tconst callbackRefElement = useRef< T | null >( null );\n\tconst lastReportRef = useRef< {\n\t\treporter: () => void;\n\t\telement: T | null;\n\t} | null >( null );\n\tconst cleanupRef = useRef< SubscriberResponse | null >();\n\n\tconst callSubscriber = useCallback( () => {\n\t\tlet element = null;\n\t\tif ( callbackRefElement.current ) {\n\t\t\telement = callbackRefElement.current;\n\t\t} else if ( refOrElement ) {\n\t\t\tif ( refOrElement instanceof HTMLElement ) {\n\t\t\t\telement = refOrElement;\n\t\t\t} else {\n\t\t\t\telement = refOrElement.current;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tlastReportRef.current &&\n\t\t\tlastReportRef.current.element === element &&\n\t\t\tlastReportRef.current.reporter === callSubscriber\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( cleanupRef.current ) {\n\t\t\tcleanupRef.current();\n\t\t\t// Making sure the cleanup is not called accidentally multiple times.\n\t\t\tcleanupRef.current = null;\n\t\t}\n\t\tlastReportRef.current = {\n\t\t\treporter: callSubscriber,\n\t\t\telement,\n\t\t};\n\n\t\t// Only calling the subscriber, if there's an actual element to report.\n\t\tif ( element ) {\n\t\t\tcleanupRef.current = subscriber( element );\n\t\t}\n\t}, [ refOrElement, subscriber ] );\n\n\t// On each render, we check whether a ref changed, or if we got a new raw\n\t// element.\n\tuseEffect( () => {\n\t\t// With this we're *technically* supporting cases where ref objects' current value changes, but only if there's a\n\t\t// render accompanying that change as well.\n\t\t// To guarantee we always have the right element, one must use the ref callback provided instead, but we support\n\t\t// RefObjects to make the hook API more convenient in certain cases.\n\t\tcallSubscriber();\n\t}, [ callSubscriber ] );\n\n\treturn useCallback< RefCallback< T > >(\n\t\t( element ) => {\n\t\t\tcallbackRefElement.current = element;\n\t\t\tcallSubscriber();\n\t\t},\n\t\t[ callSubscriber ]\n\t);\n}\n\ntype ObservedSize = {\n\twidth: number | undefined;\n\theight: number | undefined;\n};\n\ntype ResizeHandler = ( size: ObservedSize ) => void;\n\ntype HookResponse< T extends HTMLElement > = {\n\tref: RefCallback< T >;\n} & ObservedSize;\n\n// Declaring my own type here instead of using the one provided by TS (available since 4.2.2), because this way I'm not\n// forcing consumers to use a specific TS version.\ntype ResizeObserverBoxOptions =\n\t| 'border-box'\n\t| 'content-box'\n\t| 'device-pixel-content-box';\n\ndeclare global {\n\tinterface ResizeObserverEntry {\n\t\treadonly devicePixelContentBoxSize: ReadonlyArray< ResizeObserverSize >;\n\t}\n}\n\n// We're only using the first element of the size sequences, until future versions of the spec solidify on how\n// exactly it'll be used for fragments in multi-column scenarios:\n// From the spec:\n// > The box size properties are exposed as FrozenArray in order to support elements that have multiple fragments,\n// > which occur in multi-column scenarios. However the current definitions of content rect and border box do not\n// > mention how those boxes are affected by multi-column layout. In this spec, there will only be a single\n// > ResizeObserverSize returned in the FrozenArray, which will correspond to the dimensions of the first column.\n// > A future version of this spec will extend the returned FrozenArray to contain the per-fragment size information.\n// (https://drafts.csswg.org/resize-observer/#resize-observer-entry-interface)\n//\n// Also, testing these new box options revealed that in both Chrome and FF everything is returned in the callback,\n// regardless of the \"box\" option.\n// The spec states the following on this:\n// > This does not have any impact on which box dimensions are returned to the defined callback when the event\n// > is fired, it solely defines which box the author wishes to observe layout changes on.\n// (https://drafts.csswg.org/resize-observer/#resize-observer-interface)\n// I'm not exactly clear on what this means, especially when you consider a later section stating the following:\n// > This section is non-normative. An author may desire to observe more than one CSS box.\n// > In this case, author will need to use multiple ResizeObservers.\n// (https://drafts.csswg.org/resize-observer/#resize-observer-interface)\n// Which is clearly not how current browser implementations behave, and seems to contradict the previous quote.\n// For this reason I decided to only return the requested size,\n// even though it seems we have access to results for all box types.\n// This also means that we get to keep the current api, being able to return a simple { width, height } pair,\n// regardless of box option.\nconst extractSize = (\n\tentry: ResizeObserverEntry,\n\tboxProp: 'borderBoxSize' | 'contentBoxSize' | 'devicePixelContentBoxSize',\n\tsizeType: keyof ResizeObserverSize\n): number | undefined => {\n\tif ( ! entry[ boxProp ] ) {\n\t\tif ( boxProp === 'contentBoxSize' ) {\n\t\t\t// The dimensions in `contentBoxSize` and `contentRect` are equivalent according to the spec.\n\t\t\t// See the 6th step in the description for the RO algorithm:\n\t\t\t// https://drafts.csswg.org/resize-observer/#create-and-populate-resizeobserverentry-h\n\t\t\t// > Set this.contentRect to logical this.contentBoxSize given target and observedBox of \"content-box\".\n\t\t\t// In real browser implementations of course these objects differ, but the width/height values should be equivalent.\n\t\t\treturn entry.contentRect[\n\t\t\t\tsizeType === 'inlineSize' ? 'width' : 'height'\n\t\t\t];\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\t// A couple bytes smaller than calling Array.isArray() and just as effective here.\n\treturn entry[ boxProp ][ 0 ]\n\t\t? entry[ boxProp ][ 0 ][ sizeType ]\n\t\t: // TS complains about this, because the RO entry type follows the spec and does not reflect Firefox's current\n\t\t // behaviour of returning objects instead of arrays for `borderBoxSize` and `contentBoxSize`.\n\t\t // @ts-ignore\n\t\t entry[ boxProp ][ sizeType ];\n};\n\ntype RoundingFunction = ( n: number ) => number;\n\nfunction useResizeObserver< T extends HTMLElement >(\n\topts: {\n\t\tref?: RefObject< T > | T | null | undefined;\n\t\tonResize?: ResizeHandler;\n\t\tbox?: ResizeObserverBoxOptions;\n\t\tround?: RoundingFunction;\n\t} = {}\n): HookResponse< T > {\n\t// Saving the callback as a ref. With this, I don't need to put onResize in the\n\t// effect dep array, and just passing in an anonymous function without memoising\n\t// will not reinstantiate the hook's ResizeObserver.\n\tconst onResize = opts.onResize;\n\tconst onResizeRef = useRef< ResizeHandler | undefined >( undefined );\n\tonResizeRef.current = onResize;\n\tconst round = opts.round || Math.round;\n\n\t// Using a single instance throughout the hook's lifetime\n\tconst resizeObserverRef = useRef< {\n\t\tbox?: ResizeObserverBoxOptions;\n\t\tround?: RoundingFunction;\n\t\tinstance: ResizeObserver;\n\t} >();\n\n\tconst [ size, setSize ] = useState< {\n\t\twidth?: number;\n\t\theight?: number;\n\t} >( {\n\t\twidth: undefined,\n\t\theight: undefined,\n\t} );\n\n\t// In certain edge cases the RO might want to report a size change just after\n\t// the component unmounted.\n\tconst didUnmount = useRef( false );\n\tuseEffect( () => {\n\t\tdidUnmount.current = false;\n\t\treturn () => {\n\t\t\tdidUnmount.current = true;\n\t\t};\n\t}, [] );\n\n\t// Using a ref to track the previous width / height to avoid unnecessary renders.\n\tconst previous: {\n\t\tcurrent: {\n\t\t\twidth?: number;\n\t\t\theight?: number;\n\t\t};\n\t} = useRef( {\n\t\twidth: undefined,\n\t\theight: undefined,\n\t} );\n\n\t// This block is kinda like a useEffect, only it's called whenever a new\n\t// element could be resolved based on the ref option. It also has a cleanup\n\t// function.\n\tconst refCallback = useResolvedElement< T >(\n\t\tuseCallback(\n\t\t\t( element ) => {\n\t\t\t\t// We only use a single Resize Observer instance, and we're instantiating it on demand, only once there's something to observe.\n\t\t\t\t// This instance is also recreated when the `box` option changes, so that a new observation is fired if there was a previously observed element with a different box option.\n\t\t\t\tif (\n\t\t\t\t\t! resizeObserverRef.current ||\n\t\t\t\t\tresizeObserverRef.current.box !== opts.box ||\n\t\t\t\t\tresizeObserverRef.current.round !== round\n\t\t\t\t) {\n\t\t\t\t\tresizeObserverRef.current = {\n\t\t\t\t\t\tbox: opts.box,\n\t\t\t\t\t\tround,\n\t\t\t\t\t\tinstance: new ResizeObserver( ( entries ) => {\n\t\t\t\t\t\t\tconst entry = entries[ 0 ];\n\n\t\t\t\t\t\t\tlet boxProp:\n\t\t\t\t\t\t\t\t| 'borderBoxSize'\n\t\t\t\t\t\t\t\t| 'contentBoxSize'\n\t\t\t\t\t\t\t\t| 'devicePixelContentBoxSize' = 'borderBoxSize';\n\t\t\t\t\t\t\tif ( opts.box === 'border-box' ) {\n\t\t\t\t\t\t\t\tboxProp = 'borderBoxSize';\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tboxProp =\n\t\t\t\t\t\t\t\t\topts.box === 'device-pixel-content-box'\n\t\t\t\t\t\t\t\t\t\t? 'devicePixelContentBoxSize'\n\t\t\t\t\t\t\t\t\t\t: 'contentBoxSize';\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst reportedWidth = extractSize(\n\t\t\t\t\t\t\t\tentry,\n\t\t\t\t\t\t\t\tboxProp,\n\t\t\t\t\t\t\t\t'inlineSize'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst reportedHeight = extractSize(\n\t\t\t\t\t\t\t\tentry,\n\t\t\t\t\t\t\t\tboxProp,\n\t\t\t\t\t\t\t\t'blockSize'\n\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tconst newWidth = reportedWidth\n\t\t\t\t\t\t\t\t? round( reportedWidth )\n\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\tconst newHeight = reportedHeight\n\t\t\t\t\t\t\t\t? round( reportedHeight )\n\t\t\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tprevious.current.width !== newWidth ||\n\t\t\t\t\t\t\t\tprevious.current.height !== newHeight\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tconst newSize = {\n\t\t\t\t\t\t\t\t\twidth: newWidth,\n\t\t\t\t\t\t\t\t\theight: newHeight,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tprevious.current.width = newWidth;\n\t\t\t\t\t\t\t\tprevious.current.height = newHeight;\n\t\t\t\t\t\t\t\tif ( onResizeRef.current ) {\n\t\t\t\t\t\t\t\t\tonResizeRef.current( newSize );\n\t\t\t\t\t\t\t\t} else if ( ! didUnmount.current ) {\n\t\t\t\t\t\t\t\t\tsetSize( newSize );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} ),\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tresizeObserverRef.current.instance.observe( element, {\n\t\t\t\t\tbox: opts.box,\n\t\t\t\t} );\n\n\t\t\t\treturn () => {\n\t\t\t\t\tif ( resizeObserverRef.current ) {\n\t\t\t\t\t\tresizeObserverRef.current.instance.unobserve( element );\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ opts.box, round ]\n\t\t),\n\t\topts.ref\n\t);\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\tref: refCallback,\n\t\t\twidth: size.width,\n\t\t\theight: size.height,\n\t\t} ),\n\t\t[ refCallback, size ? size.width : null, size ? size.height : null ]\n\t);\n}\n\n/**\n * Hook which allows to listen the resize event of any target element when it changes sizes.\n * _Note: `useResizeObserver` will report `null` until after first render.\n *\n * @example\n *\n * ```js\n * const App = () => {\n * \tconst [ resizeListener, sizes ] = useResizeObserver();\n *\n * \treturn (\n * \t\t<div>\n * \t\t\t{ resizeListener }\n * \t\t\tYour content here\n * \t\t</div>\n * \t);\n * };\n * ```\n */\nexport default function useResizeAware(): [\n\tReactElement,\n\t{ width: number | null; height: number | null },\n] {\n\tconst { ref, width, height } = useResizeObserver();\n\tconst sizes = useMemo( () => {\n\t\treturn { width: width ?? null, height: height ?? null };\n\t}, [ width, height ] );\n\tconst resizeListener = (\n\t\t<div\n\t\t\tstyle={ {\n\t\t\t\tposition: 'absolute',\n\t\t\t\ttop: 0,\n\t\t\t\tleft: 0,\n\t\t\t\tright: 0,\n\t\t\t\tbottom: 0,\n\t\t\t\tpointerEvents: 'none',\n\t\t\t\topacity: 0,\n\t\t\t\toverflow: 'hidden',\n\t\t\t\tzIndex: -1,\n\t\t\t} }\n\t\t\taria-hidden=\"true\"\n\t\t\tref={ ref }\n\t\t/>\n\t);\n\treturn [ resizeListener, sizes ];\n}\n"],"mappings":"AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SACCA,OAAO,EACPC,MAAM,EACNC,WAAW,EACXC,SAAS,EACTC,QAAQ,QACF,oBAAoB;AAA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AG,IAAI,EAAEF,IAAI,GAAGA,IAAI,CAACG,MAAM,GAAG,IAAI,CACnE,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASgB,cAAcA,CAAA,EAGpC;EACD,MAAM;IAAED,GAAG;IAAEhB,KAAK;IAAEC;EAAO,CAAC,GAAGV,iBAAiB,CAAC,CAAC;EAClD,MAAM2B,KAAK,GAAGnD,OAAO,CAAE,MAAM;IAC5B,OAAO;MAAEiC,KAAK,EAAEA,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,IAAI;MAAEC,MAAM,EAAEA,MAAM,aAANA,MAAM,cAANA,MAAM,GAAI;IAAK,CAAC;EACxD,CAAC,EAAE,CAAED,KAAK,EAAEC,MAAM,CAAG,CAAC;EACtB,MAAMkB,cAAc,gBACnB9C,IAAA;IACC+C,KAAK,EAAG;MACPC,QAAQ,EAAE,UAAU;MACpBC,GAAG,EAAE,CAAC;MACNC,IAAI,EAAE,CAAC;MACPC,KAAK,EAAE,CAAC;MACRC,MAAM,EAAE,CAAC;MACTC,aAAa,EAAE,MAAM;MACrBC,OAAO,EAAE,CAAC;MACVC,QAAQ,EAAE,QAAQ;MAClBC,MAAM,EAAE,CAAC;IACV,CAAG;IACH,eAAY,MAAM;IAClBb,GAAG,EAAGA;EAAK,CACX,CACD;EACD,OAAO,CAAEG,cAAc,EAAED,KAAK,CAAE;AACjC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useRef","useEvent","_useLegacyResizeObserver","_useResizeObserver","callback","resizeObserverOptions","callbackEvent","observedElementRef","resizeObserverRef","element","_resizeObserverRef$cu","current","ResizeObserver","resizeObserver","unobserve","observe","useResizeObserver","options"],"sources":["@wordpress/compose/src/hooks/use-resize-observer/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport useEvent from '../use-event';\nimport type { ObservedSize } from './_legacy';\nimport _useLegacyResizeObserver from './_legacy';\n/**\n * External dependencies\n */\nimport type { ReactElement } from 'react';\n\n// This is the current implementation of `useResizeObserver`.\n//\n// The legacy implementation is still supported for backwards compatibility.\n// This is achieved by overloading the exported function with both signatures,\n// and detecting which API is being used at runtime.\nfunction _useResizeObserver< T extends HTMLElement >(\n\tcallback: ResizeObserverCallback,\n\tresizeObserverOptions: ResizeObserverOptions = {}\n): ( element?: T | null ) => void {\n\tconst callbackEvent = useEvent( callback );\n\n\tconst observedElementRef = useRef< T | null >();\n\tconst resizeObserverRef = useRef< ResizeObserver >();\n\treturn useEvent( ( element?: T | null ) => {\n\t\tif ( element === observedElementRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tobservedElementRef.current = element;\n\n\t\t// Set up `ResizeObserver`.\n\t\tresizeObserverRef.current ??= new ResizeObserver( callbackEvent );\n\t\tconst { current: resizeObserver } = resizeObserverRef;\n\n\t\t// Unobserve previous element.\n\t\tif ( observedElementRef.current ) {\n\t\t\tresizeObserver.unobserve( observedElementRef.current );\n\t\t}\n\n\t\t// Observe new element.\n\t\tif ( element ) {\n\t\t\tresizeObserver.observe( element, resizeObserverOptions );\n\t\t}\n\t} );\n}\n\n/**\n * Sets up a [`ResizeObserver`](https://developer.mozilla.org/en-US/docs/Web/API/Resize_Observer_API)\n * for an HTML or SVG element.\n *\n * Pass the returned setter as a callback ref to the React element you want\n * to observe, or use it in layout effects for advanced use cases.\n *\n * @example\n *\n * ```tsx\n * const setElement = useResizeObserver(\n * \t( resizeObserverEntries ) => console.log( resizeObserverEntries ),\n * \t{ box: 'border-box' }\n * );\n * <div ref={ setElement } />;\n *\n * // The setter can be used in other ways, for example:\n * useLayoutEffect( () => {\n * \tsetElement( document.querySelector( `data-element-id=\"${ elementId }\"` ) );\n * }, [ elementId ] );\n * ```\n *\n * @param callback The `ResizeObserver` callback - [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/ResizeObserver#callback).\n * @param options Options passed to `ResizeObserver.observe` when called - [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/observe#options). Changes will be ignored.\n */\nexport default function useResizeObserver< T extends Element >(\n\t/**\n\t * The `ResizeObserver` callback - [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/ResizeObserver#callback).\n\t */\n\tcallback: ResizeObserverCallback,\n\t/**\n\t * Options passed to `ResizeObserver.observe` when called - [MDN docs](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/observe#options). Changes will be ignored.\n\t */\n\toptions?: ResizeObserverOptions\n): ( element?: T | null ) => void;\n\n/**\n * **This is a legacy API and should not be used.**\n *\n * @deprecated Use the other `useResizeObserver` API instead: `const ref = useResizeObserver( ( entries ) => { ... } )`.\n *\n * Hook which allows to listen to the resize event of any target element when it changes size.\n * _Note: `useResizeObserver` will report `null` sizes until after first render.\n *\n * @example\n *\n * ```js\n * const App = () => {\n * \tconst [ resizeListener, sizes ] = useResizeObserver();\n *\n * \treturn (\n * \t\t<div>\n * \t\t\t{ resizeListener }\n * \t\t\tYour content here\n * \t\t</div>\n * \t);\n * };\n * ```\n */\nexport default function useResizeObserver(): [ ReactElement, ObservedSize ];\n\nexport default function useResizeObserver< T extends HTMLElement >(\n\tcallback?: ResizeObserverCallback,\n\toptions: ResizeObserverOptions = {}\n): ( ( element?: T | null ) => void ) | [ ReactElement, ObservedSize ] {\n\treturn callback\n\t\t? _useResizeObserver( callback, options )\n\t\t: _useLegacyResizeObserver();\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAM,QAAQ,oBAAoB;AAC3C;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,cAAc;AAEnC,OAAOC,wBAAwB,MAAM,WAAW;AAChD;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,SAASC,kBAAkBA,CAC1BC,QAAgC,EAChCC,qBAA4C,GAAG,CAAC,CAAC,EAChB;EACjC,MAAMC,a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default as useCopyOnClick } from './hooks/use-copy-on-click';
|
|
|
25
25
|
export { default as useCopyToClipboard } from './hooks/use-copy-to-clipboard';
|
|
26
26
|
export { default as __experimentalUseDialog } from './hooks/use-dialog';
|
|
27
27
|
export { default as useDisabled } from './hooks/use-disabled';
|
|
28
|
+
export { default as useEvent } from './hooks/use-event';
|
|
28
29
|
export { default as __experimentalUseDragging } from './hooks/use-dragging';
|
|
29
30
|
export { default as useFocusOnMount } from './hooks/use-focus-on-mount';
|
|
30
31
|
export { default as __experimentalUseFocusOutside } from './hooks/use-focus-outside';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["default","compose","pipe","ifCondition","pure","withGlobalEvents","withInstanceId","withSafeTimeout","withState","useConstrainedTabbing","useCopyOnClick","useCopyToClipboard","__experimentalUseDialog","useDisabled","__experimentalUseDragging","useFocusOnMount","__experimentalUseFocusOutside","useFocusReturn","useInstanceId","useIsomorphicLayoutEffect","useKeyboardShortcut","useMediaQuery","usePrevious","useReducedMotion","useStateWithHistory","useViewportMatch","useResizeObserver","useAsyncList","useWarnOnChange","useDebounce","useDebouncedInput","useThrottle","useMergeRefs","useRefEffect","__experimentalUseDropZone","useFocusableIframe","__experimentalUseFixedWindowList","useObservableValue"],"sources":["@wordpress/compose/src/index.js"],"sourcesContent":["// The `createHigherOrderComponent` helper and helper types.\nexport * from './utils/create-higher-order-component';\n// The `debounce` helper and its types.\nexport * from './utils/debounce';\n// The `throttle` helper and its types.\nexport * from './utils/throttle';\n// The `ObservableMap` data structure\nexport * from './utils/observable-map';\n\n// The `compose` and `pipe` helpers (inspired by `flowRight` and `flow` from Lodash).\nexport { default as compose } from './higher-order/compose';\nexport { default as pipe } from './higher-order/pipe';\n\n// Higher-order components.\nexport { default as ifCondition } from './higher-order/if-condition';\nexport { default as pure } from './higher-order/pure';\nexport { default as withGlobalEvents } from './higher-order/with-global-events';\nexport { default as withInstanceId } from './higher-order/with-instance-id';\nexport { default as withSafeTimeout } from './higher-order/with-safe-timeout';\nexport { default as withState } from './higher-order/with-state';\n\n// Hooks.\nexport { default as useConstrainedTabbing } from './hooks/use-constrained-tabbing';\nexport { default as useCopyOnClick } from './hooks/use-copy-on-click';\nexport { default as useCopyToClipboard } from './hooks/use-copy-to-clipboard';\nexport { default as __experimentalUseDialog } from './hooks/use-dialog';\nexport { default as useDisabled } from './hooks/use-disabled';\nexport { default as __experimentalUseDragging } from './hooks/use-dragging';\nexport { default as useFocusOnMount } from './hooks/use-focus-on-mount';\nexport { default as __experimentalUseFocusOutside } from './hooks/use-focus-outside';\nexport { default as useFocusReturn } from './hooks/use-focus-return';\nexport { default as useInstanceId } from './hooks/use-instance-id';\nexport { default as useIsomorphicLayoutEffect } from './hooks/use-isomorphic-layout-effect';\nexport { default as useKeyboardShortcut } from './hooks/use-keyboard-shortcut';\nexport { default as useMediaQuery } from './hooks/use-media-query';\nexport { default as usePrevious } from './hooks/use-previous';\nexport { default as useReducedMotion } from './hooks/use-reduced-motion';\nexport { default as useStateWithHistory } from './hooks/use-state-with-history';\nexport { default as useViewportMatch } from './hooks/use-viewport-match';\nexport { default as useResizeObserver } from './hooks/use-resize-observer';\nexport { default as useAsyncList } from './hooks/use-async-list';\nexport { default as useWarnOnChange } from './hooks/use-warn-on-change';\nexport { default as useDebounce } from './hooks/use-debounce';\nexport { default as useDebouncedInput } from './hooks/use-debounced-input';\nexport { default as useThrottle } from './hooks/use-throttle';\nexport { default as useMergeRefs } from './hooks/use-merge-refs';\nexport { default as useRefEffect } from './hooks/use-ref-effect';\nexport { default as __experimentalUseDropZone } from './hooks/use-drop-zone';\nexport { default as useFocusableIframe } from './hooks/use-focusable-iframe';\nexport { default as __experimentalUseFixedWindowList } from './hooks/use-fixed-window-list';\nexport { default as useObservableValue } from './hooks/use-observable-value';\n"],"mappings":"AAAA;AACA,cAAc,uCAAuC;AACrD;AACA,cAAc,kBAAkB;AAChC;AACA,cAAc,kBAAkB;AAChC;AACA,cAAc,wBAAwB;;AAEtC;AACA,SAASA,OAAO,IAAIC,OAAO,QAAQ,wBAAwB;AAC3D,SAASD,OAAO,IAAIE,IAAI,QAAQ,qBAAqB;;AAErD;AACA,SAASF,OAAO,IAAIG,WAAW,QAAQ,6BAA6B;AACpE,SAASH,OAAO,IAAII,IAAI,QAAQ,qBAAqB;AACrD,SAASJ,OAAO,IAAIK,gBAAgB,QAAQ,mCAAmC;AAC/E,SAASL,OAAO,IAAIM,cAAc,QAAQ,iCAAiC;AAC3E,SAASN,OAAO,IAAIO,eAAe,QAAQ,kCAAkC;AAC7E,SAASP,OAAO,IAAIQ,SAAS,QAAQ,2BAA2B;;AAEhE;AACA,SAASR,OAAO,IAAIS,qBAAqB,QAAQ,iCAAiC;AAClF,SAAST,OAAO,IAAIU,cAAc,QAAQ,2BAA2B;AACrE,SAASV,OAAO,IAAIW,kBAAkB,QAAQ,+BAA+B;AAC7E,SAASX,OAAO,IAAIY,uBAAuB,QAAQ,oBAAoB;AACvE,SAASZ,OAAO,IAAIa,WAAW,QAAQ,sBAAsB;AAC7D,SAASb,OAAO,IAAIc,yBAAyB,QAAQ,sBAAsB;AAC3E,
|
|
1
|
+
{"version":3,"names":["default","compose","pipe","ifCondition","pure","withGlobalEvents","withInstanceId","withSafeTimeout","withState","useConstrainedTabbing","useCopyOnClick","useCopyToClipboard","__experimentalUseDialog","useDisabled","useEvent","__experimentalUseDragging","useFocusOnMount","__experimentalUseFocusOutside","useFocusReturn","useInstanceId","useIsomorphicLayoutEffect","useKeyboardShortcut","useMediaQuery","usePrevious","useReducedMotion","useStateWithHistory","useViewportMatch","useResizeObserver","useAsyncList","useWarnOnChange","useDebounce","useDebouncedInput","useThrottle","useMergeRefs","useRefEffect","__experimentalUseDropZone","useFocusableIframe","__experimentalUseFixedWindowList","useObservableValue"],"sources":["@wordpress/compose/src/index.js"],"sourcesContent":["// The `createHigherOrderComponent` helper and helper types.\nexport * from './utils/create-higher-order-component';\n// The `debounce` helper and its types.\nexport * from './utils/debounce';\n// The `throttle` helper and its types.\nexport * from './utils/throttle';\n// The `ObservableMap` data structure\nexport * from './utils/observable-map';\n\n// The `compose` and `pipe` helpers (inspired by `flowRight` and `flow` from Lodash).\nexport { default as compose } from './higher-order/compose';\nexport { default as pipe } from './higher-order/pipe';\n\n// Higher-order components.\nexport { default as ifCondition } from './higher-order/if-condition';\nexport { default as pure } from './higher-order/pure';\nexport { default as withGlobalEvents } from './higher-order/with-global-events';\nexport { default as withInstanceId } from './higher-order/with-instance-id';\nexport { default as withSafeTimeout } from './higher-order/with-safe-timeout';\nexport { default as withState } from './higher-order/with-state';\n\n// Hooks.\nexport { default as useConstrainedTabbing } from './hooks/use-constrained-tabbing';\nexport { default as useCopyOnClick } from './hooks/use-copy-on-click';\nexport { default as useCopyToClipboard } from './hooks/use-copy-to-clipboard';\nexport { default as __experimentalUseDialog } from './hooks/use-dialog';\nexport { default as useDisabled } from './hooks/use-disabled';\nexport { default as useEvent } from './hooks/use-event';\nexport { default as __experimentalUseDragging } from './hooks/use-dragging';\nexport { default as useFocusOnMount } from './hooks/use-focus-on-mount';\nexport { default as __experimentalUseFocusOutside } from './hooks/use-focus-outside';\nexport { default as useFocusReturn } from './hooks/use-focus-return';\nexport { default as useInstanceId } from './hooks/use-instance-id';\nexport { default as useIsomorphicLayoutEffect } from './hooks/use-isomorphic-layout-effect';\nexport { default as useKeyboardShortcut } from './hooks/use-keyboard-shortcut';\nexport { default as useMediaQuery } from './hooks/use-media-query';\nexport { default as usePrevious } from './hooks/use-previous';\nexport { default as useReducedMotion } from './hooks/use-reduced-motion';\nexport { default as useStateWithHistory } from './hooks/use-state-with-history';\nexport { default as useViewportMatch } from './hooks/use-viewport-match';\nexport { default as useResizeObserver } from './hooks/use-resize-observer';\nexport { default as useAsyncList } from './hooks/use-async-list';\nexport { default as useWarnOnChange } from './hooks/use-warn-on-change';\nexport { default as useDebounce } from './hooks/use-debounce';\nexport { default as useDebouncedInput } from './hooks/use-debounced-input';\nexport { default as useThrottle } from './hooks/use-throttle';\nexport { default as useMergeRefs } from './hooks/use-merge-refs';\nexport { default as useRefEffect } from './hooks/use-ref-effect';\nexport { default as __experimentalUseDropZone } from './hooks/use-drop-zone';\nexport { default as useFocusableIframe } from './hooks/use-focusable-iframe';\nexport { default as __experimentalUseFixedWindowList } from './hooks/use-fixed-window-list';\nexport { default as useObservableValue } from './hooks/use-observable-value';\n"],"mappings":"AAAA;AACA,cAAc,uCAAuC;AACrD;AACA,cAAc,kBAAkB;AAChC;AACA,cAAc,kBAAkB;AAChC;AACA,cAAc,wBAAwB;;AAEtC;AACA,SAASA,OAAO,IAAIC,OAAO,QAAQ,wBAAwB;AAC3D,SAASD,OAAO,IAAIE,IAAI,QAAQ,qBAAqB;;AAErD;AACA,SAASF,OAAO,IAAIG,WAAW,QAAQ,6BAA6B;AACpE,SAASH,OAAO,IAAII,IAAI,QAAQ,qBAAqB;AACrD,SAASJ,OAAO,IAAIK,gBAAgB,QAAQ,mCAAmC;AAC/E,SAASL,OAAO,IAAIM,cAAc,QAAQ,iCAAiC;AAC3E,SAASN,OAAO,IAAIO,eAAe,QAAQ,kCAAkC;AAC7E,SAASP,OAAO,IAAIQ,SAAS,QAAQ,2BAA2B;;AAEhE;AACA,SAASR,OAAO,IAAIS,qBAAqB,QAAQ,iCAAiC;AAClF,SAAST,OAAO,IAAIU,cAAc,QAAQ,2BAA2B;AACrE,SAASV,OAAO,IAAIW,kBAAkB,QAAQ,+BAA+B;AAC7E,SAASX,OAAO,IAAIY,uBAAuB,QAAQ,oBAAoB;AACvE,SAASZ,OAAO,IAAIa,WAAW,QAAQ,sBAAsB;AAC7D,SAASb,OAAO,IAAIc,QAAQ,QAAQ,mBAAmB;AACvD,SAASd,OAAO,IAAIe,yBAAyB,QAAQ,sBAAsB;AAC3E,SAASf,OAAO,IAAIgB,eAAe,QAAQ,4BAA4B;AACvE,SAAShB,OAAO,IAAIiB,6BAA6B,QAAQ,2BAA2B;AACpF,SAASjB,OAAO,IAAIkB,cAAc,QAAQ,0BAA0B;AACp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SAAS,KAAK,IAAI;IACU,WAAW,QAAvC,SAAS,KAAK,IAAI;IACU,UAAU,QAAtC,SAAS,KAAK,IAAI;IACU,WAAW,QAAvC,SAAS,KAAK,IAAI;IACU,SAAS,QAArC,UAAU,KAAK,IAAI;IACS,MAAM,QAAlC,SAAS,KAAK,IAAI;CAE9B,GAAS,OAAO,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-drop-zone/index.js"],"names":[],"mappings":"AAgCA;;;;;;;;;;;;;;GAcG;AACH,wNAXG;IAAwC,eAAe;IACf,UAAU;IACV,WAAW,QAAvC,SAAS,KAAK,IAAI;IACU,WAAW,QAAvC,SAAS,KAAK,IAAI;IACU,UAAU,QAAtC,SAAS,KAAK,IAAI;IACU,WAAW,QAAvC,SAAS,KAAK,IAAI;IACU,SAAS,QAArC,UAAU,KAAK,IAAI;IACS,MAAM,QAAlC,SAAS,KAAK,IAAI;CAE9B,GAAS,OAAO,OAAO,EAAE,WAAW,CAAC,WAAW,CAAC,CAoMnD"}
|