@wordpress/compose 7.32.0 → 7.32.1-next.b8c8708f3.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/build/higher-order/compose.js +25 -20
- package/build/higher-order/compose.js.map +7 -1
- package/build/higher-order/if-condition/index.js +35 -41
- package/build/higher-order/if-condition/index.js.map +7 -1
- package/build/higher-order/pipe.js +32 -66
- package/build/higher-order/pipe.js.map +7 -1
- package/build/higher-order/pure/index.js +44 -37
- package/build/higher-order/pure/index.js.map +7 -1
- package/build/higher-order/with-global-events/index.js +64 -73
- package/build/higher-order/with-global-events/index.js.map +7 -1
- package/build/higher-order/with-global-events/listener.js +34 -21
- package/build/higher-order/with-global-events/listener.js.map +7 -1
- package/build/higher-order/with-instance-id/index.js +45 -27
- package/build/higher-order/with-instance-id/index.js.map +7 -1
- package/build/higher-order/with-safe-timeout/index.js +70 -66
- package/build/higher-order/with-safe-timeout/index.js.map +7 -1
- package/build/higher-order/with-state/index.js +52 -40
- package/build/higher-order/with-state/index.js.map +7 -1
- package/build/hooks/use-async-list/index.js +38 -42
- package/build/hooks/use-async-list/index.js.map +7 -1
- package/build/hooks/use-constrained-tabbing/index.js +54 -75
- package/build/hooks/use-constrained-tabbing/index.js.map +7 -1
- package/build/hooks/use-copy-on-click/index.js +46 -56
- package/build/hooks/use-copy-on-click/index.js.map +7 -1
- package/build/hooks/use-copy-to-clipboard/index.js +41 -51
- package/build/hooks/use-copy-to-clipboard/index.js.map +7 -1
- package/build/hooks/use-debounce/index.js +30 -37
- package/build/hooks/use-debounce/index.js.map +7 -1
- package/build/hooks/use-debounced-input/index.js +39 -27
- package/build/hooks/use-debounced-input/index.js.map +7 -1
- package/build/hooks/use-dialog/index.js +63 -55
- package/build/hooks/use-dialog/index.js.map +7 -1
- package/build/hooks/use-disabled/index.js +74 -82
- package/build/hooks/use-disabled/index.js.map +7 -1
- package/build/hooks/use-dragging/index.js +51 -48
- package/build/hooks/use-dragging/index.js.map +7 -1
- package/build/hooks/use-drop-zone/index.js +133 -168
- package/build/hooks/use-drop-zone/index.js.map +7 -1
- package/build/hooks/use-event/index.js +33 -45
- package/build/hooks/use-event/index.js.map +7 -1
- package/build/hooks/use-fixed-window-list/index.js +109 -97
- package/build/hooks/use-fixed-window-list/index.js.map +7 -1
- package/build/hooks/use-focus-on-mount/index.js +44 -57
- package/build/hooks/use-focus-on-mount/index.js.map +7 -1
- package/build/hooks/use-focus-outside/index.js +44 -102
- package/build/hooks/use-focus-outside/index.js.map +7 -1
- package/build/hooks/use-focus-return/index.js +35 -56
- package/build/hooks/use-focus-return/index.js.map +7 -1
- package/build/hooks/use-focusable-iframe/index.js +38 -35
- package/build/hooks/use-focusable-iframe/index.js.map +7 -1
- package/build/hooks/use-instance-id/index.js +26 -42
- package/build/hooks/use-instance-id/index.js.map +7 -1
- package/build/hooks/use-isomorphic-layout-effect/index.js +25 -17
- package/build/hooks/use-isomorphic-layout-effect/index.js.map +7 -1
- package/build/hooks/use-keyboard-shortcut/index.js +72 -69
- package/build/hooks/use-keyboard-shortcut/index.js.map +7 -1
- package/build/hooks/use-media-query/index.js +39 -35
- package/build/hooks/use-media-query/index.js.map +7 -1
- package/build/hooks/use-merge-refs/index.js +34 -102
- package/build/hooks/use-merge-refs/index.js.map +7 -1
- package/build/hooks/use-observable-value/index.js +31 -28
- package/build/hooks/use-observable-value/index.js.map +7 -1
- package/build/hooks/use-preferred-color-scheme/index.android.js +31 -23
- package/build/hooks/use-preferred-color-scheme/index.android.js.map +7 -1
- package/build/hooks/use-preferred-color-scheme/index.ios.js +25 -17
- package/build/hooks/use-preferred-color-scheme/index.ios.js.map +7 -1
- package/build/hooks/use-previous/index.js +26 -25
- package/build/hooks/use-previous/index.js.map +7 -1
- package/build/hooks/use-reduced-motion/index.js +35 -18
- package/build/hooks/use-reduced-motion/index.js.map +7 -1
- package/build/hooks/use-ref-effect/index.js +25 -35
- package/build/hooks/use-ref-effect/index.js.map +7 -1
- package/build/hooks/use-resize-observer/index.js +35 -67
- package/build/hooks/use-resize-observer/index.js.map +7 -1
- package/build/hooks/use-resize-observer/legacy/index.js +47 -103
- package/build/hooks/use-resize-observer/legacy/index.js.map +7 -1
- package/build/hooks/use-resize-observer/use-resize-observer.js +44 -36
- package/build/hooks/use-resize-observer/use-resize-observer.js.map +7 -1
- package/build/hooks/use-state-with-history/index.js +68 -63
- package/build/hooks/use-state-with-history/index.js.map +7 -1
- package/build/hooks/use-throttle/index.js +30 -37
- package/build/hooks/use-throttle/index.js.map +7 -1
- package/build/hooks/use-viewport-match/index.js +51 -70
- package/build/hooks/use-viewport-match/index.js.map +7 -1
- package/build/hooks/use-warn-on-change/index.js +50 -40
- package/build/hooks/use-warn-on-change/index.js.map +7 -1
- package/build/index.js +156 -358
- package/build/index.js.map +7 -1
- package/build/utils/create-higher-order-component/index.js +30 -34
- package/build/utils/create-higher-order-component/index.js.map +7 -1
- package/build/utils/debounce/index.js +38 -99
- package/build/utils/debounce/index.js.map +7 -1
- package/build/utils/observable-map/index.js +29 -19
- package/build/utils/observable-map/index.js.map +7 -1
- package/build/utils/throttle/index.js +30 -81
- package/build/utils/throttle/index.js.map +7 -1
- package/build-module/higher-order/compose.js +6 -15
- package/build-module/higher-order/compose.js.map +7 -1
- package/build-module/higher-order/if-condition/index.js +16 -37
- package/build-module/higher-order/if-condition/index.js.map +7 -1
- package/build-module/higher-order/pipe.js +10 -62
- package/build-module/higher-order/pipe.js.map +7 -1
- package/build-module/higher-order/pure/index.js +12 -29
- package/build-module/higher-order/pure/index.js.map +7 -1
- package/build-module/higher-order/with-global-events/index.js +34 -67
- package/build-module/higher-order/with-global-events/index.js.map +7 -1
- package/build-module/higher-order/with-global-events/listener.js +16 -17
- package/build-module/higher-order/with-global-events/listener.js.map +7 -1
- package/build-module/higher-order/with-instance-id/index.js +17 -22
- package/build-module/higher-order/with-instance-id/index.js.map +7 -1
- package/build-module/higher-order/with-safe-timeout/index.js +52 -62
- package/build-module/higher-order/with-safe-timeout/index.js.map +7 -1
- package/build-module/higher-order/with-state/index.js +23 -35
- package/build-module/higher-order/with-state/index.js.map +7 -1
- package/build-module/hooks/use-async-list/index.js +16 -33
- package/build-module/hooks/use-async-list/index.js.map +7 -1
- package/build-module/hooks/use-constrained-tabbing/index.js +26 -70
- package/build-module/hooks/use-constrained-tabbing/index.js.map +7 -1
- package/build-module/hooks/use-copy-on-click/index.js +14 -47
- package/build-module/hooks/use-copy-on-click/index.js.map +7 -1
- package/build-module/hooks/use-copy-to-clipboard/index.js +11 -44
- package/build-module/hooks/use-copy-to-clipboard/index.js.map +7 -1
- package/build-module/hooks/use-debounce/index.js +12 -33
- package/build-module/hooks/use-debounce/index.js.map +7 -1
- package/build-module/hooks/use-debounced-input/index.js +7 -18
- package/build-module/hooks/use-debounced-input/index.js.map +7 -1
- package/build-module/hooks/use-dialog/index.js +29 -43
- package/build-module/hooks/use-dialog/index.js.map +7 -1
- package/build-module/hooks/use-disabled/index.js +47 -78
- package/build-module/hooks/use-disabled/index.js.map +7 -1
- package/build-module/hooks/use-dragging/index.js +19 -39
- package/build-module/hooks/use-dragging/index.js.map +7 -1
- package/build-module/hooks/use-drop-zone/index.js +100 -158
- package/build-module/hooks/use-drop-zone/index.js.map +7 -1
- package/build-module/hooks/use-event/index.js +13 -39
- package/build-module/hooks/use-event/index.js.map +7 -1
- package/build-module/hooks/use-fixed-window-list/index.js +86 -87
- package/build-module/hooks/use-fixed-window-list/index.js.map +7 -1
- package/build-module/hooks/use-focus-on-mount/index.js +12 -48
- package/build-module/hooks/use-focus-on-mount/index.js.map +7 -1
- package/build-module/hooks/use-focus-outside/index.js +21 -93
- package/build-module/hooks/use-focus-outside/index.js.map +7 -1
- package/build-module/hooks/use-focus-return/index.js +13 -48
- package/build-module/hooks/use-focus-return/index.js.map +7 -1
- package/build-module/hooks/use-focusable-iframe/index.js +11 -31
- package/build-module/hooks/use-focusable-iframe/index.js.map +7 -1
- package/build-module/hooks/use-instance-id/index.js +7 -36
- package/build-module/hooks/use-instance-id/index.js.map +7 -1
- package/build-module/hooks/use-isomorphic-layout-effect/index.js +7 -13
- package/build-module/hooks/use-isomorphic-layout-effect/index.js.map +7 -1
- package/build-module/hooks/use-keyboard-shortcut/index.js +40 -60
- package/build-module/hooks/use-keyboard-shortcut/index.js.map +7 -1
- package/build-module/hooks/use-media-query/index.js +21 -30
- package/build-module/hooks/use-media-query/index.js.map +7 -1
- package/build-module/hooks/use-merge-refs/index.js +10 -92
- package/build-module/hooks/use-merge-refs/index.js.map +7 -1
- package/build-module/hooks/use-observable-value/index.js +13 -24
- package/build-module/hooks/use-observable-value/index.js.map +7 -1
- package/build-module/hooks/use-preferred-color-scheme/index.android.js +15 -18
- package/build-module/hooks/use-preferred-color-scheme/index.android.js.map +7 -1
- package/build-module/hooks/use-preferred-color-scheme/index.ios.js +6 -12
- package/build-module/hooks/use-preferred-color-scheme/index.ios.js.map +7 -1
- package/build-module/hooks/use-previous/index.js +7 -20
- package/build-module/hooks/use-previous/index.js.map +7 -1
- package/build-module/hooks/use-reduced-motion/index.js +7 -13
- package/build-module/hooks/use-reduced-motion/index.js.map +7 -1
- package/build-module/hooks/use-ref-effect/index.js +7 -31
- package/build-module/hooks/use-ref-effect/index.js.map +7 -1
- package/build-module/hooks/use-resize-observer/index.js +7 -61
- package/build-module/hooks/use-resize-observer/index.js.map +7 -1
- package/build-module/hooks/use-resize-observer/legacy/index.js +28 -96
- package/build-module/hooks/use-resize-observer/legacy/index.js.map +7 -1
- package/build-module/hooks/use-resize-observer/use-resize-observer.js +10 -28
- package/build-module/hooks/use-resize-observer/use-resize-observer.js.map +7 -1
- package/build-module/hooks/use-state-with-history/index.js +47 -55
- package/build-module/hooks/use-state-with-history/index.js.map +7 -1
- package/build-module/hooks/use-throttle/index.js +12 -33
- package/build-module/hooks/use-throttle/index.js.map +7 -1
- package/build-module/hooks/use-viewport-match/index.js +22 -64
- package/build-module/hooks/use-viewport-match/index.js.map +7 -1
- package/build-module/hooks/use-warn-on-change/index.js +21 -34
- package/build-module/hooks/use-warn-on-change/index.js.map +7 -1
- package/build-module/index.js +83 -53
- package/build-module/index.js.map +7 -1
- package/build-module/utils/create-higher-order-component/index.js +9 -30
- package/build-module/utils/create-higher-order-component/index.js.map +7 -1
- package/build-module/utils/debounce/index.js +17 -95
- package/build-module/utils/debounce/index.js.map +7 -1
- package/build-module/utils/observable-map/index.js +8 -16
- package/build-module/utils/observable-map/index.js.map +7 -1
- package/build-module/utils/throttle/index.js +8 -75
- package/build-module/utils/throttle/index.js.map +7 -1
- package/package.json +17 -10
- package/src/hooks/use-debounce/index.js +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/higher-order/with-network-connectivity/index.native.js +0 -27
- package/build/higher-order/with-network-connectivity/index.native.js.map +0 -1
- package/build/higher-order/with-preferred-color-scheme/index.native.js +0 -37
- package/build/higher-order/with-preferred-color-scheme/index.native.js.map +0 -1
- package/build/hooks/use-constrained-tabbing/index.native.js +0 -20
- package/build/hooks/use-constrained-tabbing/index.native.js.map +0 -1
- package/build/hooks/use-focus-outside/index.native.js +0 -175
- package/build/hooks/use-focus-outside/index.native.js.map +0 -1
- package/build/hooks/use-keyboard-shortcut/index.native.js +0 -9
- package/build/hooks/use-keyboard-shortcut/index.native.js.map +0 -1
- package/build/hooks/use-network-connectivity/index.native.js +0 -58
- package/build/hooks/use-network-connectivity/index.native.js.map +0 -1
- package/build/hooks/use-preferred-color-scheme-style/index.native.js +0 -42
- package/build/hooks/use-preferred-color-scheme-style/index.native.js.map +0 -1
- package/build/hooks/use-resize-observer/index.native.js +0 -14
- package/build/hooks/use-resize-observer/index.native.js.map +0 -1
- package/build/hooks/use-resize-observer/legacy/index.native.js +0 -62
- package/build/hooks/use-resize-observer/legacy/index.native.js.map +0 -1
- package/build/index.native.js +0 -297
- package/build/index.native.js.map +0 -1
- package/build-module/higher-order/with-network-connectivity/index.native.js +0 -19
- package/build-module/higher-order/with-network-connectivity/index.native.js.map +0 -1
- package/build-module/higher-order/with-preferred-color-scheme/index.native.js +0 -29
- package/build-module/higher-order/with-preferred-color-scheme/index.native.js.map +0 -1
- package/build-module/hooks/use-constrained-tabbing/index.native.js +0 -13
- package/build-module/hooks/use-constrained-tabbing/index.native.js.map +0 -1
- package/build-module/hooks/use-focus-outside/index.native.js +0 -169
- package/build-module/hooks/use-focus-outside/index.native.js.map +0 -1
- package/build-module/hooks/use-keyboard-shortcut/index.native.js +0 -3
- package/build-module/hooks/use-keyboard-shortcut/index.native.js.map +0 -1
- package/build-module/hooks/use-network-connectivity/index.native.js +0 -52
- package/build-module/hooks/use-network-connectivity/index.native.js.map +0 -1
- package/build-module/hooks/use-preferred-color-scheme-style/index.native.js +0 -35
- package/build-module/hooks/use-preferred-color-scheme-style/index.native.js.map +0 -1
- package/build-module/hooks/use-resize-observer/index.native.js +0 -2
- package/build-module/hooks/use-resize-observer/index.native.js.map +0 -1
- package/build-module/hooks/use-resize-observer/legacy/index.native.js +0 -56
- package/build-module/hooks/use-resize-observer/legacy/index.native.js.map +0 -1
- package/build-module/index.native.js +0 -45
- package/build-module/index.native.js.map +0 -1
|
@@ -1,69 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parts of this source were derived and modified from lodash,
|
|
3
|
-
* released under the MIT license.
|
|
4
|
-
*
|
|
5
|
-
* https://github.com/lodash/lodash
|
|
6
|
-
*
|
|
7
|
-
* Copyright JS Foundation and other contributors <https://js.foundation/>
|
|
8
|
-
*
|
|
9
|
-
* Based on Underscore.js, copyright Jeremy Ashkenas,
|
|
10
|
-
* DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
|
11
|
-
*
|
|
12
|
-
* This software consists of voluntary contributions made by many
|
|
13
|
-
* individuals. For exact contribution history, see the revision history
|
|
14
|
-
* available at https://github.com/lodash/lodash
|
|
15
|
-
*
|
|
16
|
-
* The following license applies to all parts of this software except as
|
|
17
|
-
* documented below:
|
|
18
|
-
*
|
|
19
|
-
* ====
|
|
20
|
-
*
|
|
21
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
|
22
|
-
* a copy of this software and associated documentation files (the
|
|
23
|
-
* "Software"), to deal in the Software without restriction, including
|
|
24
|
-
* without limitation the rights to use, copy, modify, merge, publish,
|
|
25
|
-
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
26
|
-
* permit persons to whom the Software is furnished to do so, subject to
|
|
27
|
-
* the following conditions:
|
|
28
|
-
*
|
|
29
|
-
* The above copyright notice and this permission notice shall be
|
|
30
|
-
* included in all copies or substantial portions of the Software.
|
|
31
|
-
*
|
|
32
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
33
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
34
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
35
|
-
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
36
|
-
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
37
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
38
|
-
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
39
|
-
*/
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Creates a pipe function.
|
|
43
|
-
*
|
|
44
|
-
* Allows to choose whether to perform left-to-right or right-to-left composition.
|
|
45
|
-
*
|
|
46
|
-
* @see https://lodash.com/docs/4#flow
|
|
47
|
-
*
|
|
48
|
-
* @param {boolean} reverse True if right-to-left, false for left-to-right composition.
|
|
49
|
-
*/
|
|
50
1
|
const basePipe = (reverse = false) => (...funcs) => (...args) => {
|
|
51
2
|
const functions = funcs.flat();
|
|
52
3
|
if (reverse) {
|
|
53
4
|
functions.reverse();
|
|
54
5
|
}
|
|
55
|
-
return functions.reduce(
|
|
6
|
+
return functions.reduce(
|
|
7
|
+
(prev, func) => [func(...prev)],
|
|
8
|
+
args
|
|
9
|
+
)[0];
|
|
56
10
|
};
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Composes multiple higher-order components into a single higher-order component. Performs left-to-right function
|
|
60
|
-
* composition, where each successive invocation is supplied the return value of the previous.
|
|
61
|
-
*
|
|
62
|
-
* This is inspired by `lodash`'s `flow` function.
|
|
63
|
-
*
|
|
64
|
-
* @see https://lodash.com/docs/4#flow
|
|
65
|
-
*/
|
|
66
11
|
const pipe = basePipe();
|
|
67
|
-
|
|
68
|
-
export
|
|
69
|
-
|
|
12
|
+
var pipe_default = pipe;
|
|
13
|
+
export {
|
|
14
|
+
basePipe,
|
|
15
|
+
pipe_default as default
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=pipe.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/higher-order/pipe.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Parts of this source were derived and modified from lodash,\n * released under the MIT license.\n *\n * https://github.com/lodash/lodash\n *\n * Copyright JS Foundation and other contributors <https://js.foundation/>\n *\n * Based on Underscore.js, copyright Jeremy Ashkenas,\n * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>\n *\n * This software consists of voluntary contributions made by many\n * individuals. For exact contribution history, see the revision history\n * available at https://github.com/lodash/lodash\n *\n * The following license applies to all parts of this software except as\n * documented below:\n *\n * ====\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Creates a pipe function.\n *\n * Allows to choose whether to perform left-to-right or right-to-left composition.\n *\n * @see https://lodash.com/docs/4#flow\n *\n * @param {boolean} reverse True if right-to-left, false for left-to-right composition.\n */\nconst basePipe =\n\t( reverse: boolean = false ) =>\n\t( ...funcs: Function[] ) =>\n\t( ...args: unknown[] ) => {\n\t\tconst functions = funcs.flat();\n\t\tif ( reverse ) {\n\t\t\tfunctions.reverse();\n\t\t}\n\t\treturn functions.reduce(\n\t\t\t( prev, func ) => [ func( ...prev ) ],\n\t\t\targs\n\t\t)[ 0 ];\n\t};\n\n/**\n * Composes multiple higher-order components into a single higher-order component. Performs left-to-right function\n * composition, where each successive invocation is supplied the return value of the previous.\n *\n * This is inspired by `lodash`'s `flow` function.\n *\n * @see https://lodash.com/docs/4#flow\n */\nconst pipe = basePipe();\n\nexport { basePipe };\n\nexport default pipe;\n"],
|
|
5
|
+
"mappings": "AAiDA,MAAM,WACL,CAAE,UAAmB,UACrB,IAAK,UACL,IAAK,SAAqB;AACzB,QAAM,YAAY,MAAM,KAAK;AAC7B,MAAK,SAAU;AACd,cAAU,QAAQ;AAAA,EACnB;AACA,SAAO,UAAU;AAAA,IAChB,CAAE,MAAM,SAAU,CAAE,KAAM,GAAG,IAAK,CAAE;AAAA,IACpC;AAAA,EACD,EAAG,CAAE;AACN;AAUD,MAAM,OAAO,SAAS;AAItB,IAAO,eAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,26 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* WordPress dependencies
|
|
7
|
-
*/
|
|
8
|
-
import isShallowEqual from '@wordpress/is-shallow-equal';
|
|
9
|
-
import { Component } from '@wordpress/element';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import { createHigherOrderComponent } from '../../utils/create-higher-order-component';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Given a component returns the enhanced component augmented with a component
|
|
18
|
-
* only re-rendering when its props/state change
|
|
19
|
-
*
|
|
20
|
-
* @deprecated Use `memo` or `PureComponent` instead.
|
|
21
|
-
*/
|
|
22
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
|
-
const pure = createHigherOrderComponent(function (WrappedComponent) {
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import isShallowEqual from "@wordpress/is-shallow-equal";
|
|
3
|
+
import { Component } from "@wordpress/element";
|
|
4
|
+
import { createHigherOrderComponent } from "../../utils/create-higher-order-component";
|
|
5
|
+
const pure = createHigherOrderComponent(function(WrappedComponent) {
|
|
24
6
|
if (WrappedComponent.prototype instanceof Component) {
|
|
25
7
|
return class extends WrappedComponent {
|
|
26
8
|
shouldComponentUpdate(nextProps, nextState) {
|
|
@@ -33,11 +15,12 @@ const pure = createHigherOrderComponent(function (WrappedComponent) {
|
|
|
33
15
|
return !isShallowEqual(nextProps, this.props);
|
|
34
16
|
}
|
|
35
17
|
render() {
|
|
36
|
-
return
|
|
37
|
-
...this.props
|
|
38
|
-
});
|
|
18
|
+
return /* @__PURE__ */ jsx(WrappedComponent, { ...this.props });
|
|
39
19
|
}
|
|
40
20
|
};
|
|
41
|
-
},
|
|
42
|
-
|
|
43
|
-
|
|
21
|
+
}, "pure");
|
|
22
|
+
var pure_default = pure;
|
|
23
|
+
export {
|
|
24
|
+
pure_default as default
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/higher-order/pure/index.tsx"],
|
|
4
|
+
"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 *\n * @deprecated Use `memo` or `PureComponent` instead.\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}, 'pure' );\n\nexport default pure;\n"],
|
|
5
|
+
"mappings": "AA0CU;AAlCV,OAAO,oBAAoB;AAC3B,SAAS,iBAAiB;AAK1B,SAAS,kCAAkC;AAQ3C,MAAM,OAAO,2BAA4B,SACxC,kBACyB;AACzB,MAAK,iBAAiB,qBAAqB,WAAY;AACtD,WAAO,cAAgB,iBAA8C;AAAA,MACpE,sBAAuB,WAAkB,WAAiB;AACzD,eACC,CAAE,eAAgB,WAAW,KAAK,KAAM,KACxC,CAAE,eAAgB,WAAW,KAAK,KAAM;AAAA,MAE1C;AAAA,IACD;AAAA,EACD;AAEA,SAAO,cAAc,UAAmB;AAAA,IACvC,sBAAuB,WAAmB;AACzC,aAAO,CAAE,eAAgB,WAAW,KAAK,KAAM;AAAA,IAChD;AAAA,IAEA,SAAS;AACR,aAAO,oBAAC,oBAAmB,GAAG,KAAK,OAAQ;AAAA,IAC5C;AAAA,EACD;AACD,GAAG,MAAO;AAEV,IAAO,eAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,96 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { createHigherOrderComponent } from '../../utils/create-higher-order-component';
|
|
11
|
-
import Listener from './listener';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Listener instance responsible for managing document event handling.
|
|
15
|
-
*/
|
|
16
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Component, forwardRef } from "@wordpress/element";
|
|
3
|
+
import deprecated from "@wordpress/deprecated";
|
|
4
|
+
import { createHigherOrderComponent } from "../../utils/create-higher-order-component";
|
|
5
|
+
import Listener from "./listener";
|
|
17
6
|
const listener = new Listener();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* values corresponding to a callback function name on the component, will
|
|
23
|
-
* create or update a window event handler to invoke the callback when an event
|
|
24
|
-
* occurs. On behalf of the consuming developer, the higher-order component
|
|
25
|
-
* manages unbinding when the component unmounts, and binding at most a single
|
|
26
|
-
* event handler for the entire application.
|
|
27
|
-
*
|
|
28
|
-
* @deprecated
|
|
29
|
-
*
|
|
30
|
-
* @param {Record<keyof GlobalEventHandlersEventMap, string>} eventTypesToHandlers Object with keys of DOM
|
|
31
|
-
* event type, the value a
|
|
32
|
-
* name of the function on
|
|
33
|
-
* the original component's
|
|
34
|
-
* instance which handles
|
|
35
|
-
* the event.
|
|
36
|
-
*
|
|
37
|
-
* @return {any} Higher-order component.
|
|
38
|
-
*/
|
|
39
|
-
export default function withGlobalEvents(eventTypesToHandlers) {
|
|
40
|
-
deprecated('wp.compose.withGlobalEvents', {
|
|
41
|
-
since: '5.7',
|
|
42
|
-
alternative: 'useEffect'
|
|
7
|
+
function withGlobalEvents(eventTypesToHandlers) {
|
|
8
|
+
deprecated("wp.compose.withGlobalEvents", {
|
|
9
|
+
since: "5.7",
|
|
10
|
+
alternative: "useEffect"
|
|
43
11
|
});
|
|
44
|
-
|
|
45
|
-
// @ts-ignore We don't need to fix the type-related issues because this is deprecated.
|
|
46
|
-
return createHigherOrderComponent(WrappedComponent => {
|
|
12
|
+
return createHigherOrderComponent((WrappedComponent) => {
|
|
47
13
|
class Wrapper extends Component {
|
|
48
|
-
constructor(
|
|
14
|
+
constructor(props) {
|
|
49
15
|
super(props);
|
|
50
16
|
this.handleEvent = this.handleEvent.bind(this);
|
|
51
17
|
this.handleRef = this.handleRef.bind(this);
|
|
52
18
|
}
|
|
53
19
|
componentDidMount() {
|
|
54
|
-
Object.keys(eventTypesToHandlers).forEach(eventType => {
|
|
20
|
+
Object.keys(eventTypesToHandlers).forEach((eventType) => {
|
|
55
21
|
listener.add(eventType, this);
|
|
56
22
|
});
|
|
57
23
|
}
|
|
58
24
|
componentWillUnmount() {
|
|
59
|
-
Object.keys(eventTypesToHandlers).forEach(eventType => {
|
|
25
|
+
Object.keys(eventTypesToHandlers).forEach((eventType) => {
|
|
60
26
|
listener.remove(eventType, this);
|
|
61
27
|
});
|
|
62
28
|
}
|
|
63
|
-
handleEvent(
|
|
64
|
-
const handler = eventTypesToHandlers[
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
29
|
+
handleEvent(event) {
|
|
30
|
+
const handler = eventTypesToHandlers[
|
|
31
|
+
/** @type {keyof GlobalEventHandlersEventMap} */
|
|
32
|
+
event.type
|
|
33
|
+
/* eslint-enable jsdoc/no-undefined-types */
|
|
34
|
+
];
|
|
35
|
+
if (typeof this.wrappedRef[handler] === "function") {
|
|
69
36
|
this.wrappedRef[handler](event);
|
|
70
37
|
}
|
|
71
38
|
}
|
|
72
|
-
handleRef(
|
|
39
|
+
handleRef(el) {
|
|
73
40
|
this.wrappedRef = el;
|
|
74
|
-
// Any component using `withGlobalEvents` that is not setting a `ref`
|
|
75
|
-
// will cause `this.props.forwardedRef` to be `null`, so we need this
|
|
76
|
-
// check.
|
|
77
41
|
if (this.props.forwardedRef) {
|
|
78
42
|
this.props.forwardedRef(el);
|
|
79
43
|
}
|
|
80
44
|
}
|
|
81
45
|
render() {
|
|
82
|
-
return
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
46
|
+
return /* @__PURE__ */ jsx(
|
|
47
|
+
WrappedComponent,
|
|
48
|
+
{
|
|
49
|
+
...this.props.ownProps,
|
|
50
|
+
ref: this.handleRef
|
|
51
|
+
}
|
|
52
|
+
);
|
|
86
53
|
}
|
|
87
54
|
}
|
|
88
55
|
return forwardRef((props, ref) => {
|
|
89
|
-
return
|
|
90
|
-
ownProps: props,
|
|
91
|
-
forwardedRef: ref
|
|
92
|
-
});
|
|
56
|
+
return /* @__PURE__ */ jsx(Wrapper, { ownProps: props, forwardedRef: ref });
|
|
93
57
|
});
|
|
94
|
-
},
|
|
58
|
+
}, "withGlobalEvents");
|
|
95
59
|
}
|
|
96
|
-
|
|
60
|
+
export {
|
|
61
|
+
withGlobalEvents as default
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/higher-order/with-global-events/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Component, forwardRef } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\nimport Listener from './listener';\n\n/**\n * Listener instance responsible for managing document event handling.\n */\nconst listener = new Listener();\n\n/* eslint-disable jsdoc/no-undefined-types */\n/**\n * Higher-order component creator which, given an object of DOM event types and\n * values corresponding to a callback function name on the component, will\n * create or update a window event handler to invoke the callback when an event\n * occurs. On behalf of the consuming developer, the higher-order component\n * manages unbinding when the component unmounts, and binding at most a single\n * event handler for the entire application.\n *\n * @deprecated\n *\n * @param {Record<keyof GlobalEventHandlersEventMap, string>} eventTypesToHandlers Object with keys of DOM\n * event type, the value a\n * name of the function on\n * the original component's\n * instance which handles\n * the event.\n *\n * @return {any} Higher-order component.\n */\nexport default function withGlobalEvents( eventTypesToHandlers ) {\n\tdeprecated( 'wp.compose.withGlobalEvents', {\n\t\tsince: '5.7',\n\t\talternative: 'useEffect',\n\t} );\n\n\t// @ts-ignore We don't need to fix the type-related issues because this is deprecated.\n\treturn createHigherOrderComponent( ( WrappedComponent ) => {\n\t\tclass Wrapper extends Component {\n\t\t\tconstructor( /** @type {any} */ props ) {\n\t\t\t\tsuper( props );\n\n\t\t\t\tthis.handleEvent = this.handleEvent.bind( this );\n\t\t\t\tthis.handleRef = this.handleRef.bind( this );\n\t\t\t}\n\n\t\t\tcomponentDidMount() {\n\t\t\t\tObject.keys( eventTypesToHandlers ).forEach( ( eventType ) => {\n\t\t\t\t\tlistener.add( eventType, this );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcomponentWillUnmount() {\n\t\t\t\tObject.keys( eventTypesToHandlers ).forEach( ( eventType ) => {\n\t\t\t\t\tlistener.remove( eventType, this );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\thandleEvent( /** @type {any} */ event ) {\n\t\t\t\tconst handler =\n\t\t\t\t\teventTypesToHandlers[\n\t\t\t\t\t\t/** @type {keyof GlobalEventHandlersEventMap} */ (\n\t\t\t\t\t\t\tevent.type\n\t\t\t\t\t\t)\n\t\t\t\t\t\t/* eslint-enable jsdoc/no-undefined-types */\n\t\t\t\t\t];\n\t\t\t\tif ( typeof this.wrappedRef[ handler ] === 'function' ) {\n\t\t\t\t\tthis.wrappedRef[ handler ]( event );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\thandleRef( /** @type {any} */ el ) {\n\t\t\t\tthis.wrappedRef = el;\n\t\t\t\t// Any component using `withGlobalEvents` that is not setting a `ref`\n\t\t\t\t// will cause `this.props.forwardedRef` to be `null`, so we need this\n\t\t\t\t// check.\n\t\t\t\tif ( this.props.forwardedRef ) {\n\t\t\t\t\tthis.props.forwardedRef( el );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\treturn (\n\t\t\t\t\t<WrappedComponent\n\t\t\t\t\t\t{ ...this.props.ownProps }\n\t\t\t\t\t\tref={ this.handleRef }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn forwardRef( ( props, ref ) => {\n\t\t\treturn <Wrapper ownProps={ props } forwardedRef={ ref } />;\n\t\t} );\n\t}, 'withGlobalEvents' );\n}\n"],
|
|
5
|
+
"mappings": "AA0FK;AAvFL,SAAS,WAAW,kBAAkB;AACtC,OAAO,gBAAgB;AAKvB,SAAS,kCAAkC;AAC3C,OAAO,cAAc;AAKrB,MAAM,WAAW,IAAI,SAAS;AAsBf,SAAR,iBAAmC,sBAAuB;AAChE,aAAY,+BAA+B;AAAA,IAC1C,OAAO;AAAA,IACP,aAAa;AAAA,EACd,CAAE;AAGF,SAAO,2BAA4B,CAAE,qBAAsB;AAAA,IAC1D,MAAM,gBAAgB,UAAU;AAAA,MAC/B,YAAgC,OAAQ;AACvC,cAAO,KAAM;AAEb,aAAK,cAAc,KAAK,YAAY,KAAM,IAAK;AAC/C,aAAK,YAAY,KAAK,UAAU,KAAM,IAAK;AAAA,MAC5C;AAAA,MAEA,oBAAoB;AACnB,eAAO,KAAM,oBAAqB,EAAE,QAAS,CAAE,cAAe;AAC7D,mBAAS,IAAK,WAAW,IAAK;AAAA,QAC/B,CAAE;AAAA,MACH;AAAA,MAEA,uBAAuB;AACtB,eAAO,KAAM,oBAAqB,EAAE,QAAS,CAAE,cAAe;AAC7D,mBAAS,OAAQ,WAAW,IAAK;AAAA,QAClC,CAAE;AAAA,MACH;AAAA,MAEA,YAAgC,OAAQ;AACvC,cAAM,UACL;AAAA;AAAA,UAEE,MAAM;AAAA;AAAA,QAGR;AACD,YAAK,OAAO,KAAK,WAAY,OAAQ,MAAM,YAAa;AACvD,eAAK,WAAY,OAAQ,EAAG,KAAM;AAAA,QACnC;AAAA,MACD;AAAA,MAEA,UAA8B,IAAK;AAClC,aAAK,aAAa;AAIlB,YAAK,KAAK,MAAM,cAAe;AAC9B,eAAK,MAAM,aAAc,EAAG;AAAA,QAC7B;AAAA,MACD;AAAA,MAEA,SAAS;AACR,eACC;AAAA,UAAC;AAAA;AAAA,YACE,GAAG,KAAK,MAAM;AAAA,YAChB,KAAM,KAAK;AAAA;AAAA,QACZ;AAAA,MAEF;AAAA,IACD;AAEA,WAAO,WAAY,CAAE,OAAO,QAAS;AACpC,aAAO,oBAAC,WAAQ,UAAW,OAAQ,cAAe,KAAM;AAAA,IACzD,CAAE;AAAA,EACH,GAAG,kBAAmB;AACvB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,38 +1,37 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Class responsible for orchestrating event handling on the global window,
|
|
3
|
-
* binding a single event to be shared across all handling instances, and
|
|
4
|
-
* removing the handler when no instances are listening for the event.
|
|
5
|
-
*/
|
|
6
1
|
class Listener {
|
|
7
2
|
constructor() {
|
|
8
|
-
/** @type {any} */
|
|
9
3
|
this.listeners = {};
|
|
10
4
|
this.handleEvent = this.handleEvent.bind(this);
|
|
11
5
|
}
|
|
12
|
-
add(
|
|
6
|
+
add(eventType, instance) {
|
|
13
7
|
if (!this.listeners[eventType]) {
|
|
14
|
-
// Adding first listener for this type, so bind event.
|
|
15
8
|
window.addEventListener(eventType, this.handleEvent);
|
|
16
9
|
this.listeners[eventType] = [];
|
|
17
10
|
}
|
|
18
11
|
this.listeners[eventType].push(instance);
|
|
19
12
|
}
|
|
20
|
-
remove(
|
|
13
|
+
remove(eventType, instance) {
|
|
21
14
|
if (!this.listeners[eventType]) {
|
|
22
15
|
return;
|
|
23
16
|
}
|
|
24
|
-
this.listeners[eventType] = this.listeners[eventType].filter(
|
|
17
|
+
this.listeners[eventType] = this.listeners[eventType].filter(
|
|
18
|
+
(listener) => listener !== instance
|
|
19
|
+
);
|
|
25
20
|
if (!this.listeners[eventType].length) {
|
|
26
|
-
// Removing last listener for this type, so unbind event.
|
|
27
21
|
window.removeEventListener(eventType, this.handleEvent);
|
|
28
22
|
delete this.listeners[eventType];
|
|
29
23
|
}
|
|
30
24
|
}
|
|
31
|
-
handleEvent(
|
|
32
|
-
this.listeners[event.type]?.forEach(
|
|
33
|
-
instance
|
|
34
|
-
|
|
25
|
+
handleEvent(event) {
|
|
26
|
+
this.listeners[event.type]?.forEach(
|
|
27
|
+
(instance) => {
|
|
28
|
+
instance.handleEvent(event);
|
|
29
|
+
}
|
|
30
|
+
);
|
|
35
31
|
}
|
|
36
32
|
}
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
var listener_default = Listener;
|
|
34
|
+
export {
|
|
35
|
+
listener_default as default
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=listener.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/higher-order/with-global-events/listener.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * Class responsible for orchestrating event handling on the global window,\n * binding a single event to be shared across all handling instances, and\n * removing the handler when no instances are listening for the event.\n */\nclass Listener {\n\tconstructor() {\n\t\t/** @type {any} */\n\t\tthis.listeners = {};\n\n\t\tthis.handleEvent = this.handleEvent.bind( this );\n\t}\n\n\tadd( /** @type {any} */ eventType, /** @type {any} */ instance ) {\n\t\tif ( ! this.listeners[ eventType ] ) {\n\t\t\t// Adding first listener for this type, so bind event.\n\t\t\twindow.addEventListener( eventType, this.handleEvent );\n\t\t\tthis.listeners[ eventType ] = [];\n\t\t}\n\n\t\tthis.listeners[ eventType ].push( instance );\n\t}\n\n\tremove( /** @type {any} */ eventType, /** @type {any} */ instance ) {\n\t\tif ( ! this.listeners[ eventType ] ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.listeners[ eventType ] = this.listeners[ eventType ].filter(\n\t\t\t( /** @type {any} */ listener ) => listener !== instance\n\t\t);\n\n\t\tif ( ! this.listeners[ eventType ].length ) {\n\t\t\t// Removing last listener for this type, so unbind event.\n\t\t\twindow.removeEventListener( eventType, this.handleEvent );\n\t\t\tdelete this.listeners[ eventType ];\n\t\t}\n\t}\n\n\thandleEvent( /** @type {any} */ event ) {\n\t\tthis.listeners[ event.type ]?.forEach(\n\t\t\t( /** @type {any} */ instance ) => {\n\t\t\t\tinstance.handleEvent( event );\n\t\t\t}\n\t\t);\n\t}\n}\n\nexport default Listener;\n"],
|
|
5
|
+
"mappings": "AAKA,MAAM,SAAS;AAAA,EACd,cAAc;AAEb,SAAK,YAAY,CAAC;AAElB,SAAK,cAAc,KAAK,YAAY,KAAM,IAAK;AAAA,EAChD;AAAA,EAEA,IAAwB,WAA8B,UAAW;AAChE,QAAK,CAAE,KAAK,UAAW,SAAU,GAAI;AAEpC,aAAO,iBAAkB,WAAW,KAAK,WAAY;AACrD,WAAK,UAAW,SAAU,IAAI,CAAC;AAAA,IAChC;AAEA,SAAK,UAAW,SAAU,EAAE,KAAM,QAAS;AAAA,EAC5C;AAAA,EAEA,OAA2B,WAA8B,UAAW;AACnE,QAAK,CAAE,KAAK,UAAW,SAAU,GAAI;AACpC;AAAA,IACD;AAEA,SAAK,UAAW,SAAU,IAAI,KAAK,UAAW,SAAU,EAAE;AAAA,MACzD,CAAqB,aAAc,aAAa;AAAA,IACjD;AAEA,QAAK,CAAE,KAAK,UAAW,SAAU,EAAE,QAAS;AAE3C,aAAO,oBAAqB,WAAW,KAAK,WAAY;AACxD,aAAO,KAAK,UAAW,SAAU;AAAA,IAClC;AAAA,EACD;AAAA,EAEA,YAAgC,OAAQ;AACvC,SAAK,UAAW,MAAM,IAAK,GAAG;AAAA,MAC7B,CAAqB,aAAc;AAClC,iBAAS,YAAa,KAAM;AAAA,MAC7B;AAAA,IACD;AAAA,EACD;AACD;AAEA,IAAO,mBAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
}, 'instanceId');
|
|
21
|
-
export default withInstanceId;
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createHigherOrderComponent } from "../../utils/create-higher-order-component";
|
|
3
|
+
import useInstanceId from "../../hooks/use-instance-id";
|
|
4
|
+
const withInstanceId = createHigherOrderComponent(
|
|
5
|
+
(WrappedComponent) => {
|
|
6
|
+
return (props) => {
|
|
7
|
+
const instanceId = useInstanceId(WrappedComponent);
|
|
8
|
+
return /* @__PURE__ */ jsx(WrappedComponent, { ...props, instanceId });
|
|
9
|
+
};
|
|
10
|
+
},
|
|
11
|
+
"instanceId"
|
|
12
|
+
);
|
|
13
|
+
var with_instance_id_default = withInstanceId;
|
|
14
|
+
export {
|
|
15
|
+
with_instance_id_default as default
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/higher-order/with-instance-id/index.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * Internal dependencies\n */\nimport type {\n\tWithInjectedProps,\n\tWithoutInjectedProps,\n} from '../../utils/create-higher-order-component';\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\nimport useInstanceId from '../../hooks/use-instance-id';\n\ntype InstanceIdProps = { instanceId: string | number };\n\n/**\n * A Higher Order Component used to provide a unique instance ID by component.\n */\nconst withInstanceId = createHigherOrderComponent(\n\t< C extends WithInjectedProps< C, InstanceIdProps > >(\n\t\tWrappedComponent: C\n\t) => {\n\t\treturn ( props: WithoutInjectedProps< C, InstanceIdProps > ) => {\n\t\t\tconst instanceId = useInstanceId( WrappedComponent );\n\t\t\t// @ts-ignore\n\t\t\treturn <WrappedComponent { ...props } instanceId={ instanceId } />;\n\t\t};\n\t},\n\t'instanceId'\n);\n\nexport default withInstanceId;\n"],
|
|
5
|
+
"mappings": "AAsBU;AAfV,SAAS,kCAAkC;AAC3C,OAAO,mBAAmB;AAO1B,MAAM,iBAAiB;AAAA,EACtB,CACC,qBACI;AACJ,WAAO,CAAE,UAAuD;AAC/D,YAAM,aAAa,cAAe,gBAAiB;AAEnD,aAAO,oBAAC,oBAAmB,GAAG,OAAQ,YAA0B;AAAA,IACjE;AAAA,EACD;AAAA,EACA;AACD;AAEA,IAAO,2BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,62 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
...this.props,
|
|
54
|
-
setTimeout: this.setTimeout,
|
|
55
|
-
clearTimeout: this.clearTimeout
|
|
56
|
-
})
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}, 'withSafeTimeout');
|
|
61
|
-
export default withSafeTimeout;
|
|
62
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Component } from "@wordpress/element";
|
|
3
|
+
import { createHigherOrderComponent } from "../../utils/create-higher-order-component";
|
|
4
|
+
const withSafeTimeout = createHigherOrderComponent(
|
|
5
|
+
(OriginalComponent) => {
|
|
6
|
+
return class WrappedComponent extends Component {
|
|
7
|
+
timeouts;
|
|
8
|
+
constructor(props) {
|
|
9
|
+
super(props);
|
|
10
|
+
this.timeouts = [];
|
|
11
|
+
this.setTimeout = this.setTimeout.bind(this);
|
|
12
|
+
this.clearTimeout = this.clearTimeout.bind(this);
|
|
13
|
+
}
|
|
14
|
+
componentWillUnmount() {
|
|
15
|
+
this.timeouts.forEach(clearTimeout);
|
|
16
|
+
}
|
|
17
|
+
setTimeout(fn, delay) {
|
|
18
|
+
const id = setTimeout(() => {
|
|
19
|
+
fn();
|
|
20
|
+
this.clearTimeout(id);
|
|
21
|
+
}, delay);
|
|
22
|
+
this.timeouts.push(id);
|
|
23
|
+
return id;
|
|
24
|
+
}
|
|
25
|
+
clearTimeout(id) {
|
|
26
|
+
clearTimeout(id);
|
|
27
|
+
this.timeouts = this.timeouts.filter(
|
|
28
|
+
(timeoutId) => timeoutId !== id
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
render() {
|
|
32
|
+
return (
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
/* @__PURE__ */ jsx(
|
|
35
|
+
OriginalComponent,
|
|
36
|
+
{
|
|
37
|
+
...this.props,
|
|
38
|
+
setTimeout: this.setTimeout,
|
|
39
|
+
clearTimeout: this.clearTimeout
|
|
40
|
+
}
|
|
41
|
+
)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
"withSafeTimeout"
|
|
47
|
+
);
|
|
48
|
+
var with_safe_timeout_default = withSafeTimeout;
|
|
49
|
+
export {
|
|
50
|
+
with_safe_timeout_default as default
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/higher-order/with-safe-timeout/index.tsx"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type {\n\tWithInjectedProps,\n\tWithoutInjectedProps,\n} from '../../utils/create-higher-order-component';\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * We cannot use the `Window['setTimeout']` and `Window['clearTimeout']`\n * types here because those functions include functionality that is not handled\n * by this component, like the ability to pass extra arguments.\n *\n * In the case of this component, we only handle the simplest case where\n * `setTimeout` only accepts a function (not a string) and an optional delay.\n */\ninterface TimeoutProps {\n\tsetTimeout: ( fn: () => void, delay: number ) => number;\n\tclearTimeout: ( id: number ) => void;\n}\n\n/**\n * A higher-order component used to provide and manage delayed function calls\n * that ought to be bound to a component's lifecycle.\n */\nconst withSafeTimeout = createHigherOrderComponent(\n\t< C extends WithInjectedProps< C, TimeoutProps > >(\n\t\tOriginalComponent: C\n\t) => {\n\t\ttype WrappedProps = WithoutInjectedProps< C, TimeoutProps >;\n\t\treturn class WrappedComponent extends Component< WrappedProps > {\n\t\t\ttimeouts: number[];\n\n\t\t\tconstructor( props: WrappedProps ) {\n\t\t\t\tsuper( props );\n\t\t\t\tthis.timeouts = [];\n\t\t\t\tthis.setTimeout = this.setTimeout.bind( this );\n\t\t\t\tthis.clearTimeout = this.clearTimeout.bind( this );\n\t\t\t}\n\n\t\t\tcomponentWillUnmount() {\n\t\t\t\tthis.timeouts.forEach( clearTimeout );\n\t\t\t}\n\n\t\t\tsetTimeout( fn: () => void, delay: number ) {\n\t\t\t\tconst id = setTimeout( () => {\n\t\t\t\t\tfn();\n\t\t\t\t\tthis.clearTimeout( id );\n\t\t\t\t}, delay );\n\t\t\t\tthis.timeouts.push( id );\n\t\t\t\treturn id;\n\t\t\t}\n\n\t\t\tclearTimeout( id: number ) {\n\t\t\t\tclearTimeout( id );\n\t\t\t\tthis.timeouts = this.timeouts.filter(\n\t\t\t\t\t( timeoutId ) => timeoutId !== id\n\t\t\t\t);\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\treturn (\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...this.props }\n\t\t\t\t\t\tsetTimeout={ this.setTimeout }\n\t\t\t\t\t\tclearTimeout={ this.clearTimeout }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t},\n\t'withSafeTimeout'\n);\n\nexport default withSafeTimeout;\n"],
|
|
5
|
+
"mappings": "AAqEK;AAlEL,SAAS,iBAAiB;AAS1B,SAAS,kCAAkC;AAmB3C,MAAM,kBAAkB;AAAA,EACvB,CACC,sBACI;AAEJ,WAAO,MAAM,yBAAyB,UAA0B;AAAA,MAC/D;AAAA,MAEA,YAAa,OAAsB;AAClC,cAAO,KAAM;AACb,aAAK,WAAW,CAAC;AACjB,aAAK,aAAa,KAAK,WAAW,KAAM,IAAK;AAC7C,aAAK,eAAe,KAAK,aAAa,KAAM,IAAK;AAAA,MAClD;AAAA,MAEA,uBAAuB;AACtB,aAAK,SAAS,QAAS,YAAa;AAAA,MACrC;AAAA,MAEA,WAAY,IAAgB,OAAgB;AAC3C,cAAM,KAAK,WAAY,MAAM;AAC5B,aAAG;AACH,eAAK,aAAc,EAAG;AAAA,QACvB,GAAG,KAAM;AACT,aAAK,SAAS,KAAM,EAAG;AACvB,eAAO;AAAA,MACR;AAAA,MAEA,aAAc,IAAa;AAC1B,qBAAc,EAAG;AACjB,aAAK,WAAW,KAAK,SAAS;AAAA,UAC7B,CAAE,cAAe,cAAc;AAAA,QAChC;AAAA,MACD;AAAA,MAEA,SAAS;AACR;AAAA;AAAA,UAEC;AAAA,YAAC;AAAA;AAAA,cACE,GAAG,KAAK;AAAA,cACV,YAAa,KAAK;AAAA,cAClB,cAAe,KAAK;AAAA;AAAA,UACrB;AAAA;AAAA,MAEF;AAAA,IACD;AAAA,EACD;AAAA,EACA;AACD;AAEA,IAAO,4BAAQ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|