@wordpress/compose 7.39.1-next.v.202602111440.0 → 7.40.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 +2 -0
- package/README.md +9 -9
- package/build/hooks/use-constrained-tabbing/index.cjs.map +1 -1
- package/build/hooks/use-copy-on-click/index.cjs +1 -1
- package/build/hooks/use-copy-on-click/index.cjs.map +2 -2
- package/build/hooks/use-copy-to-clipboard/index.cjs.map +1 -1
- package/build/hooks/use-dialog/index.cjs +1 -1
- package/build/hooks/use-dialog/index.cjs.map +2 -2
- package/build/hooks/use-disabled/index.cjs.map +1 -1
- package/build/hooks/use-dragging/index.cjs.map +1 -1
- package/build/hooks/use-drop-zone/index.cjs.map +1 -1
- package/build/hooks/use-fixed-window-list/index.cjs.map +1 -1
- package/build/hooks/use-focus-on-mount/index.cjs +1 -1
- package/build/hooks/use-focus-on-mount/index.cjs.map +2 -2
- package/build/hooks/use-focus-outside/index.cjs +1 -1
- package/build/hooks/use-focus-outside/index.cjs.map +2 -2
- package/build/hooks/use-focus-return/index.cjs.map +1 -1
- package/build/hooks/use-keyboard-shortcut/index.cjs.map +1 -1
- package/build/hooks/use-merge-refs/index.cjs +2 -2
- package/build/hooks/use-merge-refs/index.cjs.map +3 -3
- package/build/hooks/use-previous/index.cjs +1 -1
- package/build/hooks/use-previous/index.cjs.map +2 -2
- package/build/hooks/use-ref-effect/index.cjs +1 -1
- package/build/hooks/use-ref-effect/index.cjs.map +2 -2
- package/build/hooks/use-resize-observer/use-resize-observer.cjs +3 -3
- package/build/hooks/use-resize-observer/use-resize-observer.cjs.map +2 -2
- package/build-module/hooks/use-constrained-tabbing/index.mjs.map +1 -1
- package/build-module/hooks/use-copy-on-click/index.mjs +1 -1
- package/build-module/hooks/use-copy-on-click/index.mjs.map +2 -2
- package/build-module/hooks/use-copy-to-clipboard/index.mjs.map +1 -1
- package/build-module/hooks/use-dialog/index.mjs +1 -1
- package/build-module/hooks/use-dialog/index.mjs.map +2 -2
- package/build-module/hooks/use-disabled/index.mjs.map +1 -1
- package/build-module/hooks/use-dragging/index.mjs.map +1 -1
- package/build-module/hooks/use-drop-zone/index.mjs.map +1 -1
- package/build-module/hooks/use-fixed-window-list/index.mjs.map +1 -1
- package/build-module/hooks/use-focus-on-mount/index.mjs +1 -1
- package/build-module/hooks/use-focus-on-mount/index.mjs.map +2 -2
- package/build-module/hooks/use-focus-outside/index.mjs +1 -1
- package/build-module/hooks/use-focus-outside/index.mjs.map +2 -2
- package/build-module/hooks/use-focus-return/index.mjs.map +1 -1
- package/build-module/hooks/use-keyboard-shortcut/index.mjs.map +1 -1
- package/build-module/hooks/use-merge-refs/index.mjs +2 -2
- package/build-module/hooks/use-merge-refs/index.mjs.map +3 -3
- package/build-module/hooks/use-previous/index.mjs +1 -1
- package/build-module/hooks/use-previous/index.mjs.map +2 -2
- package/build-module/hooks/use-ref-effect/index.mjs +1 -1
- package/build-module/hooks/use-ref-effect/index.mjs.map +2 -2
- package/build-module/hooks/use-resize-observer/use-resize-observer.mjs +3 -3
- package/build-module/hooks/use-resize-observer/use-resize-observer.mjs.map +2 -2
- 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-copy-on-click/index.d.ts +5 -5
- package/build-types/hooks/use-copy-on-click/index.d.ts.map +1 -1
- package/build-types/hooks/use-copy-to-clipboard/index.d.ts +2 -2
- package/build-types/hooks/use-copy-to-clipboard/index.d.ts.map +1 -1
- package/build-types/hooks/use-disabled/index.d.ts +1 -1
- package/build-types/hooks/use-dragging/index.d.ts +6 -6
- package/build-types/hooks/use-dragging/index.d.ts.map +1 -1
- package/build-types/hooks/use-drop-zone/index.d.ts +2 -2
- package/build-types/hooks/use-drop-zone/index.d.ts.map +1 -1
- package/build-types/hooks/use-fixed-window-list/index.d.ts +5 -5
- package/build-types/hooks/use-fixed-window-list/index.d.ts.map +1 -1
- package/build-types/hooks/use-focus-on-mount/index.d.ts +2 -2
- package/build-types/hooks/use-focus-on-mount/index.d.ts.map +1 -1
- package/build-types/hooks/use-focus-return/index.d.ts +2 -2
- package/build-types/hooks/use-focus-return/index.d.ts.map +1 -1
- package/build-types/hooks/use-keyboard-shortcut/index.d.ts +10 -9
- package/build-types/hooks/use-keyboard-shortcut/index.d.ts.map +1 -1
- package/build-types/hooks/use-merge-refs/index.d.ts +4 -6
- package/build-types/hooks/use-merge-refs/index.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/hooks/use-constrained-tabbing/index.js +1 -1
- package/src/hooks/use-copy-on-click/index.js +6 -6
- package/src/hooks/use-copy-to-clipboard/index.js +2 -2
- package/src/hooks/use-dialog/index.ts +1 -1
- package/src/hooks/use-disabled/index.ts +1 -1
- package/src/hooks/use-dragging/index.js +5 -5
- package/src/hooks/use-drop-zone/index.js +1 -1
- package/src/hooks/use-fixed-window-list/index.js +4 -4
- package/src/hooks/use-focus-on-mount/index.js +3 -3
- package/src/hooks/use-focus-outside/index.native.js +3 -3
- package/src/hooks/use-focus-outside/index.ts +1 -1
- package/src/hooks/use-focus-return/index.js +3 -3
- package/src/hooks/use-keyboard-shortcut/index.js +7 -7
- package/src/hooks/use-merge-refs/{index.js → index.ts} +11 -22
- package/src/hooks/use-previous/index.ts +1 -1
- package/src/hooks/use-ref-effect/index.ts +1 -1
- package/src/hooks/use-resize-observer/use-resize-observer.ts +3 -3
|
@@ -3,8 +3,8 @@ import { useRef } from "@wordpress/element";
|
|
|
3
3
|
import useEvent from "../use-event/index.mjs";
|
|
4
4
|
function useResizeObserver(callback, resizeObserverOptions = {}) {
|
|
5
5
|
const callbackEvent = useEvent(callback);
|
|
6
|
-
const observedElementRef = useRef();
|
|
7
|
-
const resizeObserverRef = useRef();
|
|
6
|
+
const observedElementRef = useRef(null);
|
|
7
|
+
const resizeObserverRef = useRef(void 0);
|
|
8
8
|
return useEvent((element) => {
|
|
9
9
|
if (element === observedElementRef.current) {
|
|
10
10
|
return;
|
|
@@ -14,7 +14,7 @@ function useResizeObserver(callback, resizeObserverOptions = {}) {
|
|
|
14
14
|
if (observedElementRef.current) {
|
|
15
15
|
resizeObserver.unobserve(observedElementRef.current);
|
|
16
16
|
}
|
|
17
|
-
observedElementRef.current = element;
|
|
17
|
+
observedElementRef.current = element ?? null;
|
|
18
18
|
if (element) {
|
|
19
19
|
resizeObserver.observe(element, resizeObserverOptions);
|
|
20
20
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/hooks/use-resize-observer/use-resize-observer.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport useEvent from '../use-event';\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.\nexport function 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\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\tobservedElementRef.current = element;\n\t\tif ( element ) {\n\t\t\tresizeObserver.observe( element, resizeObserverOptions );\n\t\t}\n\t} );\n}\n"],
|
|
5
|
-
"mappings": ";AAGA,SAAS,cAAc;AAIvB,OAAO,cAAc;AAOd,SAAS,kBACf,UACA,wBAA+C,CAAC,GACf;AACjC,QAAM,gBAAgB,SAAU,QAAS;AAEzC,QAAM,qBAAqB,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\n/**\n * Internal dependencies\n */\nimport useEvent from '../use-event';\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.\nexport function 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 >( null );\n\tconst resizeObserverRef = useRef< ResizeObserver >( undefined );\n\treturn useEvent( ( element?: T | null ) => {\n\t\tif ( element === observedElementRef.current ) {\n\t\t\treturn;\n\t\t}\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\tobservedElementRef.current = element ?? null;\n\t\tif ( element ) {\n\t\t\tresizeObserver.observe( element, resizeObserverOptions );\n\t\t}\n\t} );\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,cAAc;AAIvB,OAAO,cAAc;AAOd,SAAS,kBACf,UACA,wBAA+C,CAAC,GACf;AACjC,QAAM,gBAAgB,SAAU,QAAS;AAEzC,QAAM,qBAAqB,OAAoB,IAAK;AACpD,QAAM,oBAAoB,OAA0B,MAAU;AAC9D,SAAO,SAAU,CAAE,YAAwB;AAC1C,QAAK,YAAY,mBAAmB,SAAU;AAC7C;AAAA,IACD;AAGA,sBAAkB,YAAY,IAAI,eAAgB,aAAc;AAChE,UAAM,EAAE,SAAS,eAAe,IAAI;AAGpC,QAAK,mBAAmB,SAAU;AACjC,qBAAe,UAAW,mBAAmB,OAAQ;AAAA,IACtD;AAGA,uBAAmB,UAAU,WAAW;AACxC,QAAK,SAAU;AACd,qBAAe,QAAS,SAAS,qBAAsB;AAAA,IACxD;AAAA,EACD,CAAE;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,7 +3,7 @@ export default useConstrainedTabbing;
|
|
|
3
3
|
* In Dialogs/modals, the tabbing must be constrained to the content of
|
|
4
4
|
* the wrapper element. This hook adds the behavior to the returned ref.
|
|
5
5
|
*
|
|
6
|
-
* @return {
|
|
6
|
+
* @return {React.RefCallback<Element>} Element Ref.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```js
|
|
@@ -20,5 +20,5 @@ export default useConstrainedTabbing;
|
|
|
20
20
|
* }
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
declare function useConstrainedTabbing():
|
|
23
|
+
declare function useConstrainedTabbing(): React.RefCallback<Element>;
|
|
24
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-constrained-tabbing/index.js"],"names":[],"mappings":";AAUA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,0CAjBY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-constrained-tabbing/index.js"],"names":[],"mappings":";AAUA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,0CAjBY,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CA2ErC"}
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @deprecated
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {string|Function}
|
|
8
|
-
* @param {number}
|
|
9
|
-
*
|
|
6
|
+
* @param {React.RefObject<string | Element | NodeListOf<Element>>} ref Reference with the element.
|
|
7
|
+
* @param {string|Function} text The text to copy.
|
|
8
|
+
* @param {number} [timeout] Optional timeout to reset the returned
|
|
9
|
+
* state. 4 seconds by default.
|
|
10
10
|
*
|
|
11
11
|
* @return {boolean} Whether or not the text has been copied. Resets after the
|
|
12
12
|
* timeout.
|
|
13
13
|
*/
|
|
14
|
-
export default function useCopyOnClick(ref:
|
|
14
|
+
export default function useCopyOnClick(ref: React.RefObject<string | Element | NodeListOf<Element>>, text: string | Function, timeout?: number): boolean;
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-copy-on-click/index.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;GAYG;AACH,4CARW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-copy-on-click/index.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;GAYG;AACH,4CARW,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,QACvD,MAAM,WAAS,YACf,MAAM,GAGL,OAAO,CAqDlB"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* already available and expensive to compute.
|
|
7
7
|
* @param {Function} onSuccess Called when to text is copied.
|
|
8
8
|
*
|
|
9
|
-
* @return {
|
|
9
|
+
* @return {React.Ref<TElementType>} A ref to assign to the target element.
|
|
10
10
|
*/
|
|
11
|
-
export default function useCopyToClipboard<TElementType extends HTMLElement>(text: string | (() => string), onSuccess: Function):
|
|
11
|
+
export default function useCopyToClipboard<TElementType extends HTMLElement>(text: string | (() => string), onSuccess: Function): React.Ref<TElementType>;
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-copy-to-clipboard/index.js"],"names":[],"mappings":"AA4BA;;;;;;;;;GASG;AACH,2CAP2B,YAAY,SAAzB,WAAY,QACf,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,wBAItB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-copy-to-clipboard/index.js"],"names":[],"mappings":"AA4BA;;;;;;;;;GASG;AACH,2CAP2B,YAAY,SAAzB,WAAY,QACf,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,wBAItB,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAgClC"}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @param {Object} config Configuration object.
|
|
9
9
|
* @param {boolean=} config.isDisabled Whether the element should be disabled.
|
|
10
|
-
* @return {
|
|
10
|
+
* @return {React.RefCallback<HTMLElement>} Element Ref.
|
|
11
11
|
*
|
|
12
12
|
* @example
|
|
13
13
|
* ```js
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @param {Object}
|
|
3
|
-
* @param {(e:
|
|
4
|
-
* @param {(e: MouseEvent) => void}
|
|
5
|
-
* @param {(e?: MouseEvent) => void}
|
|
2
|
+
* @param {Object} props
|
|
3
|
+
* @param {(e: React.MouseEvent) => void} props.onDragStart
|
|
4
|
+
* @param {(e: MouseEvent) => void} props.onDragMove
|
|
5
|
+
* @param {(e?: MouseEvent) => void} props.onDragEnd
|
|
6
6
|
*/
|
|
7
7
|
export default function useDragging({ onDragStart, onDragMove, onDragEnd }: {
|
|
8
|
-
onDragStart: (e:
|
|
8
|
+
onDragStart: (e: React.MouseEvent) => void;
|
|
9
9
|
onDragMove: (e: MouseEvent) => void;
|
|
10
10
|
onDragEnd: (e?: MouseEvent) => void;
|
|
11
11
|
}): {
|
|
12
|
-
startDrag: (e:
|
|
12
|
+
startDrag: (e: React.MouseEvent) => void;
|
|
13
13
|
endDrag: (e?: MouseEvent) => void;
|
|
14
14
|
isDragging: boolean;
|
|
15
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-dragging/index.js"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,4EAJG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-dragging/index.js"],"names":[],"mappings":"AAYA;;;;;GAKG;AACH,4EAJG;IAA6C,WAAW,EAAhD,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI;IACQ,UAAU,EAA/C,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI;IACc,SAAS,EAA9C,CAAC,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI;CAClC;mBA+Be,KAAK,CAAC,UAAU,KAAK,IAAI;kBATxB,UAAU,KAAK,IAAI;;EAkCnC"}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @param {(e: MouseEvent) => void} [props.onDragEnd] Called when dragging has ended.
|
|
12
12
|
* @param {(e: DragEvent) => void} [props.onDrop] Called when dropping in the zone.
|
|
13
13
|
*
|
|
14
|
-
* @return {
|
|
14
|
+
* @return {React.RefCallback<HTMLElement>} Ref callback to be passed to the drop zone element.
|
|
15
15
|
*/
|
|
16
16
|
export default function useDropZone({ dropZoneElement, isDisabled, onDrop: _onDrop, onDragStart: _onDragStart, onDragEnter: _onDragEnter, onDragLeave: _onDragLeave, onDragEnd: _onDragEnd, onDragOver: _onDragOver, }: {
|
|
17
17
|
dropZoneElement?: HTMLElement | null | undefined;
|
|
@@ -22,5 +22,5 @@ export default function useDropZone({ dropZoneElement, isDisabled, onDrop: _onDr
|
|
|
22
22
|
onDragLeave?: ((e: DragEvent) => void) | undefined;
|
|
23
23
|
onDragEnd?: ((e: MouseEvent) => void) | undefined;
|
|
24
24
|
onDrop?: ((e: DragEvent) => void) | undefined;
|
|
25
|
-
}):
|
|
25
|
+
}): React.RefCallback<HTMLElement>;
|
|
26
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-drop-zone/index.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-drop-zone/index.js"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;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,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CAoMzC"}
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
*/
|
|
17
17
|
/**
|
|
18
18
|
*
|
|
19
|
-
* @param {
|
|
20
|
-
* @param { number }
|
|
21
|
-
* @param { number }
|
|
22
|
-
* @param { WPFixedWindowListOptions }
|
|
19
|
+
* @param {React.RefObject<HTMLElement>} elementRef Used to find the closest scroll container that contains element.
|
|
20
|
+
* @param { number } itemHeight Fixed item height in pixels
|
|
21
|
+
* @param { number } totalItems Total items in list
|
|
22
|
+
* @param { WPFixedWindowListOptions } [options] Options object
|
|
23
23
|
* @return {[ WPFixedWindowList, setFixedListWindow:(nextWindow:WPFixedWindowList)=>void]} Array with the fixed window list and setter
|
|
24
24
|
*/
|
|
25
|
-
export default function useFixedWindowList(elementRef:
|
|
25
|
+
export default function useFixedWindowList(elementRef: React.RefObject<HTMLElement>, itemHeight: number, totalItems: number, options?: WPFixedWindowListOptions): [WPFixedWindowList, setFixedListWindow: (nextWindow: WPFixedWindowList) => void];
|
|
26
26
|
export type WPFixedWindowList = {
|
|
27
27
|
/**
|
|
28
28
|
* Items visible in the current viewport
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-fixed-window-list/index.js"],"names":[],"mappings":"AAcA;;;;;;;GAOG;AAEH;;;;;;;GAOG;AAEH;;;;;;;GAOG;AACH,uDANW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-fixed-window-list/index.js"],"names":[],"mappings":"AAcA;;;;;;;GAOG;AAEH;;;;;;;GAOG;AAEH;;;;;;;GAOG;AACH,uDANW,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,cAC3B,MAAM,cACN,MAAM,YACN,wBAAwB,GACxB,CAAE,iBAAiB,EAAE,kBAAkB,EAAC,CAAC,UAAU,EAAC,iBAAiB,KAAG,IAAI,CAAC,CA0JxF;;;;;kBA/Ka,MAAM;;;;WACN,MAAM;;;;SACN,MAAM;;;;gBACN,CAAC,KAAK,EAAC,MAAM,KAAG,OAAO;;;;;;;;;;;;;;;;;;oBASvB,GAAG"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Hook used to focus the first tabbable element on mount.
|
|
3
3
|
*
|
|
4
4
|
* @param {boolean | 'firstElement' | 'firstInputElement'} focusOnMount Focus on mount mode.
|
|
5
|
-
* @return {
|
|
5
|
+
* @return {React.RefCallback<HTMLElement>} Ref callback.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
8
|
* ```js
|
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
* }
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
|
-
export default function useFocusOnMount(focusOnMount?: boolean | "firstElement" | "firstInputElement"):
|
|
22
|
+
export default function useFocusOnMount(focusOnMount?: boolean | "firstElement" | "firstInputElement"): React.RefCallback<HTMLElement>;
|
|
23
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-focus-on-mount/index.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,uDAlBW,OAAO,GAAG,cAAc,GAAG,mBAAmB,GAC7C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-focus-on-mount/index.js"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,uDAlBW,OAAO,GAAG,cAAc,GAAG,mBAAmB,GAC7C,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CA4FzC"}
|
|
@@ -4,7 +4,7 @@ export default useFocusReturn;
|
|
|
4
4
|
* previously as is expected for roles like menus or dialogs.
|
|
5
5
|
*
|
|
6
6
|
* @param {() => void} [onFocusReturn] Overrides the default return behavior.
|
|
7
|
-
* @return {
|
|
7
|
+
* @return {React.RefCallback<HTMLElement>} Element Ref.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
10
|
* ```js
|
|
@@ -21,5 +21,5 @@ export default useFocusReturn;
|
|
|
21
21
|
* }
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
-
declare function useFocusReturn(onFocusReturn?: () => void):
|
|
24
|
+
declare function useFocusReturn(onFocusReturn?: () => void): React.RefCallback<HTMLElement>;
|
|
25
25
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-focus-return/index.js"],"names":[],"mappings":";AAQA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,gDAlBW,MAAM,IAAI,GACT,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-focus-return/index.js"],"names":[],"mappings":";AAQA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,gDAlBW,MAAM,IAAI,GACT,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CAsEzC"}
|
|
@@ -18,26 +18,27 @@ export type WPKeyboardShortcutConfig = {
|
|
|
18
18
|
/**
|
|
19
19
|
* React reference to the DOM element used to catch the keyboard event.
|
|
20
20
|
*/
|
|
21
|
-
target?: import("react").RefObject<HTMLElement> | undefined;
|
|
21
|
+
target?: import("react").RefObject<HTMLElement | null> | undefined;
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
24
|
* A block selection object.
|
|
25
25
|
*
|
|
26
26
|
* @typedef {Object} WPKeyboardShortcutConfig
|
|
27
27
|
*
|
|
28
|
-
* @property {boolean}
|
|
29
|
-
* @property {string}
|
|
30
|
-
* @property {boolean}
|
|
31
|
-
* @property {
|
|
28
|
+
* @property {boolean} [bindGlobal] Handle keyboard events anywhere including inside textarea/input fields.
|
|
29
|
+
* @property {string} [eventName] Event name used to trigger the handler, defaults to keydown.
|
|
30
|
+
* @property {boolean} [isDisabled] Disables the keyboard handler if the value is true.
|
|
31
|
+
* @property {React.RefObject<HTMLElement | null>} [target] React reference to the DOM element used to catch the keyboard event.
|
|
32
32
|
*/
|
|
33
33
|
/**
|
|
34
34
|
* Attach a keyboard shortcut handler.
|
|
35
35
|
*
|
|
36
36
|
* @see https://craig.is/killing/mice#api.bind for information about the `callback` parameter.
|
|
37
37
|
*
|
|
38
|
-
* @param {string[]|string}
|
|
39
|
-
* @param {(e:
|
|
40
|
-
* @param {WPKeyboardShortcutConfig}
|
|
38
|
+
* @param {string[]|string} shortcuts Keyboard Shortcuts.
|
|
39
|
+
* @param {(e: Mousetrap.ExtendedKeyboardEvent, combo: string) => void} callback Shortcut callback.
|
|
40
|
+
* @param {WPKeyboardShortcutConfig} options Shortcut options.
|
|
41
41
|
*/
|
|
42
|
-
declare function useKeyboardShortcut(shortcuts: string[] | string, callback: (e:
|
|
42
|
+
declare function useKeyboardShortcut(shortcuts: string[] | string, callback: (e: Mousetrap.ExtendedKeyboardEvent, combo: string) => void, { bindGlobal, eventName, isDisabled, target, }?: WPKeyboardShortcutConfig): void;
|
|
43
|
+
import Mousetrap from 'mousetrap';
|
|
43
44
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-keyboard-shortcut/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAYA;;;;;;;;;GASG;AAEH;;;;;;;;GAQG;AACH,gDAJW,MAAM,EAAE,GAAC,MAAM,YACf,CAAC,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-keyboard-shortcut/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAYA;;;;;;;;;GASG;AAEH;;;;;;;;GAQG;AACH,gDAJW,MAAM,EAAE,GAAC,MAAM,YACf,CAAC,CAAC,EAAE,SAAS,CAAC,qBAAqB,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,mDAC3D,wBAAwB,QAqElC;sBAhGqB,WAAW"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Ref, RefCallback } from 'react';
|
|
1
2
|
/**
|
|
2
3
|
* Merges refs into one ref callback.
|
|
3
4
|
*
|
|
@@ -36,11 +37,8 @@
|
|
|
36
37
|
* return <div ref={ mergedRefs } />;
|
|
37
38
|
* ```
|
|
38
39
|
*
|
|
39
|
-
* @
|
|
40
|
-
* @
|
|
41
|
-
*
|
|
42
|
-
* @return {import('react').RefCallback<TypeFromRef<TRef>>} The merged ref callback.
|
|
40
|
+
* @param refs The refs to be merged.
|
|
41
|
+
* @return The merged ref callback.
|
|
43
42
|
*/
|
|
44
|
-
export default function useMergeRefs<
|
|
45
|
-
export type TypeFromRef<T> = T extends import("react").Ref<infer R> ? R : never;
|
|
43
|
+
export default function useMergeRefs<T>(refs: Ref<T>[]): RefCallback<T>;
|
|
46
44
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-merge-refs/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-merge-refs/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAoB,GAAG,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAUhE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,CAAC,EACtC,IAAI,EAAE,GAAG,CAAE,CAAC,CAAE,EAAE,GACd,WAAW,CAAE,CAAC,CAAE,CA0DlB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/compose",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.40.0",
|
|
4
4
|
"description": "WordPress higher-order components (HOCs).",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"sideEffects": false,
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@types/mousetrap": "^1.6.8",
|
|
50
|
-
"@wordpress/deprecated": "^4.
|
|
51
|
-
"@wordpress/dom": "^4.
|
|
52
|
-
"@wordpress/element": "^6.
|
|
53
|
-
"@wordpress/is-shallow-equal": "^5.
|
|
54
|
-
"@wordpress/keycodes": "^4.
|
|
55
|
-
"@wordpress/priority-queue": "^3.
|
|
56
|
-
"@wordpress/undo-manager": "^1.
|
|
50
|
+
"@wordpress/deprecated": "^4.40.0",
|
|
51
|
+
"@wordpress/dom": "^4.40.0",
|
|
52
|
+
"@wordpress/element": "^6.40.0",
|
|
53
|
+
"@wordpress/is-shallow-equal": "^5.40.0",
|
|
54
|
+
"@wordpress/keycodes": "^4.40.0",
|
|
55
|
+
"@wordpress/priority-queue": "^3.40.0",
|
|
56
|
+
"@wordpress/undo-manager": "^1.40.0",
|
|
57
57
|
"change-case": "^4.1.2",
|
|
58
58
|
"clipboard": "^2.0.11",
|
|
59
59
|
"mousetrap": "^1.6.5",
|
|
@@ -68,5 +68,5 @@
|
|
|
68
68
|
"publishConfig": {
|
|
69
69
|
"access": "public"
|
|
70
70
|
},
|
|
71
|
-
"gitHead": "
|
|
71
|
+
"gitHead": "376124aa10dbc2cc0c81c964ec00b99fcfee5382"
|
|
72
72
|
}
|
|
@@ -12,7 +12,7 @@ import useRefEffect from '../use-ref-effect';
|
|
|
12
12
|
* In Dialogs/modals, the tabbing must be constrained to the content of
|
|
13
13
|
* the wrapper element. This hook adds the behavior to the returned ref.
|
|
14
14
|
*
|
|
15
|
-
* @return {
|
|
15
|
+
* @return {React.RefCallback<Element>} Element Ref.
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* ```js
|
|
@@ -14,10 +14,10 @@ import deprecated from '@wordpress/deprecated';
|
|
|
14
14
|
*
|
|
15
15
|
* @deprecated
|
|
16
16
|
*
|
|
17
|
-
* @param {
|
|
18
|
-
* @param {string|Function}
|
|
19
|
-
* @param {number}
|
|
20
|
-
*
|
|
17
|
+
* @param {React.RefObject<string | Element | NodeListOf<Element>>} ref Reference with the element.
|
|
18
|
+
* @param {string|Function} text The text to copy.
|
|
19
|
+
* @param {number} [timeout] Optional timeout to reset the returned
|
|
20
|
+
* state. 4 seconds by default.
|
|
21
21
|
*
|
|
22
22
|
* @return {boolean} Whether or not the text has been copied. Resets after the
|
|
23
23
|
* timeout.
|
|
@@ -28,8 +28,8 @@ export default function useCopyOnClick( ref, text, timeout = 4000 ) {
|
|
|
28
28
|
alternative: 'wp.compose.useCopyToClipboard',
|
|
29
29
|
} );
|
|
30
30
|
|
|
31
|
-
/** @type {
|
|
32
|
-
const clipboardRef = useRef();
|
|
31
|
+
/** @type {React.MutableRefObject<Clipboard | undefined>} */
|
|
32
|
+
const clipboardRef = useRef( undefined );
|
|
33
33
|
const [ hasCopied, setHasCopied ] = useState( false );
|
|
34
34
|
|
|
35
35
|
useEffect( () => {
|
|
@@ -16,7 +16,7 @@ import useRefEffect from '../use-ref-effect';
|
|
|
16
16
|
/**
|
|
17
17
|
* @template T
|
|
18
18
|
* @param {T} value
|
|
19
|
-
* @return {
|
|
19
|
+
* @return {React.RefObject<T>} The updated ref
|
|
20
20
|
*/
|
|
21
21
|
function useUpdatedRef( value ) {
|
|
22
22
|
const ref = useRef( value );
|
|
@@ -34,7 +34,7 @@ function useUpdatedRef( value ) {
|
|
|
34
34
|
* already available and expensive to compute.
|
|
35
35
|
* @param {Function} onSuccess Called when to text is copied.
|
|
36
36
|
*
|
|
37
|
-
* @return {
|
|
37
|
+
* @return {React.Ref<TElementType>} A ref to assign to the target element.
|
|
38
38
|
*/
|
|
39
39
|
export default function useCopyToClipboard( text, onSuccess ) {
|
|
40
40
|
// Store the dependencies as refs and continuously update them so they're
|
|
@@ -66,7 +66,7 @@ type useDialogReturn = [
|
|
|
66
66
|
* @param options Dialog Options.
|
|
67
67
|
*/
|
|
68
68
|
function useDialog( options: DialogOptions ): useDialogReturn {
|
|
69
|
-
const currentOptions = useRef< DialogOptions
|
|
69
|
+
const currentOptions = useRef< DialogOptions >( undefined );
|
|
70
70
|
const { constrainTabbing = options.focusOnMount !== false } = options;
|
|
71
71
|
useEffect( () => {
|
|
72
72
|
currentOptions.current = options;
|
|
@@ -13,7 +13,7 @@ import useRefEffect from '../use-ref-effect';
|
|
|
13
13
|
*
|
|
14
14
|
* @param {Object} config Configuration object.
|
|
15
15
|
* @param {boolean=} config.isDisabled Whether the element should be disabled.
|
|
16
|
-
* @return {
|
|
16
|
+
* @return {React.RefCallback<HTMLElement>} Element Ref.
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```js
|
|
@@ -11,10 +11,10 @@ import useIsomorphicLayoutEffect from '../use-isomorphic-layout-effect';
|
|
|
11
11
|
// Event handlers that are triggered from `document` listeners accept a MouseEvent,
|
|
12
12
|
// while those triggered from React listeners accept a React.MouseEvent.
|
|
13
13
|
/**
|
|
14
|
-
* @param {Object}
|
|
15
|
-
* @param {(e:
|
|
16
|
-
* @param {(e: MouseEvent) => void}
|
|
17
|
-
* @param {(e?: MouseEvent) => void}
|
|
14
|
+
* @param {Object} props
|
|
15
|
+
* @param {(e: React.MouseEvent) => void} props.onDragStart
|
|
16
|
+
* @param {(e: MouseEvent) => void} props.onDragMove
|
|
17
|
+
* @param {(e?: MouseEvent) => void} props.onDragEnd
|
|
18
18
|
*/
|
|
19
19
|
export default function useDragging( { onDragStart, onDragMove, onDragEnd } ) {
|
|
20
20
|
const [ isDragging, setIsDragging ] = useState( false );
|
|
@@ -46,7 +46,7 @@ export default function useDragging( { onDragStart, onDragMove, onDragEnd } ) {
|
|
|
46
46
|
document.removeEventListener( 'mouseup', endDrag );
|
|
47
47
|
setIsDragging( false );
|
|
48
48
|
}, [] );
|
|
49
|
-
/** @type {(e:
|
|
49
|
+
/** @type {(e: React.MouseEvent) => void} */
|
|
50
50
|
const startDrag = useCallback( ( event ) => {
|
|
51
51
|
if ( eventsRef.current.onDragStart ) {
|
|
52
52
|
eventsRef.current.onDragStart( event );
|
|
@@ -17,7 +17,7 @@ import useEvent from '../use-event';
|
|
|
17
17
|
* @param {(e: MouseEvent) => void} [props.onDragEnd] Called when dragging has ended.
|
|
18
18
|
* @param {(e: DragEvent) => void} [props.onDrop] Called when dropping in the zone.
|
|
19
19
|
*
|
|
20
|
-
* @return {
|
|
20
|
+
* @return {React.RefCallback<HTMLElement>} Ref callback to be passed to the drop zone element.
|
|
21
21
|
*/
|
|
22
22
|
export default function useDropZone( {
|
|
23
23
|
dropZoneElement,
|
|
@@ -32,10 +32,10 @@ const DEFAULT_INIT_WINDOW_SIZE = 30;
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
*
|
|
35
|
-
* @param {
|
|
36
|
-
* @param { number }
|
|
37
|
-
* @param { number }
|
|
38
|
-
* @param { WPFixedWindowListOptions }
|
|
35
|
+
* @param {React.RefObject<HTMLElement>} elementRef Used to find the closest scroll container that contains element.
|
|
36
|
+
* @param { number } itemHeight Fixed item height in pixels
|
|
37
|
+
* @param { number } totalItems Total items in list
|
|
38
|
+
* @param { WPFixedWindowListOptions } [options] Options object
|
|
39
39
|
* @return {[ WPFixedWindowList, setFixedListWindow:(nextWindow:WPFixedWindowList)=>void]} Array with the fixed window list and setter
|
|
40
40
|
*/
|
|
41
41
|
export default function useFixedWindowList(
|
|
@@ -13,7 +13,7 @@ import useRefEffect from '../use-ref-effect';
|
|
|
13
13
|
* Hook used to focus the first tabbable element on mount.
|
|
14
14
|
*
|
|
15
15
|
* @param {boolean | 'firstElement' | 'firstInputElement'} focusOnMount Focus on mount mode.
|
|
16
|
-
* @return {
|
|
16
|
+
* @return {React.RefCallback<HTMLElement>} Ref callback.
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```js
|
|
@@ -48,8 +48,8 @@ export default function useFocusOnMount( focusOnMount = 'firstElement' ) {
|
|
|
48
48
|
} );
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
/** @type {
|
|
52
|
-
const timerIdRef = useRef();
|
|
51
|
+
/** @type {React.MutableRefObject<ReturnType<setTimeout> | undefined>} */
|
|
52
|
+
const timerIdRef = useRef( undefined );
|
|
53
53
|
|
|
54
54
|
useEffect( () => {
|
|
55
55
|
focusOnMountRef.current = focusOnMount;
|
|
@@ -41,7 +41,7 @@ function isFocusNormalizedButton( eventTarget ) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
|
-
* @typedef {
|
|
44
|
+
* @typedef {React.SyntheticEvent} SyntheticEvent
|
|
45
45
|
*/
|
|
46
46
|
|
|
47
47
|
/**
|
|
@@ -55,7 +55,7 @@ function isFocusNormalizedButton( eventTarget ) {
|
|
|
55
55
|
*/
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* @typedef {
|
|
58
|
+
* @typedef {React.MutableRefObject<FocusOutsideReactElement | undefined>} FocusOutsideRef
|
|
59
59
|
*/
|
|
60
60
|
|
|
61
61
|
/**
|
|
@@ -88,7 +88,7 @@ export default function useFocusOutside( onFocusOutside ) {
|
|
|
88
88
|
const preventBlurCheck = useRef( false );
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
|
-
* @type {
|
|
91
|
+
* @type {React.MutableRefObject<number | undefined>}
|
|
92
92
|
*/
|
|
93
93
|
const blurCheckTimeoutId = useRef();
|
|
94
94
|
|
|
@@ -78,7 +78,7 @@ export default function useFocusOutside(
|
|
|
78
78
|
|
|
79
79
|
const preventBlurCheckRef = useRef( false );
|
|
80
80
|
|
|
81
|
-
const blurCheckTimeoutIdRef = useRef< number
|
|
81
|
+
const blurCheckTimeoutIdRef = useRef< number >( undefined );
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
84
|
* Cancel a blur check timeout.
|
|
@@ -11,7 +11,7 @@ let origin = null;
|
|
|
11
11
|
* previously as is expected for roles like menus or dialogs.
|
|
12
12
|
*
|
|
13
13
|
* @param {() => void} [onFocusReturn] Overrides the default return behavior.
|
|
14
|
-
* @return {
|
|
14
|
+
* @return {React.RefCallback<HTMLElement>} Element Ref.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```js
|
|
@@ -29,9 +29,9 @@ let origin = null;
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
function useFocusReturn( onFocusReturn ) {
|
|
32
|
-
/** @type {
|
|
32
|
+
/** @type {React.MutableRefObject<null | HTMLElement>} */
|
|
33
33
|
const ref = useRef( null );
|
|
34
|
-
/** @type {
|
|
34
|
+
/** @type {React.MutableRefObject<null | Element>} */
|
|
35
35
|
const focusedBeforeMount = useRef( null );
|
|
36
36
|
const onFocusReturnRef = useRef( onFocusReturn );
|
|
37
37
|
useEffect( () => {
|
|
@@ -15,10 +15,10 @@ import { isAppleOS } from '@wordpress/keycodes';
|
|
|
15
15
|
*
|
|
16
16
|
* @typedef {Object} WPKeyboardShortcutConfig
|
|
17
17
|
*
|
|
18
|
-
* @property {boolean}
|
|
19
|
-
* @property {string}
|
|
20
|
-
* @property {boolean}
|
|
21
|
-
* @property {
|
|
18
|
+
* @property {boolean} [bindGlobal] Handle keyboard events anywhere including inside textarea/input fields.
|
|
19
|
+
* @property {string} [eventName] Event name used to trigger the handler, defaults to keydown.
|
|
20
|
+
* @property {boolean} [isDisabled] Disables the keyboard handler if the value is true.
|
|
21
|
+
* @property {React.RefObject<HTMLElement | null>} [target] React reference to the DOM element used to catch the keyboard event.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -26,9 +26,9 @@ import { isAppleOS } from '@wordpress/keycodes';
|
|
|
26
26
|
*
|
|
27
27
|
* @see https://craig.is/killing/mice#api.bind for information about the `callback` parameter.
|
|
28
28
|
*
|
|
29
|
-
* @param {string[]|string}
|
|
30
|
-
* @param {(e:
|
|
31
|
-
* @param {WPKeyboardShortcutConfig}
|
|
29
|
+
* @param {string[]|string} shortcuts Keyboard Shortcuts.
|
|
30
|
+
* @param {(e: Mousetrap.ExtendedKeyboardEvent, combo: string) => void} callback Shortcut callback.
|
|
31
|
+
* @param {WPKeyboardShortcutConfig} options Shortcut options.
|
|
32
32
|
*/
|
|
33
33
|
function useKeyboardShortcut(
|
|
34
34
|
shortcuts,
|