@wordpress/compose 6.5.0 → 6.7.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 +4 -0
- package/build/higher-order/if-condition/index.js.map +1 -1
- package/build/higher-order/pure/index.js.map +1 -1
- package/build/hooks/use-focus-on-mount/index.js +36 -14
- package/build/hooks/use-focus-on-mount/index.js.map +1 -1
- package/build/hooks/use-media-query/index.js +37 -14
- package/build/hooks/use-media-query/index.js.map +1 -1
- package/build/index.native.js +0 -9
- package/build/index.native.js.map +1 -1
- package/build-module/higher-order/if-condition/index.js.map +1 -1
- package/build-module/higher-order/pure/index.js.map +1 -1
- package/build-module/hooks/use-focus-on-mount/index.js +36 -14
- package/build-module/hooks/use-focus-on-mount/index.js.map +1 -1
- package/build-module/hooks/use-media-query/index.js +38 -15
- package/build-module/hooks/use-media-query/index.js.map +1 -1
- package/build-module/index.native.js +0 -1
- package/build-module/index.native.js.map +1 -1
- package/build-types/higher-order/if-condition/index.d.ts +1 -1
- package/build-types/higher-order/if-condition/index.d.ts.map +1 -1
- package/build-types/higher-order/pure/index.d.ts +1 -1
- package/build-types/higher-order/pure/index.d.ts.map +1 -1
- package/build-types/higher-order/with-instance-id/index.d.ts +1 -1
- package/build-types/higher-order/with-instance-id/index.d.ts.map +1 -1
- package/build-types/hooks/use-async-list/index.d.ts +1 -1
- package/build-types/hooks/use-async-list/index.d.ts.map +1 -1
- package/build-types/hooks/use-dialog/index.d.ts +2 -2
- package/build-types/hooks/use-dialog/index.d.ts.map +1 -1
- package/build-types/hooks/use-dragging/index.d.ts +2 -2
- package/build-types/hooks/use-dragging/index.d.ts.map +1 -1
- package/build-types/hooks/use-focus-on-mount/index.d.ts.map +1 -1
- package/build-types/hooks/use-focus-outside/index.d.ts +1 -1
- package/build-types/hooks/use-focus-outside/index.d.ts.map +1 -1
- package/build-types/hooks/use-media-query/index.d.ts.map +1 -1
- package/build-types/utils/create-higher-order-component/index.d.ts +3 -3
- package/build-types/utils/create-higher-order-component/index.d.ts.map +1 -1
- package/build-types/utils/debounce/index.d.ts +1 -1
- package/build-types/utils/debounce/index.d.ts.map +1 -1
- package/build-types/utils/throttle/index.d.ts +1 -1
- package/build-types/utils/throttle/index.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/higher-order/if-condition/index.tsx +3 -1
- package/src/higher-order/pure/index.tsx +1 -1
- package/src/hooks/use-disabled/test/index.js +0 -2
- package/src/hooks/use-focus-on-mount/index.js +36 -12
- package/src/hooks/use-media-query/index.js +44 -21
- package/src/hooks/use-media-query/test/index.js +24 -86
- package/src/index.native.js +0 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/compose/src/higher-order/if-condition/index.tsx"],"names":["ifCondition","predicate","WrappedComponent","props"],"mappings":";;;;;;;;;AAQA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/compose/src/higher-order/if-condition/index.tsx"],"names":["ifCondition","predicate","WrappedComponent","props"],"mappings":";;;;;;;;;AAQA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAT,CACCC,SADD,EAEE;AACD,SAAO,4DACJC,gBAAF,IAAkDC,KAAF,IAAoB;AACnE,QAAK,CAAEF,SAAS,CAAEE,KAAF,CAAhB,EAA4B;AAC3B,aAAO,IAAP;AACA;;AAED,WAAO,4BAAC,gBAAD,EAAuBA,KAAvB,CAAP;AACA,GAPK,EAQN,aARM,CAAP;AAUA;;eAEcH,W","sourcesContent":["/**\n * External dependencies\n */\nimport type { ComponentType } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * Higher-order component creator, creating a new component which renders if\n * the given condition is satisfied or with the given optional prop name.\n *\n * @example\n * ```ts\n * type Props = { foo: string };\n * const Component = ( props: Props ) => <div>{ props.foo }</div>;\n * const ConditionalComponent = ifCondition( ( props: Props ) => props.foo.length !== 0 )( Component );\n * <ConditionalComponent foo=\"\" />; // => null\n * <ConditionalComponent foo=\"bar\" />; // => <div>bar</div>;\n * ```\n *\n * @param predicate Function to test condition.\n *\n * @return Higher-order component.\n */\nfunction ifCondition< Props extends {} >(\n\tpredicate: ( props: Props ) => boolean\n) {\n\treturn createHigherOrderComponent(\n\t\t( WrappedComponent: ComponentType< Props > ) => ( props: Props ) => {\n\t\t\tif ( ! predicate( props ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn <WrappedComponent { ...props } />;\n\t\t},\n\t\t'ifCondition'\n\t);\n}\n\nexport default ifCondition;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/compose/src/higher-order/pure/index.tsx"],"names":["pure","WrappedComponent","prototype","Component","shouldComponentUpdate","nextProps","nextState","props","state","render"],"mappings":";;;;;;;;;AASA;;AADA;;AAMA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA,MAAMA,IAAI,GAAG,4DAA4B,UACxCC,gBADwC,EAEf;AACzB,MAAKA,gBAAgB,CAACC,SAAjB,YAAsCC,kBAA3C,EAAuD;AACtD,WAAO,cAAgBF,gBAAhB,CAA8D;AACpEG,MAAAA,qBAAqB,CAAEC,SAAF,EAAoBC,SAApB,EAAqC;AACzD,eACC,CAAE,6BAAgBD,SAAhB,EAA2B,KAAKE,KAAhC,CAAF,IACA,CAAE,6BAAgBD,SAAhB,EAA2B,KAAKE,KAAhC,CAFH;AAIA;;AANmE,KAArE;AAQA;;AAED,SAAO,cAAcL,kBAAd,CAAiC;AACvCC,IAAAA,qBAAqB,CAAEC,SAAF,EAAqB;AACzC,aAAO,CAAE,6BAAgBA,SAAhB,EAA2B,KAAKE,KAAhC,CAAT;AACA;;AAEDE,IAAAA,MAAM,GAAG;AACR,aAAO,4BAAC,gBAAD,EAAuB,KAAKF,KAA5B,CAAP;AACA;;AAPsC,GAAxC;AASA,CAvBY,EAwBb,MAxBa,CAAb;eA0BeP,I","sourcesContent":["/**\n * External dependencies\n */\nimport type { ComponentType, ComponentClass } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * Given a component returns the enhanced component augmented with a component\n * only re-rendering when its props/state change\n */\nconst pure = createHigherOrderComponent( function < Props >(\n\tWrappedComponent: ComponentType< Props >\n): ComponentType< Props > {\n\tif ( WrappedComponent.prototype instanceof Component ) {\n\t\treturn class extends ( WrappedComponent as ComponentClass< Props > ) {\n\t\t\tshouldComponentUpdate( nextProps: Props, nextState: any ) {\n\t\t\t\treturn (\n\t\t\t\t\t! isShallowEqual( nextProps, this.props ) ||\n\t\t\t\t\t! isShallowEqual( nextState, this.state )\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t}\n\n\treturn class extends Component< Props > {\n\t\tshouldComponentUpdate( nextProps: Props ) {\n\t\t\treturn ! isShallowEqual( nextProps, this.props );\n\t\t}\n\n\t\trender() {\n\t\t\treturn <WrappedComponent { ...this.props } />;\n\t\t}\n\t};\n},\n'pure' );\n\nexport default pure;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/compose/src/higher-order/pure/index.tsx"],"names":["pure","WrappedComponent","prototype","Component","shouldComponentUpdate","nextProps","nextState","props","state","render"],"mappings":";;;;;;;;;AASA;;AADA;;AAMA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA,MAAMA,IAAI,GAAG,4DAA4B,UACxCC,gBADwC,EAEf;AACzB,MAAKA,gBAAgB,CAACC,SAAjB,YAAsCC,kBAA3C,EAAuD;AACtD,WAAO,cAAgBF,gBAAhB,CAA8D;AACpEG,MAAAA,qBAAqB,CAAEC,SAAF,EAAoBC,SAApB,EAAqC;AACzD,eACC,CAAE,6BAAgBD,SAAhB,EAA2B,KAAKE,KAAhC,CAAF,IACA,CAAE,6BAAgBD,SAAhB,EAA2B,KAAKE,KAAhC,CAFH;AAIA;;AANmE,KAArE;AAQA;;AAED,SAAO,cAAcL,kBAAd,CAAiC;AACvCC,IAAAA,qBAAqB,CAAEC,SAAF,EAAqB;AACzC,aAAO,CAAE,6BAAgBA,SAAhB,EAA2B,KAAKE,KAAhC,CAAT;AACA;;AAEDE,IAAAA,MAAM,GAAG;AACR,aAAO,4BAAC,gBAAD,EAAuB,KAAKF,KAA5B,CAAP;AACA;;AAPsC,GAAxC;AASA,CAvBY,EAwBb,MAxBa,CAAb;eA0BeP,I","sourcesContent":["/**\n * External dependencies\n */\nimport type { ComponentType, ComponentClass } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * Given a component returns the enhanced component augmented with a component\n * only re-rendering when its props/state change\n */\nconst pure = createHigherOrderComponent( function < Props extends {} >(\n\tWrappedComponent: ComponentType< Props >\n): ComponentType< Props > {\n\tif ( WrappedComponent.prototype instanceof Component ) {\n\t\treturn class extends ( WrappedComponent as ComponentClass< Props > ) {\n\t\t\tshouldComponentUpdate( nextProps: Props, nextState: any ) {\n\t\t\t\treturn (\n\t\t\t\t\t! isShallowEqual( nextProps, this.props ) ||\n\t\t\t\t\t! isShallowEqual( nextState, this.state )\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t}\n\n\treturn class extends Component< Props > {\n\t\tshouldComponentUpdate( nextProps: Props ) {\n\t\t\treturn ! isShallowEqual( nextProps, this.props );\n\t\t}\n\n\t\trender() {\n\t\t\treturn <WrappedComponent { ...this.props } />;\n\t\t}\n\t};\n},\n'pure' );\n\nexport default pure;\n"]}
|
|
@@ -37,9 +37,35 @@ var _dom = require("@wordpress/dom");
|
|
|
37
37
|
function useFocusOnMount() {
|
|
38
38
|
let focusOnMount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'firstElement';
|
|
39
39
|
const focusOnMountRef = (0, _element.useRef)(focusOnMount);
|
|
40
|
+
/**
|
|
41
|
+
* Sets focus on a DOM element.
|
|
42
|
+
*
|
|
43
|
+
* @param {HTMLElement} target The DOM element to set focus to.
|
|
44
|
+
* @return {void}
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
const setFocus = target => {
|
|
48
|
+
target.focus({
|
|
49
|
+
// When focusing newly mounted dialogs,
|
|
50
|
+
// the position of the popover is often not right on the first render
|
|
51
|
+
// This prevents the layout shifts when focusing the dialogs.
|
|
52
|
+
preventScroll: true
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
/** @type {import('react').MutableRefObject<ReturnType<setTimeout> | undefined>} */
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
const timerId = (0, _element.useRef)();
|
|
40
59
|
(0, _element.useEffect)(() => {
|
|
41
60
|
focusOnMountRef.current = focusOnMount;
|
|
42
61
|
}, [focusOnMount]);
|
|
62
|
+
(0, _element.useEffect)(() => {
|
|
63
|
+
return () => {
|
|
64
|
+
if (timerId.current) {
|
|
65
|
+
clearTimeout(timerId.current);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}, []);
|
|
43
69
|
return (0, _element.useCallback)(node => {
|
|
44
70
|
var _node$ownerDocument$a, _node$ownerDocument;
|
|
45
71
|
|
|
@@ -51,24 +77,20 @@ function useFocusOnMount() {
|
|
|
51
77
|
return;
|
|
52
78
|
}
|
|
53
79
|
|
|
54
|
-
let target = node;
|
|
55
|
-
|
|
56
80
|
if (focusOnMountRef.current === 'firstElement') {
|
|
57
|
-
|
|
81
|
+
timerId.current = setTimeout(() => {
|
|
82
|
+
const firstTabbable = _dom.focus.tabbable.find(node)[0];
|
|
58
83
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
84
|
+
if (firstTabbable) {
|
|
85
|
+
setFocus(
|
|
86
|
+
/** @type {HTMLElement} */
|
|
87
|
+
firstTabbable);
|
|
88
|
+
}
|
|
89
|
+
}, 0);
|
|
90
|
+
return;
|
|
64
91
|
}
|
|
65
92
|
|
|
66
|
-
|
|
67
|
-
// When focusing newly mounted dialogs,
|
|
68
|
-
// the position of the popover is often not right on the first render
|
|
69
|
-
// This prevents the layout shifts when focusing the dialogs.
|
|
70
|
-
preventScroll: true
|
|
71
|
-
});
|
|
93
|
+
setFocus(node);
|
|
72
94
|
}, []);
|
|
73
95
|
}
|
|
74
96
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/compose/src/hooks/use-focus-on-mount/index.js"],"names":["useFocusOnMount","focusOnMount","focusOnMountRef","current","node","contains","ownerDocument","activeElement","
|
|
1
|
+
{"version":3,"sources":["@wordpress/compose/src/hooks/use-focus-on-mount/index.js"],"names":["useFocusOnMount","focusOnMount","focusOnMountRef","setFocus","target","focus","preventScroll","timerId","current","clearTimeout","node","contains","ownerDocument","activeElement","setTimeout","firstTabbable","tabbable","find"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,eAAT,GAA0D;AAAA,MAAhCC,YAAgC,uEAAjB,cAAiB;AACxE,QAAMC,eAAe,GAAG,qBAAQD,YAAR,CAAxB;AAEA;AACD;AACA;AACA;AACA;AACA;;AACC,QAAME,QAAQ,GAAKC,MAAF,IAAc;AAC9BA,IAAAA,MAAM,CAACC,KAAP,CAAc;AACb;AACA;AACA;AACAC,MAAAA,aAAa,EAAE;AAJF,KAAd;AAMA,GAPD;AASA;;;AACA,QAAMC,OAAO,GAAG,sBAAhB;AAEA,0BAAW,MAAM;AAChBL,IAAAA,eAAe,CAACM,OAAhB,GAA0BP,YAA1B;AACA,GAFD,EAEG,CAAEA,YAAF,CAFH;AAIA,0BAAW,MAAM;AAChB,WAAO,MAAM;AACZ,UAAKM,OAAO,CAACC,OAAb,EAAuB;AACtBC,QAAAA,YAAY,CAAEF,OAAO,CAACC,OAAV,CAAZ;AACA;AACD,KAJD;AAKA,GAND,EAMG,EANH;AAQA,SAAO,0BAAeE,IAAF,IAAY;AAAA;;AAC/B,QAAK,CAAEA,IAAF,IAAUR,eAAe,CAACM,OAAhB,KAA4B,KAA3C,EAAmD;AAClD;AACA;;AAED,QAAKE,IAAI,CAACC,QAAL,iDAAeD,IAAI,CAACE,aAApB,wDAAe,oBAAoBC,aAAnC,yEAAoD,IAApD,CAAL,EAAkE;AACjE;AACA;;AAED,QAAKX,eAAe,CAACM,OAAhB,KAA4B,cAAjC,EAAkD;AACjDD,MAAAA,OAAO,CAACC,OAAR,GAAkBM,UAAU,CAAE,MAAM;AACnC,cAAMC,aAAa,GAAGV,WAAMW,QAAN,CAAeC,IAAf,CAAqBP,IAArB,EAA6B,CAA7B,CAAtB;;AAEA,YAAKK,aAAL,EAAqB;AACpBZ,UAAAA,QAAQ;AAAE;AAA6BY,UAAAA,aAA/B,CAAR;AACA;AACD,OAN2B,EAMzB,CANyB,CAA5B;AAQA;AACA;;AAEDZ,IAAAA,QAAQ,CAAEO,IAAF,CAAR;AACA,GAtBM,EAsBJ,EAtBI,CAAP;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect, useCallback } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\n\n/**\n * Hook used to focus the first tabbable element on mount.\n *\n * @param {boolean | 'firstElement'} focusOnMount Focus on mount mode.\n * @return {import('react').RefCallback<HTMLElement>} Ref callback.\n *\n * @example\n * ```js\n * import { useFocusOnMount } from '@wordpress/compose';\n *\n * const WithFocusOnMount = () => {\n * const ref = useFocusOnMount()\n * return (\n * <div ref={ ref }>\n * <Button />\n * <Button />\n * </div>\n * );\n * }\n * ```\n */\nexport default function useFocusOnMount( focusOnMount = 'firstElement' ) {\n\tconst focusOnMountRef = useRef( focusOnMount );\n\n\t/**\n\t * Sets focus on a DOM element.\n\t *\n\t * @param {HTMLElement} target The DOM element to set focus to.\n\t * @return {void}\n\t */\n\tconst setFocus = ( target ) => {\n\t\ttarget.focus( {\n\t\t\t// When focusing newly mounted dialogs,\n\t\t\t// the position of the popover is often not right on the first render\n\t\t\t// This prevents the layout shifts when focusing the dialogs.\n\t\t\tpreventScroll: true,\n\t\t} );\n\t};\n\n\t/** @type {import('react').MutableRefObject<ReturnType<setTimeout> | undefined>} */\n\tconst timerId = useRef();\n\n\tuseEffect( () => {\n\t\tfocusOnMountRef.current = focusOnMount;\n\t}, [ focusOnMount ] );\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( timerId.current ) {\n\t\t\t\tclearTimeout( timerId.current );\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\treturn useCallback( ( node ) => {\n\t\tif ( ! node || focusOnMountRef.current === false ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( node.contains( node.ownerDocument?.activeElement ?? null ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( focusOnMountRef.current === 'firstElement' ) {\n\t\t\ttimerId.current = setTimeout( () => {\n\t\t\t\tconst firstTabbable = focus.tabbable.find( node )[ 0 ];\n\n\t\t\t\tif ( firstTabbable ) {\n\t\t\t\t\tsetFocus( /** @type {HTMLElement} */ ( firstTabbable ) );\n\t\t\t\t}\n\t\t\t}, 0 );\n\n\t\t\treturn;\n\t\t}\n\n\t\tsetFocus( node );\n\t}, [] );\n}\n"]}
|
|
@@ -11,28 +11,51 @@ var _element = require("@wordpress/element");
|
|
|
11
11
|
* WordPress dependencies
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
+
/**
|
|
15
|
+
* A new MediaQueryList object for the media query
|
|
16
|
+
*
|
|
17
|
+
* @param {string} [query] Media Query.
|
|
18
|
+
* @return {MediaQueryList|null} A new object for the media query
|
|
19
|
+
*/
|
|
20
|
+
function getMediaQueryList(query) {
|
|
21
|
+
if (query && typeof window !== 'undefined' && typeof window.matchMedia === 'function') {
|
|
22
|
+
return window.matchMedia(query);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
14
27
|
/**
|
|
15
28
|
* Runs a media query and returns its value when it changes.
|
|
16
29
|
*
|
|
17
30
|
* @param {string} [query] Media Query.
|
|
18
31
|
* @return {boolean} return value of the media query.
|
|
19
32
|
*/
|
|
33
|
+
|
|
34
|
+
|
|
20
35
|
function useMediaQuery(query) {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
36
|
+
const source = (0, _element.useMemo)(() => {
|
|
37
|
+
const mediaQueryList = getMediaQueryList(query);
|
|
38
|
+
return {
|
|
39
|
+
/** @type {(onStoreChange: () => void) => () => void} */
|
|
40
|
+
subscribe(onStoreChange) {
|
|
41
|
+
if (!mediaQueryList) {
|
|
42
|
+
return () => {};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
mediaQueryList.addEventListener('change', onStoreChange);
|
|
46
|
+
return () => {
|
|
47
|
+
mediaQueryList.removeEventListener('change', onStoreChange);
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
getValue() {
|
|
52
|
+
var _mediaQueryList$match;
|
|
53
|
+
|
|
54
|
+
return (_mediaQueryList$match = mediaQueryList === null || mediaQueryList === void 0 ? void 0 : mediaQueryList.matches) !== null && _mediaQueryList$match !== void 0 ? _mediaQueryList$match : false;
|
|
55
|
+
}
|
|
56
|
+
|
|
34
57
|
};
|
|
35
58
|
}, [query]);
|
|
36
|
-
return
|
|
59
|
+
return (0, _element.useSyncExternalStore)(source.subscribe, source.getValue, () => false);
|
|
37
60
|
}
|
|
38
61
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/compose/src/hooks/use-media-query/index.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/compose/src/hooks/use-media-query/index.js"],"names":["getMediaQueryList","query","window","matchMedia","useMediaQuery","source","mediaQueryList","subscribe","onStoreChange","addEventListener","removeEventListener","getValue","matches"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,iBAAT,CAA4BC,KAA5B,EAAoC;AACnC,MACCA,KAAK,IACL,OAAOC,MAAP,KAAkB,WADlB,IAEA,OAAOA,MAAM,CAACC,UAAd,KAA6B,UAH9B,EAIE;AACD,WAAOD,MAAM,CAACC,UAAP,CAAmBF,KAAnB,CAAP;AACA;;AAED,SAAO,IAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACe,SAASG,aAAT,CAAwBH,KAAxB,EAAgC;AAC9C,QAAMI,MAAM,GAAG,sBAAS,MAAM;AAC7B,UAAMC,cAAc,GAAGN,iBAAiB,CAAEC,KAAF,CAAxC;AAEA,WAAO;AACN;AACAM,MAAAA,SAAS,CAAEC,aAAF,EAAkB;AAC1B,YAAK,CAAEF,cAAP,EAAwB;AACvB,iBAAO,MAAM,CAAE,CAAf;AACA;;AAEDA,QAAAA,cAAc,CAACG,gBAAf,CAAiC,QAAjC,EAA2CD,aAA3C;AACA,eAAO,MAAM;AACZF,UAAAA,cAAc,CAACI,mBAAf,CACC,QADD,EAECF,aAFD;AAIA,SALD;AAMA,OAdK;;AAeNG,MAAAA,QAAQ,GAAG;AAAA;;AACV,wCAAOL,cAAP,aAAOA,cAAP,uBAAOA,cAAc,CAAEM,OAAvB,yEAAkC,KAAlC;AACA;;AAjBK,KAAP;AAmBA,GAtBc,EAsBZ,CAAEX,KAAF,CAtBY,CAAf;AAwBA,SAAO,mCACNI,MAAM,CAACE,SADD,EAENF,MAAM,CAACM,QAFD,EAGN,MAAM,KAHA,CAAP;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useSyncExternalStore } from '@wordpress/element';\n\n/**\n * A new MediaQueryList object for the media query\n *\n * @param {string} [query] Media Query.\n * @return {MediaQueryList|null} A new object for the media query\n */\nfunction getMediaQueryList( query ) {\n\tif (\n\t\tquery &&\n\t\ttypeof window !== 'undefined' &&\n\t\ttypeof window.matchMedia === 'function'\n\t) {\n\t\treturn window.matchMedia( query );\n\t}\n\n\treturn null;\n}\n\n/**\n * Runs a media query and returns its value when it changes.\n *\n * @param {string} [query] Media Query.\n * @return {boolean} return value of the media query.\n */\nexport default function useMediaQuery( query ) {\n\tconst source = useMemo( () => {\n\t\tconst mediaQueryList = getMediaQueryList( query );\n\n\t\treturn {\n\t\t\t/** @type {(onStoreChange: () => void) => () => void} */\n\t\t\tsubscribe( onStoreChange ) {\n\t\t\t\tif ( ! mediaQueryList ) {\n\t\t\t\t\treturn () => {};\n\t\t\t\t}\n\n\t\t\t\tmediaQueryList.addEventListener( 'change', onStoreChange );\n\t\t\t\treturn () => {\n\t\t\t\t\tmediaQueryList.removeEventListener(\n\t\t\t\t\t\t'change',\n\t\t\t\t\t\tonStoreChange\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t\t\tgetValue() {\n\t\t\t\treturn mediaQueryList?.matches ?? false;\n\t\t\t},\n\t\t};\n\t}, [ query ] );\n\n\treturn useSyncExternalStore(\n\t\tsource.subscribe,\n\t\tsource.getValue,\n\t\t() => false\n\t);\n}\n"]}
|
package/build/index.native.js
CHANGED
|
@@ -25,7 +25,6 @@ var _exportNames = {
|
|
|
25
25
|
usePrevious: true,
|
|
26
26
|
useReducedMotion: true,
|
|
27
27
|
useViewportMatch: true,
|
|
28
|
-
useAsyncList: true,
|
|
29
28
|
usePreferredColorScheme: true,
|
|
30
29
|
usePreferredColorSchemeStyle: true,
|
|
31
30
|
useResizeObserver: true,
|
|
@@ -70,12 +69,6 @@ Object.defineProperty(exports, "pure", {
|
|
|
70
69
|
return _pure.default;
|
|
71
70
|
}
|
|
72
71
|
});
|
|
73
|
-
Object.defineProperty(exports, "useAsyncList", {
|
|
74
|
-
enumerable: true,
|
|
75
|
-
get: function () {
|
|
76
|
-
return _useAsyncList.default;
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
72
|
Object.defineProperty(exports, "useConstrainedTabbing", {
|
|
80
73
|
enumerable: true,
|
|
81
74
|
get: function () {
|
|
@@ -277,8 +270,6 @@ var _useReducedMotion = _interopRequireDefault(require("./hooks/use-reduced-moti
|
|
|
277
270
|
|
|
278
271
|
var _useViewportMatch = _interopRequireDefault(require("./hooks/use-viewport-match"));
|
|
279
272
|
|
|
280
|
-
var _useAsyncList = _interopRequireDefault(require("./hooks/use-async-list"));
|
|
281
|
-
|
|
282
273
|
var _usePreferredColorScheme = _interopRequireDefault(require("./hooks/use-preferred-color-scheme"));
|
|
283
274
|
|
|
284
275
|
var _usePreferredColorSchemeStyle = _interopRequireDefault(require("./hooks/use-preferred-color-scheme-style"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/compose/src/index.native.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["@wordpress/compose/src/index.native.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAEA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","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\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';\nexport { default as withPreferredColorScheme } from './higher-order/with-preferred-color-scheme';\n\n// Hooks.\nexport { default as useConstrainedTabbing } from './hooks/use-constrained-tabbing';\nexport { default as __experimentalUseDragging } from './hooks/use-dragging';\nexport { default as __experimentalUseFocusOutside } from './hooks/use-focus-outside';\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 useViewportMatch } from './hooks/use-viewport-match';\nexport { default as usePreferredColorScheme } from './hooks/use-preferred-color-scheme';\nexport { default as usePreferredColorSchemeStyle } from './hooks/use-preferred-color-scheme-style';\nexport { default as useResizeObserver } from './hooks/use-resize-observer';\nexport { default as useDebounce } from './hooks/use-debounce';\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';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/compose/src/higher-order/if-condition/index.tsx"],"names":["createHigherOrderComponent","ifCondition","predicate","WrappedComponent","props"],"mappings":";;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,0BAAT,QAA2C,2CAA3C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,
|
|
1
|
+
{"version":3,"sources":["@wordpress/compose/src/higher-order/if-condition/index.tsx"],"names":["createHigherOrderComponent","ifCondition","predicate","WrappedComponent","props"],"mappings":";;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,0BAAT,QAA2C,2CAA3C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,CACCC,SADD,EAEE;AACD,SAAOF,0BAA0B,CAC9BG,gBAAF,IAAkDC,KAAF,IAAoB;AACnE,QAAK,CAAEF,SAAS,CAAEE,KAAF,CAAhB,EAA4B;AAC3B,aAAO,IAAP;AACA;;AAED,WAAO,cAAC,gBAAD,EAAuBA,KAAvB,CAAP;AACA,GAP+B,EAQhC,aARgC,CAAjC;AAUA;;AAED,eAAeH,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ComponentType } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * Higher-order component creator, creating a new component which renders if\n * the given condition is satisfied or with the given optional prop name.\n *\n * @example\n * ```ts\n * type Props = { foo: string };\n * const Component = ( props: Props ) => <div>{ props.foo }</div>;\n * const ConditionalComponent = ifCondition( ( props: Props ) => props.foo.length !== 0 )( Component );\n * <ConditionalComponent foo=\"\" />; // => null\n * <ConditionalComponent foo=\"bar\" />; // => <div>bar</div>;\n * ```\n *\n * @param predicate Function to test condition.\n *\n * @return Higher-order component.\n */\nfunction ifCondition< Props extends {} >(\n\tpredicate: ( props: Props ) => boolean\n) {\n\treturn createHigherOrderComponent(\n\t\t( WrappedComponent: ComponentType< Props > ) => ( props: Props ) => {\n\t\t\tif ( ! predicate( props ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn <WrappedComponent { ...props } />;\n\t\t},\n\t\t'ifCondition'\n\t);\n}\n\nexport default ifCondition;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/compose/src/higher-order/pure/index.tsx"],"names":["isShallowEqual","Component","createHigherOrderComponent","pure","WrappedComponent","prototype","shouldComponentUpdate","nextProps","nextState","props","state","render"],"mappings":";;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,6BAA3B;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,SAASC,0BAAT,QAA2C,2CAA3C;AAEA;AACA;AACA;AACA;;AACA,MAAMC,IAAI,GAAGD,0BAA0B,CAAE,UACxCE,gBADwC,EAEf;AACzB,MAAKA,gBAAgB,CAACC,SAAjB,YAAsCJ,SAA3C,EAAuD;AACtD,WAAO,cAAgBG,gBAAhB,CAA8D;AACpEE,MAAAA,qBAAqB,CAAEC,SAAF,EAAoBC,SAApB,EAAqC;AACzD,eACC,CAAER,cAAc,CAAEO,SAAF,EAAa,KAAKE,KAAlB,CAAhB,IACA,CAAET,cAAc,CAAEQ,SAAF,EAAa,KAAKE,KAAlB,CAFjB;AAIA;;AANmE,KAArE;AAQA;;AAED,SAAO,cAAcT,SAAd,CAAiC;AACvCK,IAAAA,qBAAqB,CAAEC,SAAF,EAAqB;AACzC,aAAO,CAAEP,cAAc,CAAEO,SAAF,EAAa,KAAKE,KAAlB,CAAvB;AACA;;AAEDE,IAAAA,MAAM,GAAG;AACR,aAAO,cAAC,gBAAD,EAAuB,KAAKF,KAA5B,CAAP;AACA;;AAPsC,GAAxC;AASA,CAvBsC,EAwBvC,MAxBuC,CAAvC;AA0BA,eAAeN,IAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ComponentType, ComponentClass } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * Given a component returns the enhanced component augmented with a component\n * only re-rendering when its props/state change\n */\nconst pure = createHigherOrderComponent( function < Props >(\n\tWrappedComponent: ComponentType< Props >\n): ComponentType< Props > {\n\tif ( WrappedComponent.prototype instanceof Component ) {\n\t\treturn class extends ( WrappedComponent as ComponentClass< Props > ) {\n\t\t\tshouldComponentUpdate( nextProps: Props, nextState: any ) {\n\t\t\t\treturn (\n\t\t\t\t\t! isShallowEqual( nextProps, this.props ) ||\n\t\t\t\t\t! isShallowEqual( nextState, this.state )\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t}\n\n\treturn class extends Component< Props > {\n\t\tshouldComponentUpdate( nextProps: Props ) {\n\t\t\treturn ! isShallowEqual( nextProps, this.props );\n\t\t}\n\n\t\trender() {\n\t\t\treturn <WrappedComponent { ...this.props } />;\n\t\t}\n\t};\n},\n'pure' );\n\nexport default pure;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/compose/src/higher-order/pure/index.tsx"],"names":["isShallowEqual","Component","createHigherOrderComponent","pure","WrappedComponent","prototype","shouldComponentUpdate","nextProps","nextState","props","state","render"],"mappings":";;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,6BAA3B;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,SAASC,0BAAT,QAA2C,2CAA3C;AAEA;AACA;AACA;AACA;;AACA,MAAMC,IAAI,GAAGD,0BAA0B,CAAE,UACxCE,gBADwC,EAEf;AACzB,MAAKA,gBAAgB,CAACC,SAAjB,YAAsCJ,SAA3C,EAAuD;AACtD,WAAO,cAAgBG,gBAAhB,CAA8D;AACpEE,MAAAA,qBAAqB,CAAEC,SAAF,EAAoBC,SAApB,EAAqC;AACzD,eACC,CAAER,cAAc,CAAEO,SAAF,EAAa,KAAKE,KAAlB,CAAhB,IACA,CAAET,cAAc,CAAEQ,SAAF,EAAa,KAAKE,KAAlB,CAFjB;AAIA;;AANmE,KAArE;AAQA;;AAED,SAAO,cAAcT,SAAd,CAAiC;AACvCK,IAAAA,qBAAqB,CAAEC,SAAF,EAAqB;AACzC,aAAO,CAAEP,cAAc,CAAEO,SAAF,EAAa,KAAKE,KAAlB,CAAvB;AACA;;AAEDE,IAAAA,MAAM,GAAG;AACR,aAAO,cAAC,gBAAD,EAAuB,KAAKF,KAA5B,CAAP;AACA;;AAPsC,GAAxC;AASA,CAvBsC,EAwBvC,MAxBuC,CAAvC;AA0BA,eAAeN,IAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ComponentType, ComponentClass } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * Given a component returns the enhanced component augmented with a component\n * only re-rendering when its props/state change\n */\nconst pure = createHigherOrderComponent( function < Props extends {} >(\n\tWrappedComponent: ComponentType< Props >\n): ComponentType< Props > {\n\tif ( WrappedComponent.prototype instanceof Component ) {\n\t\treturn class extends ( WrappedComponent as ComponentClass< Props > ) {\n\t\t\tshouldComponentUpdate( nextProps: Props, nextState: any ) {\n\t\t\t\treturn (\n\t\t\t\t\t! isShallowEqual( nextProps, this.props ) ||\n\t\t\t\t\t! isShallowEqual( nextState, this.state )\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t}\n\n\treturn class extends Component< Props > {\n\t\tshouldComponentUpdate( nextProps: Props ) {\n\t\t\treturn ! isShallowEqual( nextProps, this.props );\n\t\t}\n\n\t\trender() {\n\t\t\treturn <WrappedComponent { ...this.props } />;\n\t\t}\n\t};\n},\n'pure' );\n\nexport default pure;\n"]}
|
|
@@ -28,9 +28,35 @@ import { focus } from '@wordpress/dom';
|
|
|
28
28
|
export default function useFocusOnMount() {
|
|
29
29
|
let focusOnMount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'firstElement';
|
|
30
30
|
const focusOnMountRef = useRef(focusOnMount);
|
|
31
|
+
/**
|
|
32
|
+
* Sets focus on a DOM element.
|
|
33
|
+
*
|
|
34
|
+
* @param {HTMLElement} target The DOM element to set focus to.
|
|
35
|
+
* @return {void}
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
const setFocus = target => {
|
|
39
|
+
target.focus({
|
|
40
|
+
// When focusing newly mounted dialogs,
|
|
41
|
+
// the position of the popover is often not right on the first render
|
|
42
|
+
// This prevents the layout shifts when focusing the dialogs.
|
|
43
|
+
preventScroll: true
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
/** @type {import('react').MutableRefObject<ReturnType<setTimeout> | undefined>} */
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
const timerId = useRef();
|
|
31
50
|
useEffect(() => {
|
|
32
51
|
focusOnMountRef.current = focusOnMount;
|
|
33
52
|
}, [focusOnMount]);
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
return () => {
|
|
55
|
+
if (timerId.current) {
|
|
56
|
+
clearTimeout(timerId.current);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}, []);
|
|
34
60
|
return useCallback(node => {
|
|
35
61
|
var _node$ownerDocument$a, _node$ownerDocument;
|
|
36
62
|
|
|
@@ -42,24 +68,20 @@ export default function useFocusOnMount() {
|
|
|
42
68
|
return;
|
|
43
69
|
}
|
|
44
70
|
|
|
45
|
-
let target = node;
|
|
46
|
-
|
|
47
71
|
if (focusOnMountRef.current === 'firstElement') {
|
|
48
|
-
|
|
72
|
+
timerId.current = setTimeout(() => {
|
|
73
|
+
const firstTabbable = focus.tabbable.find(node)[0];
|
|
49
74
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
75
|
+
if (firstTabbable) {
|
|
76
|
+
setFocus(
|
|
77
|
+
/** @type {HTMLElement} */
|
|
78
|
+
firstTabbable);
|
|
79
|
+
}
|
|
80
|
+
}, 0);
|
|
81
|
+
return;
|
|
55
82
|
}
|
|
56
83
|
|
|
57
|
-
|
|
58
|
-
// When focusing newly mounted dialogs,
|
|
59
|
-
// the position of the popover is often not right on the first render
|
|
60
|
-
// This prevents the layout shifts when focusing the dialogs.
|
|
61
|
-
preventScroll: true
|
|
62
|
-
});
|
|
84
|
+
setFocus(node);
|
|
63
85
|
}, []);
|
|
64
86
|
}
|
|
65
87
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/compose/src/hooks/use-focus-on-mount/index.js"],"names":["useRef","useEffect","useCallback","focus","useFocusOnMount","focusOnMount","focusOnMountRef","current","node","contains","ownerDocument","activeElement","
|
|
1
|
+
{"version":3,"sources":["@wordpress/compose/src/hooks/use-focus-on-mount/index.js"],"names":["useRef","useEffect","useCallback","focus","useFocusOnMount","focusOnMount","focusOnMountRef","setFocus","target","preventScroll","timerId","current","clearTimeout","node","contains","ownerDocument","activeElement","setTimeout","firstTabbable","tabbable","find"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,SAAjB,EAA4BC,WAA5B,QAA+C,oBAA/C;AACA,SAASC,KAAT,QAAsB,gBAAtB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,eAAT,GAA0D;AAAA,MAAhCC,YAAgC,uEAAjB,cAAiB;AACxE,QAAMC,eAAe,GAAGN,MAAM,CAAEK,YAAF,CAA9B;AAEA;AACD;AACA;AACA;AACA;AACA;;AACC,QAAME,QAAQ,GAAKC,MAAF,IAAc;AAC9BA,IAAAA,MAAM,CAACL,KAAP,CAAc;AACb;AACA;AACA;AACAM,MAAAA,aAAa,EAAE;AAJF,KAAd;AAMA,GAPD;AASA;;;AACA,QAAMC,OAAO,GAAGV,MAAM,EAAtB;AAEAC,EAAAA,SAAS,CAAE,MAAM;AAChBK,IAAAA,eAAe,CAACK,OAAhB,GAA0BN,YAA1B;AACA,GAFQ,EAEN,CAAEA,YAAF,CAFM,CAAT;AAIAJ,EAAAA,SAAS,CAAE,MAAM;AAChB,WAAO,MAAM;AACZ,UAAKS,OAAO,CAACC,OAAb,EAAuB;AACtBC,QAAAA,YAAY,CAAEF,OAAO,CAACC,OAAV,CAAZ;AACA;AACD,KAJD;AAKA,GANQ,EAMN,EANM,CAAT;AAQA,SAAOT,WAAW,CAAIW,IAAF,IAAY;AAAA;;AAC/B,QAAK,CAAEA,IAAF,IAAUP,eAAe,CAACK,OAAhB,KAA4B,KAA3C,EAAmD;AAClD;AACA;;AAED,QAAKE,IAAI,CAACC,QAAL,iDAAeD,IAAI,CAACE,aAApB,wDAAe,oBAAoBC,aAAnC,yEAAoD,IAApD,CAAL,EAAkE;AACjE;AACA;;AAED,QAAKV,eAAe,CAACK,OAAhB,KAA4B,cAAjC,EAAkD;AACjDD,MAAAA,OAAO,CAACC,OAAR,GAAkBM,UAAU,CAAE,MAAM;AACnC,cAAMC,aAAa,GAAGf,KAAK,CAACgB,QAAN,CAAeC,IAAf,CAAqBP,IAArB,EAA6B,CAA7B,CAAtB;;AAEA,YAAKK,aAAL,EAAqB;AACpBX,UAAAA,QAAQ;AAAE;AAA6BW,UAAAA,aAA/B,CAAR;AACA;AACD,OAN2B,EAMzB,CANyB,CAA5B;AAQA;AACA;;AAEDX,IAAAA,QAAQ,CAAEM,IAAF,CAAR;AACA,GAtBiB,EAsBf,EAtBe,CAAlB;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect, useCallback } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\n\n/**\n * Hook used to focus the first tabbable element on mount.\n *\n * @param {boolean | 'firstElement'} focusOnMount Focus on mount mode.\n * @return {import('react').RefCallback<HTMLElement>} Ref callback.\n *\n * @example\n * ```js\n * import { useFocusOnMount } from '@wordpress/compose';\n *\n * const WithFocusOnMount = () => {\n * const ref = useFocusOnMount()\n * return (\n * <div ref={ ref }>\n * <Button />\n * <Button />\n * </div>\n * );\n * }\n * ```\n */\nexport default function useFocusOnMount( focusOnMount = 'firstElement' ) {\n\tconst focusOnMountRef = useRef( focusOnMount );\n\n\t/**\n\t * Sets focus on a DOM element.\n\t *\n\t * @param {HTMLElement} target The DOM element to set focus to.\n\t * @return {void}\n\t */\n\tconst setFocus = ( target ) => {\n\t\ttarget.focus( {\n\t\t\t// When focusing newly mounted dialogs,\n\t\t\t// the position of the popover is often not right on the first render\n\t\t\t// This prevents the layout shifts when focusing the dialogs.\n\t\t\tpreventScroll: true,\n\t\t} );\n\t};\n\n\t/** @type {import('react').MutableRefObject<ReturnType<setTimeout> | undefined>} */\n\tconst timerId = useRef();\n\n\tuseEffect( () => {\n\t\tfocusOnMountRef.current = focusOnMount;\n\t}, [ focusOnMount ] );\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( timerId.current ) {\n\t\t\t\tclearTimeout( timerId.current );\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\treturn useCallback( ( node ) => {\n\t\tif ( ! node || focusOnMountRef.current === false ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( node.contains( node.ownerDocument?.activeElement ?? null ) ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( focusOnMountRef.current === 'firstElement' ) {\n\t\t\ttimerId.current = setTimeout( () => {\n\t\t\t\tconst firstTabbable = focus.tabbable.find( node )[ 0 ];\n\n\t\t\t\tif ( firstTabbable ) {\n\t\t\t\t\tsetFocus( /** @type {HTMLElement} */ ( firstTabbable ) );\n\t\t\t\t}\n\t\t\t}, 0 );\n\n\t\t\treturn;\n\t\t}\n\n\t\tsetFocus( node );\n\t}, [] );\n}\n"]}
|
|
@@ -1,7 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { useMemo, useSyncExternalStore } from '@wordpress/element';
|
|
5
|
+
/**
|
|
6
|
+
* A new MediaQueryList object for the media query
|
|
7
|
+
*
|
|
8
|
+
* @param {string} [query] Media Query.
|
|
9
|
+
* @return {MediaQueryList|null} A new object for the media query
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
function getMediaQueryList(query) {
|
|
13
|
+
if (query && typeof window !== 'undefined' && typeof window.matchMedia === 'function') {
|
|
14
|
+
return window.matchMedia(query);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
5
19
|
/**
|
|
6
20
|
* Runs a media query and returns its value when it changes.
|
|
7
21
|
*
|
|
@@ -9,22 +23,31 @@ import { useState, useEffect } from '@wordpress/element';
|
|
|
9
23
|
* @return {boolean} return value of the media query.
|
|
10
24
|
*/
|
|
11
25
|
|
|
26
|
+
|
|
12
27
|
export default function useMediaQuery(query) {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
const source = useMemo(() => {
|
|
29
|
+
const mediaQueryList = getMediaQueryList(query);
|
|
30
|
+
return {
|
|
31
|
+
/** @type {(onStoreChange: () => void) => () => void} */
|
|
32
|
+
subscribe(onStoreChange) {
|
|
33
|
+
if (!mediaQueryList) {
|
|
34
|
+
return () => {};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
mediaQueryList.addEventListener('change', onStoreChange);
|
|
38
|
+
return () => {
|
|
39
|
+
mediaQueryList.removeEventListener('change', onStoreChange);
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
getValue() {
|
|
44
|
+
var _mediaQueryList$match;
|
|
45
|
+
|
|
46
|
+
return (_mediaQueryList$match = mediaQueryList === null || mediaQueryList === void 0 ? void 0 : mediaQueryList.matches) !== null && _mediaQueryList$match !== void 0 ? _mediaQueryList$match : false;
|
|
47
|
+
}
|
|
48
|
+
|
|
26
49
|
};
|
|
27
50
|
}, [query]);
|
|
28
|
-
return
|
|
51
|
+
return useSyncExternalStore(source.subscribe, source.getValue, () => false);
|
|
29
52
|
}
|
|
30
53
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/compose/src/hooks/use-media-query/index.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/compose/src/hooks/use-media-query/index.js"],"names":["useMemo","useSyncExternalStore","getMediaQueryList","query","window","matchMedia","useMediaQuery","source","mediaQueryList","subscribe","onStoreChange","addEventListener","removeEventListener","getValue","matches"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,EAAkBC,oBAAlB,QAA8C,oBAA9C;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,iBAAT,CAA4BC,KAA5B,EAAoC;AACnC,MACCA,KAAK,IACL,OAAOC,MAAP,KAAkB,WADlB,IAEA,OAAOA,MAAM,CAACC,UAAd,KAA6B,UAH9B,EAIE;AACD,WAAOD,MAAM,CAACC,UAAP,CAAmBF,KAAnB,CAAP;AACA;;AAED,SAAO,IAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAe,SAASG,aAAT,CAAwBH,KAAxB,EAAgC;AAC9C,QAAMI,MAAM,GAAGP,OAAO,CAAE,MAAM;AAC7B,UAAMQ,cAAc,GAAGN,iBAAiB,CAAEC,KAAF,CAAxC;AAEA,WAAO;AACN;AACAM,MAAAA,SAAS,CAAEC,aAAF,EAAkB;AAC1B,YAAK,CAAEF,cAAP,EAAwB;AACvB,iBAAO,MAAM,CAAE,CAAf;AACA;;AAEDA,QAAAA,cAAc,CAACG,gBAAf,CAAiC,QAAjC,EAA2CD,aAA3C;AACA,eAAO,MAAM;AACZF,UAAAA,cAAc,CAACI,mBAAf,CACC,QADD,EAECF,aAFD;AAIA,SALD;AAMA,OAdK;;AAeNG,MAAAA,QAAQ,GAAG;AAAA;;AACV,wCAAOL,cAAP,aAAOA,cAAP,uBAAOA,cAAc,CAAEM,OAAvB,yEAAkC,KAAlC;AACA;;AAjBK,KAAP;AAmBA,GAtBqB,EAsBnB,CAAEX,KAAF,CAtBmB,CAAtB;AAwBA,SAAOF,oBAAoB,CAC1BM,MAAM,CAACE,SADmB,EAE1BF,MAAM,CAACM,QAFmB,EAG1B,MAAM,KAHoB,CAA3B;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo, useSyncExternalStore } from '@wordpress/element';\n\n/**\n * A new MediaQueryList object for the media query\n *\n * @param {string} [query] Media Query.\n * @return {MediaQueryList|null} A new object for the media query\n */\nfunction getMediaQueryList( query ) {\n\tif (\n\t\tquery &&\n\t\ttypeof window !== 'undefined' &&\n\t\ttypeof window.matchMedia === 'function'\n\t) {\n\t\treturn window.matchMedia( query );\n\t}\n\n\treturn null;\n}\n\n/**\n * Runs a media query and returns its value when it changes.\n *\n * @param {string} [query] Media Query.\n * @return {boolean} return value of the media query.\n */\nexport default function useMediaQuery( query ) {\n\tconst source = useMemo( () => {\n\t\tconst mediaQueryList = getMediaQueryList( query );\n\n\t\treturn {\n\t\t\t/** @type {(onStoreChange: () => void) => () => void} */\n\t\t\tsubscribe( onStoreChange ) {\n\t\t\t\tif ( ! mediaQueryList ) {\n\t\t\t\t\treturn () => {};\n\t\t\t\t}\n\n\t\t\t\tmediaQueryList.addEventListener( 'change', onStoreChange );\n\t\t\t\treturn () => {\n\t\t\t\t\tmediaQueryList.removeEventListener(\n\t\t\t\t\t\t'change',\n\t\t\t\t\t\tonStoreChange\n\t\t\t\t\t);\n\t\t\t\t};\n\t\t\t},\n\t\t\tgetValue() {\n\t\t\t\treturn mediaQueryList?.matches ?? false;\n\t\t\t},\n\t\t};\n\t}, [ query ] );\n\n\treturn useSyncExternalStore(\n\t\tsource.subscribe,\n\t\tsource.getValue,\n\t\t() => false\n\t);\n}\n"]}
|
|
@@ -26,7 +26,6 @@ export { default as useMediaQuery } from './hooks/use-media-query';
|
|
|
26
26
|
export { default as usePrevious } from './hooks/use-previous';
|
|
27
27
|
export { default as useReducedMotion } from './hooks/use-reduced-motion';
|
|
28
28
|
export { default as useViewportMatch } from './hooks/use-viewport-match';
|
|
29
|
-
export { default as useAsyncList } from './hooks/use-async-list';
|
|
30
29
|
export { default as usePreferredColorScheme } from './hooks/use-preferred-color-scheme';
|
|
31
30
|
export { default as usePreferredColorSchemeStyle } from './hooks/use-preferred-color-scheme-style';
|
|
32
31
|
export { default as useResizeObserver } from './hooks/use-resize-observer';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/compose/src/index.native.js"],"names":["default","compose","pipe","ifCondition","pure","withGlobalEvents","withInstanceId","withSafeTimeout","withState","withPreferredColorScheme","useConstrainedTabbing","__experimentalUseDragging","__experimentalUseFocusOutside","useInstanceId","useIsomorphicLayoutEffect","useKeyboardShortcut","useMediaQuery","usePrevious","useReducedMotion","useViewportMatch","
|
|
1
|
+
{"version":3,"sources":["@wordpress/compose/src/index.native.js"],"names":["default","compose","pipe","ifCondition","pure","withGlobalEvents","withInstanceId","withSafeTimeout","withState","withPreferredColorScheme","useConstrainedTabbing","__experimentalUseDragging","__experimentalUseFocusOutside","useInstanceId","useIsomorphicLayoutEffect","useKeyboardShortcut","useMediaQuery","usePrevious","useReducedMotion","useViewportMatch","usePreferredColorScheme","usePreferredColorSchemeStyle","useResizeObserver","useDebounce","useThrottle","useMergeRefs","useRefEffect"],"mappings":"AAAA;AACA,cAAc,uCAAd,C,CACA;;AACA,cAAc,kBAAd,C,CACA;;AACA,cAAc,kBAAd,C,CAEA;;AACA,SAASA,OAAO,IAAIC,OAApB,QAAmC,wBAAnC;AACA,SAASD,OAAO,IAAIE,IAApB,QAAgC,qBAAhC,C,CAEA;;AACA,SAASF,OAAO,IAAIG,WAApB,QAAuC,6BAAvC;AACA,SAASH,OAAO,IAAII,IAApB,QAAgC,qBAAhC;AACA,SAASJ,OAAO,IAAIK,gBAApB,QAA4C,mCAA5C;AACA,SAASL,OAAO,IAAIM,cAApB,QAA0C,iCAA1C;AACA,SAASN,OAAO,IAAIO,eAApB,QAA2C,kCAA3C;AACA,SAASP,OAAO,IAAIQ,SAApB,QAAqC,2BAArC;AACA,SAASR,OAAO,IAAIS,wBAApB,QAAoD,4CAApD,C,CAEA;;AACA,SAAST,OAAO,IAAIU,qBAApB,QAAiD,iCAAjD;AACA,SAASV,OAAO,IAAIW,yBAApB,QAAqD,sBAArD;AACA,SAASX,OAAO,IAAIY,6BAApB,QAAyD,2BAAzD;AACA,SAASZ,OAAO,IAAIa,aAApB,QAAyC,yBAAzC;AACA,SAASb,OAAO,IAAIc,yBAApB,QAAqD,sCAArD;AACA,SAASd,OAAO,IAAIe,mBAApB,QAA+C,+BAA/C;AACA,SAASf,OAAO,IAAIgB,aAApB,QAAyC,yBAAzC;AACA,SAAShB,OAAO,IAAIiB,WAApB,QAAuC,sBAAvC;AACA,SAASjB,OAAO,IAAIkB,gBAApB,QAA4C,4BAA5C;AACA,SAASlB,OAAO,IAAImB,gBAApB,QAA4C,4BAA5C;AACA,SAASnB,OAAO,IAAIoB,uBAApB,QAAmD,oCAAnD;AACA,SAASpB,OAAO,IAAIqB,4BAApB,QAAwD,0CAAxD;AACA,SAASrB,OAAO,IAAIsB,iBAApB,QAA6C,6BAA7C;AACA,SAAStB,OAAO,IAAIuB,WAApB,QAAuC,sBAAvC;AACA,SAASvB,OAAO,IAAIwB,WAApB,QAAuC,sBAAvC;AACA,SAASxB,OAAO,IAAIyB,YAApB,QAAwC,wBAAxC;AACA,SAASzB,OAAO,IAAI0B,YAApB,QAAwC,wBAAxC","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\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';\nexport { default as withPreferredColorScheme } from './higher-order/with-preferred-color-scheme';\n\n// Hooks.\nexport { default as useConstrainedTabbing } from './hooks/use-constrained-tabbing';\nexport { default as __experimentalUseDragging } from './hooks/use-dragging';\nexport { default as __experimentalUseFocusOutside } from './hooks/use-focus-outside';\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 useViewportMatch } from './hooks/use-viewport-match';\nexport { default as usePreferredColorScheme } from './hooks/use-preferred-color-scheme';\nexport { default as usePreferredColorSchemeStyle } from './hooks/use-preferred-color-scheme-style';\nexport { default as useResizeObserver } from './hooks/use-resize-observer';\nexport { default as useDebounce } from './hooks/use-debounce';\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';\n"]}
|
|
@@ -19,6 +19,6 @@ import type { ComponentType } from 'react';
|
|
|
19
19
|
*
|
|
20
20
|
* @return Higher-order component.
|
|
21
21
|
*/
|
|
22
|
-
declare function ifCondition<Props>(predicate: (props: Props) => boolean): (Inner: ComponentType<Props>) => (props: Props) => JSX.Element | null;
|
|
22
|
+
declare function ifCondition<Props extends {}>(predicate: (props: Props) => boolean): (Inner: ComponentType<Props>) => (props: Props) => JSX.Element | null;
|
|
23
23
|
export default ifCondition;
|
|
24
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/higher-order/if-condition/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAO3C;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,WAAW,CAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/higher-order/if-condition/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAO3C;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,WAAW,CAAE,KAAK,SAAS,EAAE,EACrC,SAAS,EAAE,CAAE,KAAK,EAAE,KAAK,KAAM,OAAO,4CAGoB,KAAK,wBAS/D;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -6,6 +6,6 @@ import type { ComponentType } from 'react';
|
|
|
6
6
|
* Given a component returns the enhanced component augmented with a component
|
|
7
7
|
* only re-rendering when its props/state change
|
|
8
8
|
*/
|
|
9
|
-
declare const pure: <Props>(Inner: ComponentType<Props>) => ComponentType<Props>;
|
|
9
|
+
declare const pure: <Props extends {}>(Inner: ComponentType<Props>) => ComponentType<Props>;
|
|
10
10
|
export default pure;
|
|
11
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/higher-order/pure/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;AAa3D;;;GAGG;AACH,QAAA,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/higher-order/pure/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;AAa3D;;;GAGG;AACH,QAAA,MAAM,IAAI,yEAwBF,CAAC;AAET,eAAe,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/higher-order/with-instance-id/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAEN,iBAAiB,EACjB,oBAAoB,EACpB,MAAM,2CAA2C,CAAC;AAGnD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/higher-order/with-instance-id/index.tsx"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAEN,iBAAiB,EACjB,oBAAoB,EACpB,MAAM,2CAA2C,CAAC;AAGnD,KAAK,eAAe,GAAG;IAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAEvD;;;GAGG;AACH,QAAA,MAAM,cAAc,iIAWnB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-async-list/index.ts"],"names":[],"mappings":"AAMA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-async-list/index.ts"],"names":[],"mappings":"AAMA,KAAK,eAAe,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAwBF;;;;;;;;GAQG;AACH,iBAAS,YAAY,CAAE,CAAC,EACvB,IAAI,EAAE,CAAC,EAAE,EACT,MAAM,GAAE,eAA6B,GACnC,CAAC,EAAE,CA8BL;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { RefCallback, SyntheticEvent } from 'react';
|
|
5
5
|
import useFocusOnMount from '../use-focus-on-mount';
|
|
6
6
|
import useFocusOutside from '../use-focus-outside';
|
|
7
|
-
|
|
7
|
+
type DialogOptions = {
|
|
8
8
|
focusOnMount?: Parameters<typeof useFocusOnMount>[0];
|
|
9
9
|
onClose?: () => void;
|
|
10
10
|
/**
|
|
@@ -14,7 +14,7 @@ declare type DialogOptions = {
|
|
|
14
14
|
*/
|
|
15
15
|
__unstableOnClose?: (type: string | undefined, event: SyntheticEvent) => void;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
type useDialogReturn = [
|
|
18
18
|
RefCallback<HTMLElement>,
|
|
19
19
|
ReturnType<typeof useFocusOutside> & Pick<HTMLElement, 'tabIndex'>
|
|
20
20
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-dialog/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAYzD,OAAO,eAAe,MAAM,uBAAuB,CAAC;AAEpD,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAGnD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-dialog/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAYzD,OAAO,eAAe,MAAM,uBAAuB,CAAC;AAEpD,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAGnD,KAAK,aAAa,GAAG;IACpB,YAAY,CAAC,EAAE,UAAU,CAAE,OAAO,eAAe,CAAE,CAAE,CAAC,CAAE,CAAC;IACzD,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,CACnB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,KAAK,EAAE,cAAc,KACjB,IAAI,CAAC;CACV,CAAC;AAEF,KAAK,eAAe,GAAG;IACtB,WAAW,CAAE,WAAW,CAAE;IAC1B,UAAU,CAAE,OAAO,eAAe,CAAE,GAAG,IAAI,CAAE,WAAW,EAAE,UAAU,CAAE;CACtE,CAAC;AAEF;;;;;;;;GAQG;AACH,iBAAS,SAAS,CAAE,OAAO,EAAE,aAAa,GAAI,eAAe,CA+C5D;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
export default function useDragging({ onDragStart, onDragMove, onDragEnd }: {
|
|
8
8
|
onDragStart: (e: import('react').MouseEvent) => void;
|
|
9
9
|
onDragMove: (e: MouseEvent) => void;
|
|
10
|
-
onDragEnd: (e?: MouseEvent
|
|
10
|
+
onDragEnd: (e?: MouseEvent) => void;
|
|
11
11
|
}): {
|
|
12
12
|
startDrag: (e: import('react').MouseEvent) => void;
|
|
13
|
-
endDrag: (e?: MouseEvent
|
|
13
|
+
endDrag: (e?: MouseEvent) => void;
|
|
14
14
|
isDragging: boolean;
|
|
15
15
|
};
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|