@wordpress/compose 6.16.0 → 6.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/higher-order/compose.js +0 -2
- package/build/higher-order/compose.js.map +1 -1
- package/build/higher-order/if-condition/index.js +2 -6
- package/build/higher-order/if-condition/index.js.map +1 -1
- package/build/higher-order/pipe.js +1 -5
- package/build/higher-order/pipe.js.map +1 -1
- package/build/higher-order/pure/index.js +2 -10
- package/build/higher-order/pure/index.js.map +1 -1
- package/build/higher-order/with-global-events/index.js +13 -32
- package/build/higher-order/with-global-events/index.js.map +1 -1
- package/build/higher-order/with-global-events/listener.js +5 -28
- package/build/higher-order/with-global-events/listener.js.map +1 -1
- package/build/higher-order/with-instance-id/index.js +4 -8
- package/build/higher-order/with-instance-id/index.js.map +1 -1
- package/build/higher-order/with-preferred-color-scheme/index.native.js +3 -6
- package/build/higher-order/with-preferred-color-scheme/index.native.js.map +1 -1
- package/build/higher-order/with-safe-timeout/index.js +4 -14
- package/build/higher-order/with-safe-timeout/index.js.map +1 -1
- package/build/higher-order/with-state/index.js +3 -11
- package/build/higher-order/with-state/index.js.map +1 -1
- package/build/hooks/use-async-list/index.js +1 -14
- package/build/hooks/use-async-list/index.js.map +1 -1
- package/build/hooks/use-constrained-tabbing/index.js +14 -30
- package/build/hooks/use-constrained-tabbing/index.js.map +1 -1
- package/build/hooks/use-constrained-tabbing/index.native.js +4 -4
- package/build/hooks/use-constrained-tabbing/index.native.js.map +1 -1
- package/build/hooks/use-copy-on-click/index.js +6 -15
- package/build/hooks/use-copy-on-click/index.js.map +1 -1
- package/build/hooks/use-copy-to-clipboard/index.js +3 -11
- package/build/hooks/use-copy-to-clipboard/index.js.map +1 -1
- package/build/hooks/use-debounce/index.js +0 -4
- package/build/hooks/use-debounce/index.js.map +1 -1
- package/build/hooks/use-dialog/index.js +2 -12
- package/build/hooks/use-dialog/index.js.map +1 -1
- package/build/hooks/use-disabled/index.js +5 -15
- package/build/hooks/use-disabled/index.js.map +1 -1
- package/build/hooks/use-dragging/index.js +4 -11
- package/build/hooks/use-dragging/index.js.map +1 -1
- package/build/hooks/use-drop-zone/index.js +27 -66
- package/build/hooks/use-drop-zone/index.js.map +1 -1
- package/build/hooks/use-fixed-window-list/index.js +8 -34
- package/build/hooks/use-fixed-window-list/index.js.map +1 -1
- package/build/hooks/use-focus-on-mount/index.js +3 -14
- package/build/hooks/use-focus-on-mount/index.js.map +1 -1
- package/build/hooks/use-focus-outside/index.js +13 -19
- package/build/hooks/use-focus-outside/index.js.map +1 -1
- package/build/hooks/use-focus-outside/index.native.js +13 -21
- package/build/hooks/use-focus-outside/index.native.js.map +1 -1
- package/build/hooks/use-focus-return/index.js +7 -15
- package/build/hooks/use-focus-return/index.js.map +1 -1
- package/build/hooks/use-focusable-iframe/index.js +1 -5
- package/build/hooks/use-focusable-iframe/index.js.map +1 -1
- package/build/hooks/use-instance-id/index.js +3 -5
- package/build/hooks/use-instance-id/index.js.map +1 -1
- package/build/hooks/use-isomorphic-layout-effect/index.js +0 -2
- package/build/hooks/use-isomorphic-layout-effect/index.js.map +1 -1
- package/build/hooks/use-keyboard-shortcut/index.js +12 -28
- package/build/hooks/use-keyboard-shortcut/index.js.map +1 -1
- package/build/hooks/use-keyboard-shortcut/index.native.js +0 -2
- package/build/hooks/use-keyboard-shortcut/index.native.js.map +1 -1
- package/build/hooks/use-media-query/index.js +1 -9
- package/build/hooks/use-media-query/index.js.map +1 -1
- package/build/hooks/use-merge-refs/index.js +18 -24
- package/build/hooks/use-merge-refs/index.js.map +1 -1
- package/build/hooks/use-preferred-color-scheme/index.android.js +0 -5
- package/build/hooks/use-preferred-color-scheme/index.android.js.map +1 -1
- package/build/hooks/use-preferred-color-scheme/index.ios.js +0 -2
- package/build/hooks/use-preferred-color-scheme/index.ios.js.map +1 -1
- package/build/hooks/use-preferred-color-scheme-style/index.native.js +2 -5
- package/build/hooks/use-preferred-color-scheme-style/index.native.js.map +1 -1
- package/build/hooks/use-previous/index.js +3 -4
- package/build/hooks/use-previous/index.js.map +1 -1
- package/build/hooks/use-reduced-motion/index.js +0 -4
- package/build/hooks/use-reduced-motion/index.js.map +1 -1
- package/build/hooks/use-ref-effect/index.js +0 -2
- package/build/hooks/use-ref-effect/index.js.map +1 -1
- package/build/hooks/use-resize-observer/index.js +23 -30
- package/build/hooks/use-resize-observer/index.js.map +1 -1
- package/build/hooks/use-resize-observer/index.native.js +0 -6
- package/build/hooks/use-resize-observer/index.native.js.map +1 -1
- package/build/hooks/use-throttle/index.js +0 -4
- package/build/hooks/use-throttle/index.js.map +1 -1
- package/build/hooks/use-viewport-match/index.js +4 -13
- package/build/hooks/use-viewport-match/index.js.map +1 -1
- package/build/hooks/use-warn-on-change/index.js +4 -14
- package/build/hooks/use-warn-on-change/index.js.map +1 -1
- package/build/index.js +0 -41
- package/build/index.js.map +1 -1
- package/build/index.native.js +0 -33
- package/build/index.native.js.map +1 -1
- package/build/utils/create-higher-order-component/index.js +1 -4
- package/build/utils/create-higher-order-component/index.js.map +1 -1
- package/build/utils/debounce/index.js +12 -37
- package/build/utils/debounce/index.js.map +1 -1
- package/build/utils/throttle/index.js +0 -5
- package/build/utils/throttle/index.js.map +1 -1
- package/build-module/higher-order/compose.js +1 -1
- package/build-module/higher-order/compose.js.map +1 -1
- package/build-module/higher-order/if-condition/index.js +3 -5
- package/build-module/higher-order/if-condition/index.js.map +1 -1
- package/build-module/higher-order/pipe.js +1 -4
- package/build-module/higher-order/pipe.js.map +1 -1
- package/build-module/higher-order/pure/index.js +4 -8
- package/build-module/higher-order/pure/index.js.map +1 -1
- package/build-module/higher-order/with-global-events/index.js +15 -29
- package/build-module/higher-order/with-global-events/index.js.map +1 -1
- package/build-module/higher-order/with-global-events/listener.js +5 -27
- package/build-module/higher-order/with-global-events/listener.js.map +1 -1
- package/build-module/higher-order/with-instance-id/index.js +5 -5
- package/build-module/higher-order/with-instance-id/index.js.map +1 -1
- package/build-module/higher-order/with-preferred-color-scheme/index.native.js +3 -3
- package/build-module/higher-order/with-preferred-color-scheme/index.native.js.map +1 -1
- package/build-module/higher-order/with-safe-timeout/index.js +6 -8
- package/build-module/higher-order/with-safe-timeout/index.js.map +1 -1
- package/build-module/higher-order/with-state/index.js +5 -9
- package/build-module/higher-order/with-state/index.js.map +1 -1
- package/build-module/hooks/use-async-list/index.js +1 -12
- package/build-module/hooks/use-async-list/index.js.map +1 -1
- package/build-module/hooks/use-constrained-tabbing/index.js +16 -27
- package/build-module/hooks/use-constrained-tabbing/index.js.map +1 -1
- package/build-module/hooks/use-constrained-tabbing/index.native.js +3 -3
- package/build-module/hooks/use-constrained-tabbing/index.native.js.map +1 -1
- package/build-module/hooks/use-copy-on-click/index.js +8 -12
- package/build-module/hooks/use-copy-on-click/index.js.map +1 -1
- package/build-module/hooks/use-copy-to-clipboard/index.js +6 -9
- package/build-module/hooks/use-copy-to-clipboard/index.js.map +1 -1
- package/build-module/hooks/use-debounce/index.js +3 -3
- package/build-module/hooks/use-debounce/index.js.map +1 -1
- package/build-module/hooks/use-dialog/index.js +3 -5
- package/build-module/hooks/use-dialog/index.js.map +1 -1
- package/build-module/hooks/use-disabled/index.js +6 -12
- package/build-module/hooks/use-disabled/index.js.map +1 -1
- package/build-module/hooks/use-dragging/index.js +6 -9
- package/build-module/hooks/use-dragging/index.js.map +1 -1
- package/build-module/hooks/use-drop-zone/index.js +29 -64
- package/build-module/hooks/use-drop-zone/index.js.map +1 -1
- package/build-module/hooks/use-fixed-window-list/index.js +8 -30
- package/build-module/hooks/use-fixed-window-list/index.js.map +1 -1
- package/build-module/hooks/use-focus-on-mount/index.js +4 -12
- package/build-module/hooks/use-focus-on-mount/index.js.map +1 -1
- package/build-module/hooks/use-focus-outside/index.js +14 -18
- package/build-module/hooks/use-focus-outside/index.js.map +1 -1
- package/build-module/hooks/use-focus-outside/index.native.js +14 -20
- package/build-module/hooks/use-focus-outside/index.native.js.map +1 -1
- package/build-module/hooks/use-focus-return/index.js +8 -14
- package/build-module/hooks/use-focus-return/index.js.map +1 -1
- package/build-module/hooks/use-focusable-iframe/index.js +2 -3
- package/build-module/hooks/use-focusable-iframe/index.js.map +1 -1
- package/build-module/hooks/use-instance-id/index.js +2 -3
- package/build-module/hooks/use-instance-id/index.js.map +1 -1
- package/build-module/hooks/use-isomorphic-layout-effect/index.js +1 -1
- package/build-module/hooks/use-isomorphic-layout-effect/index.js.map +1 -1
- package/build-module/hooks/use-keyboard-shortcut/index.js +14 -24
- package/build-module/hooks/use-keyboard-shortcut/index.js.map +1 -1
- package/build-module/hooks/use-keyboard-shortcut/index.native.js +0 -1
- package/build-module/hooks/use-keyboard-shortcut/index.native.js.map +1 -1
- package/build-module/hooks/use-media-query/index.js +2 -8
- package/build-module/hooks/use-media-query/index.js.map +1 -1
- package/build-module/hooks/use-merge-refs/index.js +19 -23
- package/build-module/hooks/use-merge-refs/index.js.map +1 -1
- package/build-module/hooks/use-preferred-color-scheme/index.android.js +1 -3
- package/build-module/hooks/use-preferred-color-scheme/index.android.js.map +1 -1
- package/build-module/hooks/use-preferred-color-scheme/index.ios.js +1 -1
- package/build-module/hooks/use-preferred-color-scheme/index.ios.js.map +1 -1
- package/build-module/hooks/use-preferred-color-scheme-style/index.native.js +3 -3
- package/build-module/hooks/use-preferred-color-scheme-style/index.native.js.map +1 -1
- package/build-module/hooks/use-previous/index.js +4 -3
- package/build-module/hooks/use-previous/index.js.map +1 -1
- package/build-module/hooks/use-reduced-motion/index.js +1 -2
- package/build-module/hooks/use-reduced-motion/index.js.map +1 -1
- package/build-module/hooks/use-ref-effect/index.js +1 -1
- package/build-module/hooks/use-ref-effect/index.js.map +1 -1
- package/build-module/hooks/use-resize-observer/index.js +22 -30
- package/build-module/hooks/use-resize-observer/index.js.map +1 -1
- package/build-module/hooks/use-resize-observer/index.native.js +1 -6
- package/build-module/hooks/use-resize-observer/index.native.js.map +1 -1
- package/build-module/hooks/use-throttle/index.js +3 -3
- package/build-module/hooks/use-throttle/index.js.map +1 -1
- package/build-module/hooks/use-viewport-match/index.js +6 -11
- package/build-module/hooks/use-viewport-match/index.js.map +1 -1
- package/build-module/hooks/use-warn-on-change/index.js +6 -12
- package/build-module/hooks/use-warn-on-change/index.js.map +1 -1
- package/build-module/index.js +10 -7
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +10 -7
- package/build-module/index.native.js.map +1 -1
- package/build-module/utils/create-higher-order-component/index.js +1 -2
- package/build-module/utils/create-higher-order-component/index.js.map +1 -1
- package/build-module/utils/debounce/index.js +12 -35
- package/build-module/utils/debounce/index.js.map +1 -1
- package/build-module/utils/throttle/index.js +0 -3
- package/build-module/utils/throttle/index.js.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/higher-order/with-safe-timeout/index.d.ts +1 -1
- package/build-types/higher-order/with-safe-timeout/index.d.ts.map +1 -1
- package/build-types/hooks/use-disabled/index.d.ts +1 -1
- package/build-types/hooks/use-disabled/index.d.ts.map +1 -1
- package/build-types/hooks/use-isomorphic-layout-effect/index.d.ts +1 -1
- package/build-types/hooks/use-isomorphic-layout-effect/index.d.ts.map +1 -1
- package/build-types/hooks/use-viewport-match/index.d.ts +1 -1
- package/package.json +8 -8
- package/src/higher-order/with-instance-id/index.tsx +2 -2
- package/src/higher-order/with-safe-timeout/index.tsx +2 -2
- package/src/hooks/use-resize-observer/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/compose.ts"],"
|
|
1
|
+
{"version":3,"names":["_pipe","require","compose","basePipe","_default","exports","default"],"sources":["@wordpress/compose/src/higher-order/compose.ts"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { basePipe } from './pipe';\n\n/**\n * Composes multiple higher-order components into a single higher-order component. Performs right-to-left function\n * composition, where each successive invocation is supplied the return value of the previous.\n *\n * This is inspired by `lodash`'s `flowRight` function.\n *\n * @see https://docs-lodash.com/v4/flow-right/\n */\nconst compose = basePipe( true );\n\nexport default compose;\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,OAAO,GAAG,IAAAC,cAAQ,EAAE,IAAK,CAAC;AAAC,IAAAC,QAAA,GAElBF,OAAO;AAAAG,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
8
|
var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* External dependencies
|
|
14
11
|
*/
|
|
@@ -39,12 +36,11 @@ function ifCondition(predicate) {
|
|
|
39
36
|
if (!predicate(props)) {
|
|
40
37
|
return null;
|
|
41
38
|
}
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
return (0, _element.createElement)(WrappedComponent, {
|
|
40
|
+
...props
|
|
44
41
|
});
|
|
45
42
|
}, 'ifCondition');
|
|
46
43
|
}
|
|
47
|
-
|
|
48
44
|
var _default = ifCondition;
|
|
49
45
|
exports.default = _default;
|
|
50
46
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_createHigherOrderComponent","require","ifCondition","predicate","createHigherOrderComponent","WrappedComponent","props","_element","createElement","_default","exports","default"],"sources":["@wordpress/compose/src/higher-order/if-condition/index.tsx"],"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"],"mappings":";;;;;;;AAQA,IAAAA,2BAAA,GAAAC,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,WAAWA,CACnBC,SAAsC,EACrC;EACD,OAAO,IAAAC,sDAA0B,EAC9BC,gBAAwC,IAAQC,KAAY,IAAM;IACnE,IAAK,CAAEH,SAAS,CAAEG,KAAM,CAAC,EAAG;MAC3B,OAAO,IAAI;IACZ;IAEA,OAAO,IAAAC,QAAA,CAAAC,aAAA,EAACH,gBAAgB;MAAA,GAAMC;IAAK,CAAI,CAAC;EACzC,CAAC,EACD,aACD,CAAC;AACF;AAAC,IAAAG,QAAA,GAEcP,WAAW;AAAAQ,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.basePipe = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Parts of this source were derived and modified from lodash,
|
|
10
9
|
* released under the MIT license.
|
|
@@ -56,13 +55,12 @@ exports.default = exports.basePipe = void 0;
|
|
|
56
55
|
*/
|
|
57
56
|
const basePipe = (reverse = false) => (...funcs) => (...args) => {
|
|
58
57
|
const functions = funcs.flat();
|
|
59
|
-
|
|
60
58
|
if (reverse) {
|
|
61
59
|
functions.reverse();
|
|
62
60
|
}
|
|
63
|
-
|
|
64
61
|
return functions.reduce((prev, func) => [func(...prev)], args)[0];
|
|
65
62
|
};
|
|
63
|
+
|
|
66
64
|
/**
|
|
67
65
|
* Composes multiple higher-order components into a single higher-order component. Performs left-to-right function
|
|
68
66
|
* composition, where each successive invocation is supplied the return value of the previous.
|
|
@@ -71,8 +69,6 @@ const basePipe = (reverse = false) => (...funcs) => (...args) => {
|
|
|
71
69
|
*
|
|
72
70
|
* @see https://docs-lodash.com/v4/flow/
|
|
73
71
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
72
|
exports.basePipe = basePipe;
|
|
77
73
|
const pipe = basePipe();
|
|
78
74
|
var _default = pipe;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["basePipe","reverse","funcs","args","functions","flat","reduce","prev","func","exports","pipe","_default","default"],"sources":["@wordpress/compose/src/higher-order/pipe.ts"],"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://docs-lodash.com/v4/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://docs-lodash.com/v4/flow/\n */\nconst pipe = basePipe();\n\nexport { basePipe };\n\nexport default pipe;\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,QAAQ,GACbA,CAAEC,OAAgB,GAAG,KAAK,KAC1B,CAAE,GAAGC,KAAiB,KACtB,CAAE,GAAGC,IAAe,KAAM;EACzB,MAAMC,SAAS,GAAGF,KAAK,CAACG,IAAI,CAAC,CAAC;EAC9B,IAAKJ,OAAO,EAAG;IACdG,SAAS,CAACH,OAAO,CAAC,CAAC;EACpB;EACA,OAAOG,SAAS,CAACE,MAAM,CACtB,CAAEC,IAAI,EAAEC,IAAI,KAAM,CAAEA,IAAI,CAAE,GAAGD,IAAK,CAAC,CAAE,EACrCJ,IACD,CAAC,CAAE,CAAC,CAAE;AACP,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAM,OAAA,CAAAT,QAAA,GAAAA,QAAA;AAQA,MAAMU,IAAI,GAAGV,QAAQ,CAAC,CAAC;AAAC,IAAAW,QAAA,GAITD,IAAI;AAAAD,OAAA,CAAAG,OAAA,GAAAD,QAAA"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
9
|
var _isShallowEqual = _interopRequireDefault(require("@wordpress/is-shallow-equal"));
|
|
13
|
-
|
|
14
10
|
var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* External dependencies
|
|
18
13
|
*/
|
|
@@ -35,20 +30,17 @@ const pure = (0, _createHigherOrderComponent.createHigherOrderComponent)(functio
|
|
|
35
30
|
shouldComponentUpdate(nextProps, nextState) {
|
|
36
31
|
return !(0, _isShallowEqual.default)(nextProps, this.props) || !(0, _isShallowEqual.default)(nextState, this.state);
|
|
37
32
|
}
|
|
38
|
-
|
|
39
33
|
};
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
return class extends _element.Component {
|
|
43
36
|
shouldComponentUpdate(nextProps) {
|
|
44
37
|
return !(0, _isShallowEqual.default)(nextProps, this.props);
|
|
45
38
|
}
|
|
46
|
-
|
|
47
39
|
render() {
|
|
48
|
-
return (0, _element.createElement)(WrappedComponent, {
|
|
40
|
+
return (0, _element.createElement)(WrappedComponent, {
|
|
41
|
+
...this.props
|
|
49
42
|
});
|
|
50
43
|
}
|
|
51
|
-
|
|
52
44
|
};
|
|
53
45
|
}, 'pure');
|
|
54
46
|
var _default = pure;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_isShallowEqual","_interopRequireDefault","_createHigherOrderComponent","pure","createHigherOrderComponent","WrappedComponent","prototype","Component","shouldComponentUpdate","nextProps","nextState","isShallowEqual","props","state","render","createElement","_default","exports","default"],"sources":["@wordpress/compose/src/higher-order/pure/index.tsx"],"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"],"mappings":";;;;;;;AASA,IAAAA,QAAA,GAAAC,OAAA;AADA,IAAAC,eAAA,GAAAC,sBAAA,CAAAF,OAAA;AAMA,IAAAG,2BAAA,GAAAH,OAAA;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA,MAAMI,IAAI,GAAG,IAAAC,sDAA0B,EAAE,UACxCC,gBAAwC,EACf;EACzB,IAAKA,gBAAgB,CAACC,SAAS,YAAYC,kBAAS,EAAG;IACtD,OAAO,cAAgBF,gBAAgB,CAA8B;MACpEG,qBAAqBA,CAAEC,SAAgB,EAAEC,SAAc,EAAG;QACzD,OACC,CAAE,IAAAC,uBAAc,EAAEF,SAAS,EAAE,IAAI,CAACG,KAAM,CAAC,IACzC,CAAE,IAAAD,uBAAc,EAAED,SAAS,EAAE,IAAI,CAACG,KAAM,CAAC;MAE3C;IACD,CAAC;EACF;EAEA,OAAO,cAAcN,kBAAS,CAAU;IACvCC,qBAAqBA,CAAEC,SAAgB,EAAG;MACzC,OAAO,CAAE,IAAAE,uBAAc,EAAEF,SAAS,EAAE,IAAI,CAACG,KAAM,CAAC;IACjD;IAEAE,MAAMA,CAAA,EAAG;MACR,OAAO,IAAAhB,QAAA,CAAAiB,aAAA,EAACV,gBAAgB;QAAA,GAAM,IAAI,CAACO;MAAK,CAAI,CAAC;IAC9C;EACD,CAAC;AACF,CAAC,EACD,MAAO,CAAC;AAAC,IAAAI,QAAA,GAEMb,IAAI;AAAAc,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = withGlobalEvents;
|
|
9
|
-
|
|
10
8
|
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
9
|
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
13
|
-
|
|
14
10
|
var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
|
|
15
|
-
|
|
16
11
|
var _listener = _interopRequireDefault(require("./listener"));
|
|
17
|
-
|
|
18
12
|
/**
|
|
19
13
|
* WordPress dependencies
|
|
20
14
|
*/
|
|
@@ -27,8 +21,8 @@ var _listener = _interopRequireDefault(require("./listener"));
|
|
|
27
21
|
* Listener instance responsible for managing document event handling.
|
|
28
22
|
*/
|
|
29
23
|
const listener = new _listener.default();
|
|
30
|
-
/* eslint-disable jsdoc/no-undefined-types */
|
|
31
24
|
|
|
25
|
+
/* eslint-disable jsdoc/no-undefined-types */
|
|
32
26
|
/**
|
|
33
27
|
* Higher-order component creator which, given an object of DOM event types and
|
|
34
28
|
* values corresponding to a callback function name on the component, will
|
|
@@ -48,69 +42,56 @@ const listener = new _listener.default();
|
|
|
48
42
|
*
|
|
49
43
|
* @return {any} Higher-order component.
|
|
50
44
|
*/
|
|
51
|
-
|
|
52
45
|
function withGlobalEvents(eventTypesToHandlers) {
|
|
53
46
|
(0, _deprecated.default)('wp.compose.withGlobalEvents', {
|
|
54
47
|
since: '5.7',
|
|
55
48
|
alternative: 'useEffect'
|
|
56
|
-
});
|
|
49
|
+
});
|
|
57
50
|
|
|
51
|
+
// @ts-ignore We don't need to fix the type-related issues because this is deprecated.
|
|
58
52
|
return (0, _createHigherOrderComponent.createHigherOrderComponent)(WrappedComponent => {
|
|
59
53
|
class Wrapper extends _element.Component {
|
|
60
|
-
constructor(
|
|
61
|
-
/** @type {any} */
|
|
62
|
-
props) {
|
|
54
|
+
constructor( /** @type {any} */props) {
|
|
63
55
|
super(props);
|
|
64
56
|
this.handleEvent = this.handleEvent.bind(this);
|
|
65
57
|
this.handleRef = this.handleRef.bind(this);
|
|
66
58
|
}
|
|
67
|
-
|
|
68
59
|
componentDidMount() {
|
|
69
60
|
Object.keys(eventTypesToHandlers).forEach(eventType => {
|
|
70
61
|
listener.add(eventType, this);
|
|
71
62
|
});
|
|
72
63
|
}
|
|
73
|
-
|
|
74
64
|
componentWillUnmount() {
|
|
75
65
|
Object.keys(eventTypesToHandlers).forEach(eventType => {
|
|
76
66
|
listener.remove(eventType, this);
|
|
77
67
|
});
|
|
78
68
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
/** @type {any} */
|
|
82
|
-
event) {
|
|
83
|
-
const handler = eventTypesToHandlers[
|
|
84
|
-
/** @type {keyof GlobalEventHandlersEventMap} */
|
|
69
|
+
handleEvent( /** @type {any} */event) {
|
|
70
|
+
const handler = eventTypesToHandlers[/** @type {keyof GlobalEventHandlersEventMap} */
|
|
85
71
|
event.type
|
|
86
|
-
|
|
87
|
-
];
|
|
72
|
+
|
|
73
|
+
/* eslint-enable jsdoc/no-undefined-types */];
|
|
88
74
|
|
|
89
75
|
if (typeof this.wrappedRef[handler] === 'function') {
|
|
90
76
|
this.wrappedRef[handler](event);
|
|
91
77
|
}
|
|
92
78
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
el) {
|
|
97
|
-
this.wrappedRef = el; // Any component using `withGlobalEvents` that is not setting a `ref`
|
|
79
|
+
handleRef( /** @type {any} */el) {
|
|
80
|
+
this.wrappedRef = el;
|
|
81
|
+
// Any component using `withGlobalEvents` that is not setting a `ref`
|
|
98
82
|
// will cause `this.props.forwardedRef` to be `null`, so we need this
|
|
99
83
|
// check.
|
|
100
|
-
|
|
101
84
|
if (this.props.forwardedRef) {
|
|
102
85
|
this.props.forwardedRef(el);
|
|
103
86
|
}
|
|
104
87
|
}
|
|
105
|
-
|
|
106
88
|
render() {
|
|
107
|
-
return (0, _element.createElement)(WrappedComponent, {
|
|
89
|
+
return (0, _element.createElement)(WrappedComponent, {
|
|
90
|
+
...this.props.ownProps,
|
|
108
91
|
ref: this.handleRef
|
|
109
92
|
});
|
|
110
93
|
}
|
|
111
|
-
|
|
112
94
|
}
|
|
113
|
-
|
|
114
95
|
return (0, _element.forwardRef)((props, ref) => {
|
|
115
96
|
return (0, _element.createElement)(Wrapper, {
|
|
116
97
|
ownProps: props,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_deprecated","_interopRequireDefault","_createHigherOrderComponent","_listener","listener","Listener","withGlobalEvents","eventTypesToHandlers","deprecated","since","alternative","createHigherOrderComponent","WrappedComponent","Wrapper","Component","constructor","props","handleEvent","bind","handleRef","componentDidMount","Object","keys","forEach","eventType","add","componentWillUnmount","remove","event","handler","type","wrappedRef","el","forwardedRef","render","createElement","ownProps","ref","forwardRef"],"sources":["@wordpress/compose/src/higher-order/with-global-events/index.js"],"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"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,2BAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAF,sBAAA,CAAAF,OAAA;AAVA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA,MAAMK,QAAQ,GAAG,IAAIC,iBAAQ,CAAC,CAAC;;AAE/B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,gBAAgBA,CAAEC,oBAAoB,EAAG;EAChE,IAAAC,mBAAU,EAAE,6BAA6B,EAAE;IAC1CC,KAAK,EAAE,KAAK;IACZC,WAAW,EAAE;EACd,CAAE,CAAC;;EAEH;EACA,OAAO,IAAAC,sDAA0B,EAAIC,gBAAgB,IAAM;IAC1D,MAAMC,OAAO,SAASC,kBAAS,CAAC;MAC/BC,WAAWA,CAAA,CAAE,kBAAmBC,KAAK,EAAG;QACvC,KAAK,CAAEA,KAAM,CAAC;QAEd,IAAI,CAACC,WAAW,GAAG,IAAI,CAACA,WAAW,CAACC,IAAI,CAAE,IAAK,CAAC;QAChD,IAAI,CAACC,SAAS,GAAG,IAAI,CAACA,SAAS,CAACD,IAAI,CAAE,IAAK,CAAC;MAC7C;MAEAE,iBAAiBA,CAAA,EAAG;QACnBC,MAAM,CAACC,IAAI,CAAEf,oBAAqB,CAAC,CAACgB,OAAO,CAAIC,SAAS,IAAM;UAC7DpB,QAAQ,CAACqB,GAAG,CAAED,SAAS,EAAE,IAAK,CAAC;QAChC,CAAE,CAAC;MACJ;MAEAE,oBAAoBA,CAAA,EAAG;QACtBL,MAAM,CAACC,IAAI,CAAEf,oBAAqB,CAAC,CAACgB,OAAO,CAAIC,SAAS,IAAM;UAC7DpB,QAAQ,CAACuB,MAAM,CAAEH,SAAS,EAAE,IAAK,CAAC;QACnC,CAAE,CAAC;MACJ;MAEAP,WAAWA,CAAA,CAAE,kBAAmBW,KAAK,EAAG;QACvC,MAAMC,OAAO,GACZtB,oBAAoB,CACnB;QACCqB,KAAK,CAACE;;QAEP,6CACA;;QACF,IAAK,OAAO,IAAI,CAACC,UAAU,CAAEF,OAAO,CAAE,KAAK,UAAU,EAAG;UACvD,IAAI,CAACE,UAAU,CAAEF,OAAO,CAAE,CAAED,KAAM,CAAC;QACpC;MACD;MAEAT,SAASA,CAAA,CAAE,kBAAmBa,EAAE,EAAG;QAClC,IAAI,CAACD,UAAU,GAAGC,EAAE;QACpB;QACA;QACA;QACA,IAAK,IAAI,CAAChB,KAAK,CAACiB,YAAY,EAAG;UAC9B,IAAI,CAACjB,KAAK,CAACiB,YAAY,CAAED,EAAG,CAAC;QAC9B;MACD;MAEAE,MAAMA,CAAA,EAAG;QACR,OACC,IAAApC,QAAA,CAAAqC,aAAA,EAACvB,gBAAgB;UAAA,GACX,IAAI,CAACI,KAAK,CAACoB,QAAQ;UACxBC,GAAG,EAAG,IAAI,CAAClB;QAAW,CACtB,CAAC;MAEJ;IACD;IAEA,OAAO,IAAAmB,mBAAU,EAAE,CAAEtB,KAAK,EAAEqB,GAAG,KAAM;MACpC,OAAO,IAAAvC,QAAA,CAAAqC,aAAA,EAACtB,OAAO;QAACuB,QAAQ,EAAGpB,KAAO;QAACiB,YAAY,EAAGI;MAAK,CAAE,CAAC;IAC3D,CAAE,CAAC;EACJ,CAAC,EAAE,kBAAmB,CAAC;AACxB"}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
/**
|
|
9
8
|
* Class responsible for orchestrating event handling on the global window,
|
|
10
9
|
* binding a single event to be shared across all handling instances, and
|
|
@@ -16,53 +15,31 @@ class Listener {
|
|
|
16
15
|
this.listeners = {};
|
|
17
16
|
this.handleEvent = this.handleEvent.bind(this);
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
add(
|
|
21
|
-
/** @type {any} */
|
|
22
|
-
eventType,
|
|
23
|
-
/** @type {any} */
|
|
24
|
-
instance) {
|
|
18
|
+
add( /** @type {any} */eventType, /** @type {any} */instance) {
|
|
25
19
|
if (!this.listeners[eventType]) {
|
|
26
20
|
// Adding first listener for this type, so bind event.
|
|
27
21
|
window.addEventListener(eventType, this.handleEvent);
|
|
28
22
|
this.listeners[eventType] = [];
|
|
29
23
|
}
|
|
30
|
-
|
|
31
24
|
this.listeners[eventType].push(instance);
|
|
32
25
|
}
|
|
33
|
-
|
|
34
|
-
remove(
|
|
35
|
-
/** @type {any} */
|
|
36
|
-
eventType,
|
|
37
|
-
/** @type {any} */
|
|
38
|
-
instance) {
|
|
26
|
+
remove( /** @type {any} */eventType, /** @type {any} */instance) {
|
|
39
27
|
if (!this.listeners[eventType]) {
|
|
40
28
|
return;
|
|
41
29
|
}
|
|
42
|
-
|
|
43
|
-
this.listeners[eventType] = this.listeners[eventType].filter((
|
|
44
|
-
/** @type {any} */
|
|
45
|
-
listener) => listener !== instance);
|
|
46
|
-
|
|
30
|
+
this.listeners[eventType] = this.listeners[eventType].filter(( /** @type {any} */listener) => listener !== instance);
|
|
47
31
|
if (!this.listeners[eventType].length) {
|
|
48
32
|
// Removing last listener for this type, so unbind event.
|
|
49
33
|
window.removeEventListener(eventType, this.handleEvent);
|
|
50
34
|
delete this.listeners[eventType];
|
|
51
35
|
}
|
|
52
36
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
/** @type {any} */
|
|
56
|
-
event) {
|
|
57
|
-
this.listeners[event.type]?.forEach((
|
|
58
|
-
/** @type {any} */
|
|
59
|
-
instance) => {
|
|
37
|
+
handleEvent( /** @type {any} */event) {
|
|
38
|
+
this.listeners[event.type]?.forEach(( /** @type {any} */instance) => {
|
|
60
39
|
instance.handleEvent(event);
|
|
61
40
|
});
|
|
62
41
|
}
|
|
63
|
-
|
|
64
42
|
}
|
|
65
|
-
|
|
66
43
|
var _default = Listener;
|
|
67
44
|
exports.default = _default;
|
|
68
45
|
//# sourceMappingURL=listener.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["Listener","constructor","listeners","handleEvent","bind","add","eventType","instance","window","addEventListener","push","remove","filter","listener","length","removeEventListener","event","type","forEach","_default","exports","default"],"sources":["@wordpress/compose/src/higher-order/with-global-events/listener.js"],"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"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA,MAAMA,QAAQ,CAAC;EACdC,WAAWA,CAAA,EAAG;IACb;IACA,IAAI,CAACC,SAAS,GAAG,CAAC,CAAC;IAEnB,IAAI,CAACC,WAAW,GAAG,IAAI,CAACA,WAAW,CAACC,IAAI,CAAE,IAAK,CAAC;EACjD;EAEAC,GAAGA,CAAA,CAAE,kBAAmBC,SAAS,EAAE,kBAAmBC,QAAQ,EAAG;IAChE,IAAK,CAAE,IAAI,CAACL,SAAS,CAAEI,SAAS,CAAE,EAAG;MACpC;MACAE,MAAM,CAACC,gBAAgB,CAAEH,SAAS,EAAE,IAAI,CAACH,WAAY,CAAC;MACtD,IAAI,CAACD,SAAS,CAAEI,SAAS,CAAE,GAAG,EAAE;IACjC;IAEA,IAAI,CAACJ,SAAS,CAAEI,SAAS,CAAE,CAACI,IAAI,CAAEH,QAAS,CAAC;EAC7C;EAEAI,MAAMA,CAAA,CAAE,kBAAmBL,SAAS,EAAE,kBAAmBC,QAAQ,EAAG;IACnE,IAAK,CAAE,IAAI,CAACL,SAAS,CAAEI,SAAS,CAAE,EAAG;MACpC;IACD;IAEA,IAAI,CAACJ,SAAS,CAAEI,SAAS,CAAE,GAAG,IAAI,CAACJ,SAAS,CAAEI,SAAS,CAAE,CAACM,MAAM,CAC/D,EAAE,kBAAmBC,QAAQ,KAAMA,QAAQ,KAAKN,QACjD,CAAC;IAED,IAAK,CAAE,IAAI,CAACL,SAAS,CAAEI,SAAS,CAAE,CAACQ,MAAM,EAAG;MAC3C;MACAN,MAAM,CAACO,mBAAmB,CAAET,SAAS,EAAE,IAAI,CAACH,WAAY,CAAC;MACzD,OAAO,IAAI,CAACD,SAAS,CAAEI,SAAS,CAAE;IACnC;EACD;EAEAH,WAAWA,CAAA,CAAE,kBAAmBa,KAAK,EAAG;IACvC,IAAI,CAACd,SAAS,CAAEc,KAAK,CAACC,IAAI,CAAE,EAAEC,OAAO,CACpC,EAAE,kBAAmBX,QAAQ,KAAM;MAClCA,QAAQ,CAACJ,WAAW,CAAEa,KAAM,CAAC;IAC9B,CACD,CAAC;EACF;AACD;AAAC,IAAAG,QAAA,GAEcnB,QAAQ;AAAAoB,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
9
|
var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
|
|
13
|
-
|
|
14
10
|
var _useInstanceId = _interopRequireDefault(require("../../hooks/use-instance-id"));
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* Internal dependencies
|
|
18
13
|
*/
|
|
@@ -23,9 +18,10 @@ var _useInstanceId = _interopRequireDefault(require("../../hooks/use-instance-id
|
|
|
23
18
|
*/
|
|
24
19
|
const withInstanceId = (0, _createHigherOrderComponent.createHigherOrderComponent)(WrappedComponent => {
|
|
25
20
|
return props => {
|
|
26
|
-
const instanceId = (0, _useInstanceId.default)(WrappedComponent);
|
|
27
|
-
|
|
28
|
-
return (0, _element.createElement)(WrappedComponent, {
|
|
21
|
+
const instanceId = (0, _useInstanceId.default)(WrappedComponent);
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
return (0, _element.createElement)(WrappedComponent, {
|
|
24
|
+
...props,
|
|
29
25
|
instanceId: instanceId
|
|
30
26
|
});
|
|
31
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_createHigherOrderComponent","require","_useInstanceId","_interopRequireDefault","withInstanceId","createHigherOrderComponent","WrappedComponent","props","instanceId","useInstanceId","_element","createElement","_default","exports","default"],"sources":["@wordpress/compose/src/higher-order/with-instance-id/index.tsx"],"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 be provide a unique instance ID by\n * 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"],"mappings":";;;;;;;;AAOA,IAAAA,2BAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAC,sBAAA,CAAAF,OAAA;AARA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA,MAAMG,cAAc,GAAG,IAAAC,sDAA0B,EAE/CC,gBAAmB,IACf;EACJ,OAASC,KAAiD,IAAM;IAC/D,MAAMC,UAAU,GAAG,IAAAC,sBAAa,EAAEH,gBAAiB,CAAC;IACpD;IACA,OAAO,IAAAI,QAAA,CAAAC,aAAA,EAACL,gBAAgB;MAAA,GAAMC,KAAK;MAAGC,UAAU,EAAGA;IAAY,CAAE,CAAC;EACnE,CAAC;AACF,CAAC,EACD,YACD,CAAC;AAAC,IAAAI,QAAA,GAEaR,cAAc;AAAAS,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
9
|
var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
|
|
13
|
-
|
|
14
10
|
var _usePreferredColorScheme = _interopRequireDefault(require("../../hooks/use-preferred-color-scheme"));
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* Internal dependencies
|
|
18
13
|
*/
|
|
@@ -20,11 +15,13 @@ var _usePreferredColorScheme = _interopRequireDefault(require("../../hooks/use-p
|
|
|
20
15
|
/**
|
|
21
16
|
* WordPress dependencies
|
|
22
17
|
*/
|
|
18
|
+
|
|
23
19
|
const withPreferredColorScheme = (0, _createHigherOrderComponent.createHigherOrderComponent)(WrappedComponent => props => {
|
|
24
20
|
const colorScheme = (0, _usePreferredColorScheme.default)();
|
|
25
21
|
const isDarkMode = colorScheme === 'dark';
|
|
26
22
|
const getStyles = (0, _element.useCallback)((lightStyles, darkStyles) => {
|
|
27
|
-
const finalDarkStyles = {
|
|
23
|
+
const finalDarkStyles = {
|
|
24
|
+
...lightStyles,
|
|
28
25
|
...darkStyles
|
|
29
26
|
};
|
|
30
27
|
return isDarkMode ? finalDarkStyles : lightStyles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_createHigherOrderComponent","_usePreferredColorScheme","_interopRequireDefault","withPreferredColorScheme","createHigherOrderComponent","WrappedComponent","props","colorScheme","usePreferredColorScheme","isDarkMode","getStyles","useCallback","lightStyles","darkStyles","finalDarkStyles","createElement","preferredColorScheme","getStylesFromColorScheme","_default","exports","default"],"sources":["@wordpress/compose/src/higher-order/with-preferred-color-scheme/index.native.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\nimport usePreferredColorScheme from '../../hooks/use-preferred-color-scheme';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\n\nconst withPreferredColorScheme = createHigherOrderComponent(\n\t( WrappedComponent ) => ( props ) => {\n\t\tconst colorScheme = usePreferredColorScheme();\n\t\tconst isDarkMode = colorScheme === 'dark';\n\n\t\tconst getStyles = useCallback(\n\t\t\t( lightStyles, darkStyles ) => {\n\t\t\t\tconst finalDarkStyles = {\n\t\t\t\t\t...lightStyles,\n\t\t\t\t\t...darkStyles,\n\t\t\t\t};\n\n\t\t\t\treturn isDarkMode ? finalDarkStyles : lightStyles;\n\t\t\t},\n\t\t\t[ isDarkMode ]\n\t\t);\n\n\t\treturn (\n\t\t\t<WrappedComponent\n\t\t\t\tpreferredColorScheme={ colorScheme }\n\t\t\t\tgetStylesFromColorScheme={ getStyles }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t);\n\t},\n\t'withPreferredColorScheme'\n);\n\nexport default withPreferredColorScheme;\n"],"mappings":";;;;;;;AASA,IAAAA,QAAA,GAAAC,OAAA;AANA,IAAAC,2BAAA,GAAAD,OAAA;AACA,IAAAE,wBAAA,GAAAC,sBAAA,CAAAH,OAAA;AAJA;AACA;AACA;;AAIA;AACA;AACA;;AAGA,MAAMI,wBAAwB,GAAG,IAAAC,sDAA0B,EACxDC,gBAAgB,IAAQC,KAAK,IAAM;EACpC,MAAMC,WAAW,GAAG,IAAAC,gCAAuB,EAAC,CAAC;EAC7C,MAAMC,UAAU,GAAGF,WAAW,KAAK,MAAM;EAEzC,MAAMG,SAAS,GAAG,IAAAC,oBAAW,EAC5B,CAAEC,WAAW,EAAEC,UAAU,KAAM;IAC9B,MAAMC,eAAe,GAAG;MACvB,GAAGF,WAAW;MACd,GAAGC;IACJ,CAAC;IAED,OAAOJ,UAAU,GAAGK,eAAe,GAAGF,WAAW;EAClD,CAAC,EACD,CAAEH,UAAU,CACb,CAAC;EAED,OACC,IAAAX,QAAA,CAAAiB,aAAA,EAACV,gBAAgB;IAChBW,oBAAoB,EAAGT,WAAa;IACpCU,wBAAwB,EAAGP,SAAW;IAAA,GACjCJ;EAAK,CACV,CAAC;AAEJ,CAAC,EACD,0BACD,CAAC;AAAC,IAAAY,QAAA,GAEaf,wBAAwB;AAAAgB,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -4,19 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
8
|
var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
|
|
11
|
-
|
|
12
9
|
/**
|
|
13
10
|
* WordPress dependencies
|
|
14
11
|
*/
|
|
15
12
|
|
|
16
|
-
/**
|
|
17
|
-
* Internal dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
13
|
/**
|
|
21
14
|
* A higher-order component used to provide and manage delayed function calls
|
|
22
15
|
* that ought to be bound to a component's lifecycle.
|
|
@@ -29,11 +22,9 @@ const withSafeTimeout = (0, _createHigherOrderComponent.createHigherOrderCompone
|
|
|
29
22
|
this.setTimeout = this.setTimeout.bind(this);
|
|
30
23
|
this.clearTimeout = this.clearTimeout.bind(this);
|
|
31
24
|
}
|
|
32
|
-
|
|
33
25
|
componentWillUnmount() {
|
|
34
26
|
this.timeouts.forEach(clearTimeout);
|
|
35
27
|
}
|
|
36
|
-
|
|
37
28
|
setTimeout(fn, delay) {
|
|
38
29
|
const id = setTimeout(() => {
|
|
39
30
|
fn();
|
|
@@ -42,21 +33,20 @@ const withSafeTimeout = (0, _createHigherOrderComponent.createHigherOrderCompone
|
|
|
42
33
|
this.timeouts.push(id);
|
|
43
34
|
return id;
|
|
44
35
|
}
|
|
45
|
-
|
|
46
36
|
clearTimeout(id) {
|
|
47
37
|
clearTimeout(id);
|
|
48
38
|
this.timeouts = this.timeouts.filter(timeoutId => timeoutId !== id);
|
|
49
39
|
}
|
|
50
|
-
|
|
51
40
|
render() {
|
|
52
|
-
return (
|
|
53
|
-
|
|
41
|
+
return (
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
(0, _element.createElement)(OriginalComponent, {
|
|
44
|
+
...this.props,
|
|
54
45
|
setTimeout: this.setTimeout,
|
|
55
46
|
clearTimeout: this.clearTimeout
|
|
56
47
|
})
|
|
57
48
|
);
|
|
58
49
|
}
|
|
59
|
-
|
|
60
50
|
};
|
|
61
51
|
}, 'withSafeTimeout');
|
|
62
52
|
var _default = withSafeTimeout;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"names":["_element","require","_createHigherOrderComponent","withSafeTimeout","createHigherOrderComponent","OriginalComponent","WrappedComponent","Component","constructor","props","timeouts","setTimeout","bind","clearTimeout","componentWillUnmount","forEach","fn","delay","id","push","filter","timeoutId","render","createElement","_default","exports","default"],"sources":["@wordpress/compose/src/higher-order/with-safe-timeout/index.tsx"],"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"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AASA,IAAAC,2BAAA,GAAAD,OAAA;AAZA;AACA;AACA;;AAyBA;AACA;AACA;AACA;AACA,MAAME,eAAe,GAAG,IAAAC,sDAA0B,EAEhDC,iBAAoB,IAChB;EAEJ,OAAO,MAAMC,gBAAgB,SAASC,kBAAS,CAAiB;IAG/DC,WAAWA,CAAEC,KAAmB,EAAG;MAClC,KAAK,CAAEA,KAAM,CAAC;MACd,IAAI,CAACC,QAAQ,GAAG,EAAE;MAClB,IAAI,CAACC,UAAU,GAAG,IAAI,CAACA,UAAU,CAACC,IAAI,CAAE,IAAK,CAAC;MAC9C,IAAI,CAACC,YAAY,GAAG,IAAI,CAACA,YAAY,CAACD,IAAI,CAAE,IAAK,CAAC;IACnD;IAEAE,oBAAoBA,CAAA,EAAG;MACtB,IAAI,CAACJ,QAAQ,CAACK,OAAO,CAAEF,YAAa,CAAC;IACtC;IAEAF,UAAUA,CAAEK,EAAc,EAAEC,KAAa,EAAG;MAC3C,MAAMC,EAAE,GAAGP,UAAU,CAAE,MAAM;QAC5BK,EAAE,CAAC,CAAC;QACJ,IAAI,CAACH,YAAY,CAAEK,EAAG,CAAC;MACxB,CAAC,EAAED,KAAM,CAAC;MACV,IAAI,CAACP,QAAQ,CAACS,IAAI,CAAED,EAAG,CAAC;MACxB,OAAOA,EAAE;IACV;IAEAL,YAAYA,CAAEK,EAAU,EAAG;MAC1BL,YAAY,CAAEK,EAAG,CAAC;MAClB,IAAI,CAACR,QAAQ,GAAG,IAAI,CAACA,QAAQ,CAACU,MAAM,CACjCC,SAAS,IAAMA,SAAS,KAAKH,EAChC,CAAC;IACF;IAEAI,MAAMA,CAAA,EAAG;MACR;QACC;QACA,IAAAtB,QAAA,CAAAuB,aAAA,EAAClB,iBAAiB;UAAA,GACZ,IAAI,CAACI,KAAK;UACfE,UAAU,EAAG,IAAI,CAACA,UAAY;UAC9BE,YAAY,EAAG,IAAI,CAACA;QAAc,CAClC;MAAC;IAEJ;EACD,CAAC;AACF,CAAC,EACD,iBACD,CAAC;AAAC,IAAAW,QAAA,GAEarB,eAAe;AAAAsB,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = withState;
|
|
9
|
-
|
|
10
8
|
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
9
|
var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
|
|
13
|
-
|
|
14
10
|
var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* WordPress dependencies
|
|
18
13
|
*/
|
|
@@ -38,21 +33,18 @@ function withState(initialState = {}) {
|
|
|
38
33
|
});
|
|
39
34
|
return (0, _createHigherOrderComponent.createHigherOrderComponent)(OriginalComponent => {
|
|
40
35
|
return class WrappedComponent extends _element.Component {
|
|
41
|
-
constructor(
|
|
42
|
-
/** @type {any} */
|
|
43
|
-
props) {
|
|
36
|
+
constructor( /** @type {any} */props) {
|
|
44
37
|
super(props);
|
|
45
38
|
this.setState = this.setState.bind(this);
|
|
46
39
|
this.state = initialState;
|
|
47
40
|
}
|
|
48
|
-
|
|
49
41
|
render() {
|
|
50
|
-
return (0, _element.createElement)(OriginalComponent, {
|
|
42
|
+
return (0, _element.createElement)(OriginalComponent, {
|
|
43
|
+
...this.props,
|
|
51
44
|
...this.state,
|
|
52
45
|
setState: this.setState
|
|
53
46
|
});
|
|
54
47
|
}
|
|
55
|
-
|
|
56
48
|
};
|
|
57
49
|
}, 'withState');
|
|
58
50
|
}
|