@wordpress/compose 6.34.0 → 7.0.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +6 -6
  3. package/build/higher-order/compose.js +1 -1
  4. package/build/higher-order/compose.js.map +1 -1
  5. package/build/higher-order/if-condition/index.js +3 -4
  6. package/build/higher-order/if-condition/index.js.map +1 -1
  7. package/build/higher-order/pipe.js +2 -2
  8. package/build/higher-order/pipe.js.map +1 -1
  9. package/build/higher-order/pure/index.js +3 -4
  10. package/build/higher-order/pure/index.js.map +1 -1
  11. package/build/higher-order/with-global-events/index.js +4 -5
  12. package/build/higher-order/with-global-events/index.js.map +1 -1
  13. package/build/higher-order/with-instance-id/index.js +2 -2
  14. package/build/higher-order/with-instance-id/index.js.map +1 -1
  15. package/build/higher-order/with-network-connectivity/index.native.js +2 -2
  16. package/build/higher-order/with-network-connectivity/index.native.js.map +1 -1
  17. package/build/higher-order/with-preferred-color-scheme/index.native.js +2 -2
  18. package/build/higher-order/with-preferred-color-scheme/index.native.js.map +1 -1
  19. package/build/higher-order/with-safe-timeout/index.js +3 -2
  20. package/build/higher-order/with-safe-timeout/index.js.map +1 -1
  21. package/build/higher-order/with-state/index.js +3 -4
  22. package/build/higher-order/with-state/index.js.map +1 -1
  23. package/build/hooks/use-debounce/index.js +1 -1
  24. package/build/hooks/use-debounce/index.js.map +1 -1
  25. package/build/hooks/use-debounced-input/index.js +3 -3
  26. package/build/hooks/use-debounced-input/index.js.map +1 -1
  27. package/build/hooks/use-focus-on-mount/index.js +12 -8
  28. package/build/hooks/use-focus-on-mount/index.js.map +1 -1
  29. package/build/hooks/use-resize-observer/index.js +2 -2
  30. package/build/hooks/use-resize-observer/index.js.map +1 -1
  31. package/build/hooks/use-resize-observer/index.native.js +3 -4
  32. package/build/hooks/use-resize-observer/index.native.js.map +1 -1
  33. package/build/hooks/use-throttle/index.js +1 -1
  34. package/build/hooks/use-throttle/index.js.map +1 -1
  35. package/build-module/higher-order/compose.js +1 -1
  36. package/build-module/higher-order/compose.js.map +1 -1
  37. package/build-module/higher-order/if-condition/index.js +2 -2
  38. package/build-module/higher-order/if-condition/index.js.map +1 -1
  39. package/build-module/higher-order/pipe.js +2 -2
  40. package/build-module/higher-order/pipe.js.map +1 -1
  41. package/build-module/higher-order/pure/index.js +2 -2
  42. package/build-module/higher-order/pure/index.js.map +1 -1
  43. package/build-module/higher-order/with-global-events/index.js +3 -3
  44. package/build-module/higher-order/with-global-events/index.js.map +1 -1
  45. package/build-module/higher-order/with-instance-id/index.js +2 -2
  46. package/build-module/higher-order/with-instance-id/index.js.map +1 -1
  47. package/build-module/higher-order/with-network-connectivity/index.native.js +2 -2
  48. package/build-module/higher-order/with-network-connectivity/index.native.js.map +1 -1
  49. package/build-module/higher-order/with-preferred-color-scheme/index.native.js +2 -2
  50. package/build-module/higher-order/with-preferred-color-scheme/index.native.js.map +1 -1
  51. package/build-module/higher-order/with-safe-timeout/index.js +3 -3
  52. package/build-module/higher-order/with-safe-timeout/index.js.map +1 -1
  53. package/build-module/higher-order/with-state/index.js +2 -2
  54. package/build-module/higher-order/with-state/index.js.map +1 -1
  55. package/build-module/hooks/use-debounce/index.js +1 -1
  56. package/build-module/hooks/use-debounce/index.js.map +1 -1
  57. package/build-module/hooks/use-debounced-input/index.js +3 -3
  58. package/build-module/hooks/use-debounced-input/index.js.map +1 -1
  59. package/build-module/hooks/use-focus-on-mount/index.js +12 -9
  60. package/build-module/hooks/use-focus-on-mount/index.js.map +1 -1
  61. package/build-module/hooks/use-resize-observer/index.js +2 -2
  62. package/build-module/hooks/use-resize-observer/index.js.map +1 -1
  63. package/build-module/hooks/use-resize-observer/index.native.js +2 -2
  64. package/build-module/hooks/use-resize-observer/index.native.js.map +1 -1
  65. package/build-module/hooks/use-throttle/index.js +1 -1
  66. package/build-module/hooks/use-throttle/index.js.map +1 -1
  67. package/build-types/higher-order/compose.d.ts +1 -1
  68. package/build-types/higher-order/if-condition/index.d.ts +1 -1
  69. package/build-types/higher-order/if-condition/index.d.ts.map +1 -1
  70. package/build-types/higher-order/pipe.d.ts +2 -2
  71. package/build-types/higher-order/with-instance-id/index.d.ts +1 -1
  72. package/build-types/higher-order/with-instance-id/index.d.ts.map +1 -1
  73. package/build-types/higher-order/with-safe-timeout/index.d.ts +1 -1
  74. package/build-types/hooks/use-debounce/index.d.ts +1 -1
  75. package/build-types/hooks/use-debounced-input/index.d.ts +3 -3
  76. package/build-types/hooks/use-debounced-input/index.d.ts.map +1 -1
  77. package/build-types/hooks/use-focus-on-mount/index.d.ts.map +1 -1
  78. package/build-types/hooks/use-throttle/index.d.ts +1 -1
  79. package/package.json +11 -10
  80. package/src/higher-order/compose.ts +1 -1
  81. package/src/higher-order/pipe.ts +2 -2
  82. package/src/hooks/use-debounce/index.js +1 -1
  83. package/src/hooks/use-debounced-input/{index.js → index.ts} +7 -5
  84. package/src/hooks/use-focus-on-mount/index.js +13 -10
  85. package/src/hooks/use-throttle/index.js +1 -1
  86. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 7.0.0 (2024-05-31)
6
+
7
+ ### Breaking Changes
8
+
9
+ - Increase the minimum required Node.js version to v18.12.0 matching long-term support releases ([#31270](https://github.com/WordPress/gutenberg/pull/61930)). Learn more about [Node.js releases](https://nodejs.org/en/about/previous-releases).
10
+
11
+ ## 6.35.0 (2024-05-16)
12
+
5
13
  ## 6.34.0 (2024-05-02)
6
14
 
7
15
  - Added new `observableMap` data structure and `useObservableValue` React hook ([#60945](https://github.com/WordPress/gutenberg/pull/60945)).
package/README.md CHANGED
@@ -69,7 +69,7 @@ This is inspired by `lodash`'s `flowRight` function.
69
69
 
70
70
  _Related_
71
71
 
72
- - <https://docs-lodash.com/v4/flow-right/>
72
+ - <https://lodash.com/docs/4#flow-right>
73
73
 
74
74
  ### createHigherOrderComponent
75
75
 
@@ -145,7 +145,7 @@ This is inspired by `lodash`'s `flow` function.
145
145
 
146
146
  _Related_
147
147
 
148
- - <https://docs-lodash.com/v4/flow/>
148
+ - <https://lodash.com/docs/4#flow>
149
149
 
150
150
  ### pure
151
151
 
@@ -247,7 +247,7 @@ Debounces a function similar to Lodash's `debounce`. A new debounced function wi
247
247
 
248
248
  _Related_
249
249
 
250
- - <https://docs-lodash.com/v4/debounce/>
250
+ - <https://lodash.com/docs/4#debounce>
251
251
 
252
252
  _Parameters_
253
253
 
@@ -265,11 +265,11 @@ Helper hook for input fields that need to debounce the value before using it.
265
265
 
266
266
  _Parameters_
267
267
 
268
- - _defaultValue_ `any`: The default value to use.
268
+ - _defaultValue_ The default value to use.
269
269
 
270
270
  _Returns_
271
271
 
272
- - `[string, Function, string]`: The input value, the setter and the debounced input value.
272
+ - `[ string, ( value: string ) => void, string ]`: The input value, the setter and the debounced input value.
273
273
 
274
274
  ### useDisabled
275
275
 
@@ -535,7 +535,7 @@ Throttles a function similar to Lodash's `throttle`. A new throttled function wi
535
535
 
536
536
  _Related_
537
537
 
538
- - <https://docs-lodash.com/v4/throttle/>
538
+ - <https://lodash.com/docs/4#throttle>
539
539
 
540
540
  _Parameters_
541
541
 
@@ -15,7 +15,7 @@ var _pipe = require("./pipe");
15
15
  *
16
16
  * This is inspired by `lodash`'s `flowRight` function.
17
17
  *
18
- * @see https://docs-lodash.com/v4/flow-right/
18
+ * @see https://lodash.com/docs/4#flow-right
19
19
  */
20
20
  const compose = (0, _pipe.basePipe)(true);
21
21
  var _default = exports.default = compose;
@@ -1 +1 @@
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,GAAAC,OAAA,CAAAC,OAAA,GAElBJ,OAAO","ignoreList":[]}
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://lodash.com/docs/4#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,GAAAC,OAAA,CAAAC,OAAA,GAElBJ,OAAO","ignoreList":[]}
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _react = require("react");
8
7
  var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
8
+ var _jsxRuntime = require("react/jsx-runtime");
9
9
  /**
10
10
  * External dependencies
11
11
  */
@@ -30,13 +30,12 @@ var _createHigherOrderComponent = require("../../utils/create-higher-order-compo
30
30
  * @param predicate Function to test condition.
31
31
  *
32
32
  * @return Higher-order component.
33
- */
34
- function ifCondition(predicate) {
33
+ */function ifCondition(predicate) {
35
34
  return (0, _createHigherOrderComponent.createHigherOrderComponent)(WrappedComponent => props => {
36
35
  if (!predicate(props)) {
37
36
  return null;
38
37
  }
39
- return (0, _react.createElement)(WrappedComponent, {
38
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, {
40
39
  ...props
41
40
  });
42
41
  }, 'ifCondition');
@@ -1 +1 @@
1
- {"version":3,"names":["_createHigherOrderComponent","require","ifCondition","predicate","createHigherOrderComponent","WrappedComponent","props","_react","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,MAAA,CAAAC,aAAA,EAACH,gBAAgB;MAAA,GAAMC;IAAK,CAAI,CAAC;EACzC,CAAC,EACD,aACD,CAAC;AACF;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcT,WAAW","ignoreList":[]}
1
+ {"version":3,"names":["_createHigherOrderComponent","require","_jsxRuntime","ifCondition","predicate","createHigherOrderComponent","WrappedComponent","props","jsx","_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;AAAuF,IAAAC,WAAA,GAAAD,OAAA;AARvF;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACA,SAASE,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,oBAAO,IAAAL,WAAA,CAAAM,GAAA,EAACF,gBAAgB;MAAA,GAAMC;IAAK,CAAI,CAAC;EACzC,CAAC,EACD,aACD,CAAC;AACF;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcR,WAAW","ignoreList":[]}
@@ -49,7 +49,7 @@ exports.default = exports.basePipe = void 0;
49
49
  *
50
50
  * Allows to choose whether to perform left-to-right or right-to-left composition.
51
51
  *
52
- * @see https://docs-lodash.com/v4/flow/
52
+ * @see https://lodash.com/docs/4#flow
53
53
  *
54
54
  * @param {boolean} reverse True if right-to-left, false for left-to-right composition.
55
55
  */
@@ -67,7 +67,7 @@ const basePipe = (reverse = false) => (...funcs) => (...args) => {
67
67
  *
68
68
  * This is inspired by `lodash`'s `flow` function.
69
69
  *
70
- * @see https://docs-lodash.com/v4/flow/
70
+ * @see https://lodash.com/docs/4#flow
71
71
  */
72
72
  exports.basePipe = basePipe;
73
73
  const pipe = basePipe();
@@ -1 +1 @@
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,GAAAF,OAAA,CAAAG,OAAA,GAITF,IAAI","ignoreList":[]}
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://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"],"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,GAAAF,OAAA,CAAAG,OAAA,GAITF,IAAI","ignoreList":[]}
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _react = require("react");
9
8
  var _isShallowEqual = _interopRequireDefault(require("@wordpress/is-shallow-equal"));
10
9
  var _element = require("@wordpress/element");
11
10
  var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
12
  /**
13
13
  * External dependencies
14
14
  */
@@ -26,8 +26,7 @@ var _createHigherOrderComponent = require("../../utils/create-higher-order-compo
26
26
  * only re-rendering when its props/state change
27
27
  *
28
28
  * @deprecated Use `memo` or `PureComponent` instead.
29
- */
30
- const pure = (0, _createHigherOrderComponent.createHigherOrderComponent)(function (WrappedComponent) {
29
+ */const pure = (0, _createHigherOrderComponent.createHigherOrderComponent)(function (WrappedComponent) {
31
30
  if (WrappedComponent.prototype instanceof _element.Component) {
32
31
  return class extends WrappedComponent {
33
32
  shouldComponentUpdate(nextProps, nextState) {
@@ -40,7 +39,7 @@ const pure = (0, _createHigherOrderComponent.createHigherOrderComponent)(functio
40
39
  return !(0, _isShallowEqual.default)(nextProps, this.props);
41
40
  }
42
41
  render() {
43
- return (0, _react.createElement)(WrappedComponent, {
42
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, {
44
43
  ...this.props
45
44
  });
46
45
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_isShallowEqual","_interopRequireDefault","require","_element","_createHigherOrderComponent","pure","createHigherOrderComponent","WrappedComponent","prototype","Component","shouldComponentUpdate","nextProps","nextState","isShallowEqual","props","state","render","_react","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 *\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"],"mappings":";;;;;;;;AAQA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,2BAAA,GAAAF,OAAA;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,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,IAAAC,MAAA,CAAAC,aAAA,EAACX,gBAAgB;QAAA,GAAM,IAAI,CAACO;MAAK,CAAI,CAAC;IAC9C;EACD,CAAC;AACF,CAAC,EAAE,MAAO,CAAC;AAAC,IAAAK,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEGhB,IAAI","ignoreList":[]}
1
+ {"version":3,"names":["_isShallowEqual","_interopRequireDefault","require","_element","_createHigherOrderComponent","_jsxRuntime","pure","createHigherOrderComponent","WrappedComponent","prototype","Component","shouldComponentUpdate","nextProps","nextState","isShallowEqual","props","state","render","jsx","_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 *\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"],"mappings":";;;;;;;AAQA,IAAAA,eAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,2BAAA,GAAAF,OAAA;AAAuF,IAAAG,WAAA,GAAAH,OAAA;AAdvF;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA,GACA,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,oBAAO,IAAAZ,WAAA,CAAAa,GAAA,EAACV,gBAAgB;QAAA,GAAM,IAAI,CAACO;MAAK,CAAI,CAAC;IAC9C;EACD,CAAC;AACF,CAAC,EAAE,MAAO,CAAC;AAAC,IAAAI,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEGf,IAAI","ignoreList":[]}
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = withGlobalEvents;
8
- var _react = require("react");
9
8
  var _element = require("@wordpress/element");
10
9
  var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
11
10
  var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
12
11
  var _listener = _interopRequireDefault(require("./listener"));
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
13
  /**
14
14
  * WordPress dependencies
15
15
  */
@@ -20,8 +20,7 @@ var _listener = _interopRequireDefault(require("./listener"));
20
20
 
21
21
  /**
22
22
  * Listener instance responsible for managing document event handling.
23
- */
24
- const listener = new _listener.default();
23
+ */const listener = new _listener.default();
25
24
 
26
25
  /* eslint-disable jsdoc/no-undefined-types */
27
26
  /**
@@ -86,14 +85,14 @@ function withGlobalEvents(eventTypesToHandlers) {
86
85
  }
87
86
  }
88
87
  render() {
89
- return (0, _react.createElement)(WrappedComponent, {
88
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, {
90
89
  ...this.props.ownProps,
91
90
  ref: this.handleRef
92
91
  });
93
92
  }
94
93
  }
95
94
  return (0, _element.forwardRef)((props, ref) => {
96
- return (0, _react.createElement)(Wrapper, {
95
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Wrapper, {
97
96
  ownProps: props,
98
97
  forwardedRef: ref
99
98
  });
@@ -1 +1 @@
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","_react","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,GACnB;QACCqB,KAAK,CAACE;;QAEP,8CACA;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,IAAAC,MAAA,CAAAC,aAAA,EAACxB,gBAAgB;UAAA,GACX,IAAI,CAACI,KAAK,CAACqB,QAAQ;UACxBC,GAAG,EAAG,IAAI,CAACnB;QAAW,CACtB,CAAC;MAEJ;IACD;IAEA,OAAO,IAAAoB,mBAAU,EAAE,CAAEvB,KAAK,EAAEsB,GAAG,KAAM;MACpC,OAAO,IAAAH,MAAA,CAAAC,aAAA,EAACvB,OAAO;QAACwB,QAAQ,EAAGrB,KAAO;QAACiB,YAAY,EAAGK;MAAK,CAAE,CAAC;IAC3D,CAAE,CAAC;EACJ,CAAC,EAAE,kBAAmB,CAAC;AACxB","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","_deprecated","_interopRequireDefault","_createHigherOrderComponent","_listener","_jsxRuntime","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","jsx","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;AAAkC,IAAAK,WAAA,GAAAL,OAAA;AAVlC;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA,GACA,MAAMM,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,GACnB;QACCqB,KAAK,CAACE;;QAEP,8CACA;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,oBACC,IAAA/B,WAAA,CAAAgC,GAAA,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,oBAAO,IAAAlC,WAAA,CAAAgC,GAAA,EAACtB,OAAO;QAACuB,QAAQ,EAAGpB,KAAO;QAACiB,YAAY,EAAGI;MAAK,CAAE,CAAC;IAC3D,CAAE,CAAC;EACJ,CAAC,EAAE,kBAAmB,CAAC;AACxB","ignoreList":[]}
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _react = require("react");
9
8
  var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
10
9
  var _useInstanceId = _interopRequireDefault(require("../../hooks/use-instance-id"));
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
11
  /**
12
12
  * Internal dependencies
13
13
  */
@@ -20,7 +20,7 @@ const withInstanceId = (0, _createHigherOrderComponent.createHigherOrderComponen
20
20
  return props => {
21
21
  const instanceId = (0, _useInstanceId.default)(WrappedComponent);
22
22
  // @ts-ignore
23
- return (0, _react.createElement)(WrappedComponent, {
23
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, {
24
24
  ...props,
25
25
  instanceId: instanceId
26
26
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_createHigherOrderComponent","require","_useInstanceId","_interopRequireDefault","withInstanceId","createHigherOrderComponent","WrappedComponent","props","instanceId","useInstanceId","_react","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,MAAA,CAAAC,aAAA,EAACL,gBAAgB;MAAA,GAAMC,KAAK;MAAGC,UAAU,EAAGA;IAAY,CAAE,CAAC;EACnE,CAAC;AACF,CAAC,EACD,YACD,CAAC;AAAC,IAAAI,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaV,cAAc","ignoreList":[]}
1
+ {"version":3,"names":["_createHigherOrderComponent","require","_useInstanceId","_interopRequireDefault","_jsxRuntime","withInstanceId","createHigherOrderComponent","WrappedComponent","props","instanceId","useInstanceId","jsx","_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;AAAwD,IAAAG,WAAA,GAAAH,OAAA;AARxD;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA,MAAMI,cAAc,GAAG,IAAAC,sDAA0B,EAE/CC,gBAAmB,IACf;EACJ,OAASC,KAAiD,IAAM;IAC/D,MAAMC,UAAU,GAAG,IAAAC,sBAAa,EAAEH,gBAAiB,CAAC;IACpD;IACA,oBAAO,IAAAH,WAAA,CAAAO,GAAA,EAACJ,gBAAgB;MAAA,GAAMC,KAAK;MAAGC,UAAU,EAAGA;IAAY,CAAE,CAAC;EACnE,CAAC;AACF,CAAC,EACD,YACD,CAAC;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaT,cAAc","ignoreList":[]}
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _react = require("react");
9
8
  var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
10
9
  var _useNetworkConnectivity = _interopRequireDefault(require("../../hooks/use-network-connectivity"));
10
+ var _jsxRuntime = require("react/jsx-runtime");
11
11
  /**
12
12
  * Internal dependencies
13
13
  */
@@ -17,7 +17,7 @@ const withNetworkConnectivity = (0, _createHigherOrderComponent.createHigherOrde
17
17
  const {
18
18
  isConnected
19
19
  } = (0, _useNetworkConnectivity.default)();
20
- return (0, _react.createElement)(WrappedComponent, {
20
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, {
21
21
  ...props,
22
22
  isConnected: isConnected
23
23
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_createHigherOrderComponent","require","_useNetworkConnectivity","_interopRequireDefault","withNetworkConnectivity","createHigherOrderComponent","WrappedComponent","props","isConnected","useNetworkConnectivity","_react","createElement","_default","exports","default"],"sources":["@wordpress/compose/src/higher-order/with-network-connectivity/index.native.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\nimport useNetworkConnectivity from '../../hooks/use-network-connectivity';\n\nconst withNetworkConnectivity = createHigherOrderComponent(\n\t( WrappedComponent ) => {\n\t\treturn ( props ) => {\n\t\t\tconst { isConnected } = useNetworkConnectivity();\n\t\t\treturn (\n\t\t\t\t<WrappedComponent { ...props } isConnected={ isConnected } />\n\t\t\t);\n\t\t};\n\t},\n\t'withNetworkConnectivity'\n);\n\nexport default withNetworkConnectivity;\n"],"mappings":";;;;;;;;AAGA,IAAAA,2BAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAJA;AACA;AACA;;AAIA,MAAMG,uBAAuB,GAAG,IAAAC,sDAA0B,EACvDC,gBAAgB,IAAM;EACvB,OAASC,KAAK,IAAM;IACnB,MAAM;MAAEC;IAAY,CAAC,GAAG,IAAAC,+BAAsB,EAAC,CAAC;IAChD,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACL,gBAAgB;MAAA,GAAMC,KAAK;MAAGC,WAAW,EAAGA;IAAa,CAAE,CAAC;EAE/D,CAAC;AACF,CAAC,EACD,yBACD,CAAC;AAAC,IAAAI,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaV,uBAAuB","ignoreList":[]}
1
+ {"version":3,"names":["_createHigherOrderComponent","require","_useNetworkConnectivity","_interopRequireDefault","_jsxRuntime","withNetworkConnectivity","createHigherOrderComponent","WrappedComponent","props","isConnected","useNetworkConnectivity","jsx","_default","exports","default"],"sources":["@wordpress/compose/src/higher-order/with-network-connectivity/index.native.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\nimport useNetworkConnectivity from '../../hooks/use-network-connectivity';\n\nconst withNetworkConnectivity = createHigherOrderComponent(\n\t( WrappedComponent ) => {\n\t\treturn ( props ) => {\n\t\t\tconst { isConnected } = useNetworkConnectivity();\n\t\t\treturn (\n\t\t\t\t<WrappedComponent { ...props } isConnected={ isConnected } />\n\t\t\t);\n\t\t};\n\t},\n\t'withNetworkConnectivity'\n);\n\nexport default withNetworkConnectivity;\n"],"mappings":";;;;;;;AAGA,IAAAA,2BAAA,GAAAC,OAAA;AACA,IAAAC,uBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA0E,IAAAG,WAAA,GAAAH,OAAA;AAJ1E;AACA;AACA;;AAIA,MAAMI,uBAAuB,GAAG,IAAAC,sDAA0B,EACvDC,gBAAgB,IAAM;EACvB,OAASC,KAAK,IAAM;IACnB,MAAM;MAAEC;IAAY,CAAC,GAAG,IAAAC,+BAAsB,EAAC,CAAC;IAChD,oBACC,IAAAN,WAAA,CAAAO,GAAA,EAACJ,gBAAgB;MAAA,GAAMC,KAAK;MAAGC,WAAW,EAAGA;IAAa,CAAE,CAAC;EAE/D,CAAC;AACF,CAAC,EACD,yBACD,CAAC;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaT,uBAAuB","ignoreList":[]}
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _react = require("react");
9
8
  var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
10
9
  var _usePreferredColorScheme = _interopRequireDefault(require("../../hooks/use-preferred-color-scheme"));
11
10
  var _element = require("@wordpress/element");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
12
  /**
13
13
  * Internal dependencies
14
14
  */
@@ -27,7 +27,7 @@ const withPreferredColorScheme = (0, _createHigherOrderComponent.createHigherOrd
27
27
  };
28
28
  return isDarkMode ? finalDarkStyles : lightStyles;
29
29
  }, [isDarkMode]);
30
- return (0, _react.createElement)(WrappedComponent, {
30
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, {
31
31
  preferredColorScheme: colorScheme,
32
32
  getStylesFromColorScheme: getStyles,
33
33
  ...props
@@ -1 +1 @@
1
- {"version":3,"names":["_createHigherOrderComponent","require","_usePreferredColorScheme","_interopRequireDefault","_element","withPreferredColorScheme","createHigherOrderComponent","WrappedComponent","props","colorScheme","usePreferredColorScheme","isDarkMode","getStyles","useCallback","lightStyles","darkStyles","finalDarkStyles","_react","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":";;;;;;;;AAGA,IAAAA,2BAAA,GAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AATA;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,IAAAM,MAAA,CAAAC,aAAA,EAACX,gBAAgB;IAChBY,oBAAoB,EAAGV,WAAa;IACpCW,wBAAwB,EAAGR,SAAW;IAAA,GACjCJ;EAAK,CACV,CAAC;AAEJ,CAAC,EACD,0BACD,CAAC;AAAC,IAAAa,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEalB,wBAAwB","ignoreList":[]}
1
+ {"version":3,"names":["_createHigherOrderComponent","require","_usePreferredColorScheme","_interopRequireDefault","_element","_jsxRuntime","withPreferredColorScheme","createHigherOrderComponent","WrappedComponent","props","colorScheme","usePreferredColorScheme","isDarkMode","getStyles","useCallback","lightStyles","darkStyles","finalDarkStyles","jsx","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":";;;;;;;AAGA,IAAAA,2BAAA,GAAAC,OAAA;AACA,IAAAC,wBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AAAiD,IAAAI,WAAA,GAAAJ,OAAA;AATjD;AACA;AACA;;AAIA;AACA;AACA;;AAGA,MAAMK,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,oBACC,IAAAP,WAAA,CAAAa,GAAA,EAACV,gBAAgB;IAChBW,oBAAoB,EAAGT,WAAa;IACpCU,wBAAwB,EAAGP,SAAW;IAAA,GACjCJ;EAAK,CACV,CAAC;AAEJ,CAAC,EACD,0BACD,CAAC;AAAC,IAAAY,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEajB,wBAAwB","ignoreList":[]}
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _react = require("react");
8
7
  var _element = require("@wordpress/element");
9
8
  var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
10
  /**
11
11
  * WordPress dependencies
12
12
  */
@@ -53,8 +53,9 @@ const withSafeTimeout = (0, _createHigherOrderComponent.createHigherOrderCompone
53
53
  }
54
54
  render() {
55
55
  return (
56
+ /*#__PURE__*/
56
57
  // @ts-ignore
57
- (0, _react.createElement)(OriginalComponent, {
58
+ (0, _jsxRuntime.jsx)(OriginalComponent, {
58
59
  ...this.props,
59
60
  setTimeout: this.setTimeout,
60
61
  clearTimeout: this.clearTimeout
@@ -1 +1 @@
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","_react","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;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;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,IAAAC,MAAA,CAAAC,aAAA,EAACnB,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,IAAAY,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaxB,eAAe","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","_createHigherOrderComponent","_jsxRuntime","withSafeTimeout","createHigherOrderComponent","OriginalComponent","WrappedComponent","Component","constructor","props","timeouts","setTimeout","bind","clearTimeout","componentWillUnmount","forEach","fn","delay","id","push","filter","timeoutId","render","jsx","_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;AAAuF,IAAAE,WAAA,GAAAF,OAAA;AAZvF;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA,MAAMG,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;QAAA;QACC;QACA,IAAApB,WAAA,CAAAqB,GAAA,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,GAAAC,OAAA,CAAAC,OAAA,GAEavB,eAAe","ignoreList":[]}
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = withState;
8
- var _react = require("react");
9
8
  var _element = require("@wordpress/element");
10
9
  var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
11
10
  var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
12
  /**
13
13
  * WordPress dependencies
14
14
  */
@@ -26,8 +26,7 @@ var _createHigherOrderComponent = require("../../utils/create-higher-order-compo
26
26
  * @param {any} initialState Optional initial state of the component.
27
27
  *
28
28
  * @return {any} A higher order component wrapper accepting a component that takes the state props + its own props + `setState` and returning a component that only accepts the own props.
29
- */
30
- function withState(initialState = {}) {
29
+ */function withState(initialState = {}) {
31
30
  (0, _deprecated.default)('wp.compose.withState', {
32
31
  since: '5.8',
33
32
  alternative: 'wp.element.useState'
@@ -40,7 +39,7 @@ function withState(initialState = {}) {
40
39
  this.state = initialState;
41
40
  }
42
41
  render() {
43
- return (0, _react.createElement)(OriginalComponent, {
42
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(OriginalComponent, {
44
43
  ...this.props,
45
44
  ...this.state,
46
45
  setState: this.setState
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_deprecated","_interopRequireDefault","_createHigherOrderComponent","withState","initialState","deprecated","since","alternative","createHigherOrderComponent","OriginalComponent","WrappedComponent","Component","constructor","props","setState","bind","state","render","_react","createElement"],"sources":["@wordpress/compose/src/higher-order/with-state/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * A Higher Order Component used to provide and manage internal component state\n * via props.\n *\n * @deprecated Use `useState` instead.\n *\n * @param {any} initialState Optional initial state of the component.\n *\n * @return {any} A higher order component wrapper accepting a component that takes the state props + its own props + `setState` and returning a component that only accepts the own props.\n */\nexport default function withState( initialState = {} ) {\n\tdeprecated( 'wp.compose.withState', {\n\t\tsince: '5.8',\n\t\talternative: 'wp.element.useState',\n\t} );\n\n\treturn createHigherOrderComponent( ( OriginalComponent ) => {\n\t\treturn class WrappedComponent extends Component {\n\t\t\tconstructor( /** @type {any} */ props ) {\n\t\t\t\tsuper( props );\n\n\t\t\t\tthis.setState = this.setState.bind( this );\n\n\t\t\t\tthis.state = initialState;\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\treturn (\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...this.props }\n\t\t\t\t\t\t{ ...this.state }\n\t\t\t\t\t\tsetState={ this.setState }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t}, 'withState' );\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,2BAAA,GAAAH,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASI,SAASA,CAAEC,YAAY,GAAG,CAAC,CAAC,EAAG;EACtD,IAAAC,mBAAU,EAAE,sBAAsB,EAAE;IACnCC,KAAK,EAAE,KAAK;IACZC,WAAW,EAAE;EACd,CAAE,CAAC;EAEH,OAAO,IAAAC,sDAA0B,EAAIC,iBAAiB,IAAM;IAC3D,OAAO,MAAMC,gBAAgB,SAASC,kBAAS,CAAC;MAC/CC,WAAWA,CAAA,CAAE,kBAAmBC,KAAK,EAAG;QACvC,KAAK,CAAEA,KAAM,CAAC;QAEd,IAAI,CAACC,QAAQ,GAAG,IAAI,CAACA,QAAQ,CAACC,IAAI,CAAE,IAAK,CAAC;QAE1C,IAAI,CAACC,KAAK,GAAGZ,YAAY;MAC1B;MAEAa,MAAMA,CAAA,EAAG;QACR,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACV,iBAAiB;UAAA,GACZ,IAAI,CAACI,KAAK;UAAA,GACV,IAAI,CAACG,KAAK;UACfF,QAAQ,EAAG,IAAI,CAACA;QAAU,CAC1B,CAAC;MAEJ;IACD,CAAC;EACF,CAAC,EAAE,WAAY,CAAC;AACjB","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","_deprecated","_interopRequireDefault","_createHigherOrderComponent","_jsxRuntime","withState","initialState","deprecated","since","alternative","createHigherOrderComponent","OriginalComponent","WrappedComponent","Component","constructor","props","setState","bind","state","render","jsx"],"sources":["@wordpress/compose/src/higher-order/with-state/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * A Higher Order Component used to provide and manage internal component state\n * via props.\n *\n * @deprecated Use `useState` instead.\n *\n * @param {any} initialState Optional initial state of the component.\n *\n * @return {any} A higher order component wrapper accepting a component that takes the state props + its own props + `setState` and returning a component that only accepts the own props.\n */\nexport default function withState( initialState = {} ) {\n\tdeprecated( 'wp.compose.withState', {\n\t\tsince: '5.8',\n\t\talternative: 'wp.element.useState',\n\t} );\n\n\treturn createHigherOrderComponent( ( OriginalComponent ) => {\n\t\treturn class WrappedComponent extends Component {\n\t\t\tconstructor( /** @type {any} */ props ) {\n\t\t\t\tsuper( props );\n\n\t\t\t\tthis.setState = this.setState.bind( this );\n\n\t\t\t\tthis.state = initialState;\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\treturn (\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...this.props }\n\t\t\t\t\t\t{ ...this.state }\n\t\t\t\t\t\tsetState={ this.setState }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t}, 'withState' );\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,2BAAA,GAAAH,OAAA;AAAuF,IAAAI,WAAA,GAAAJ,OAAA;AATvF;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACe,SAASK,SAASA,CAAEC,YAAY,GAAG,CAAC,CAAC,EAAG;EACtD,IAAAC,mBAAU,EAAE,sBAAsB,EAAE;IACnCC,KAAK,EAAE,KAAK;IACZC,WAAW,EAAE;EACd,CAAE,CAAC;EAEH,OAAO,IAAAC,sDAA0B,EAAIC,iBAAiB,IAAM;IAC3D,OAAO,MAAMC,gBAAgB,SAASC,kBAAS,CAAC;MAC/CC,WAAWA,CAAA,CAAE,kBAAmBC,KAAK,EAAG;QACvC,KAAK,CAAEA,KAAM,CAAC;QAEd,IAAI,CAACC,QAAQ,GAAG,IAAI,CAACA,QAAQ,CAACC,IAAI,CAAE,IAAK,CAAC;QAE1C,IAAI,CAACC,KAAK,GAAGZ,YAAY;MAC1B;MAEAa,MAAMA,CAAA,EAAG;QACR,oBACC,IAAAf,WAAA,CAAAgB,GAAA,EAACT,iBAAiB;UAAA,GACZ,IAAI,CAACI,KAAK;UAAA,GACV,IAAI,CAACG,KAAK;UACfF,QAAQ,EAAG,IAAI,CAACA;QAAU,CAC1B,CAAC;MAEJ;IACD,CAAC;EACF,CAAC,EAAE,WAAY,CAAC;AACjB","ignoreList":[]}
@@ -25,7 +25,7 @@ var _debounce = require("../../utils/debounce");
25
25
  * including the function to debounce, so please wrap functions created on
26
26
  * render in components in `useCallback`.
27
27
  *
28
- * @see https://docs-lodash.com/v4/debounce/
28
+ * @see https://lodash.com/docs/4#debounce
29
29
  *
30
30
  * @template {(...args: any[]) => void} TFunc
31
31
  *
@@ -1 +1 @@
1
- {"version":3,"names":["_useMemoOne","require","_element","_debounce","useDebounce","fn","wait","options","debounced","useMemoOne","debounce","useEffect","cancel"],"sources":["@wordpress/compose/src/hooks/use-debounce/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { debounce } from '../../utils/debounce';\n\n/**\n * Debounces a function similar to Lodash's `debounce`. A new debounced function will\n * be returned and any scheduled calls cancelled if any of the arguments change,\n * including the function to debounce, so please wrap functions created on\n * render in components in `useCallback`.\n *\n * @see https://docs-lodash.com/v4/debounce/\n *\n * @template {(...args: any[]) => void} TFunc\n *\n * @param {TFunc} fn The function to debounce.\n * @param {number} [wait] The number of milliseconds to delay.\n * @param {import('../../utils/debounce').DebounceOptions} [options] The options object.\n * @return {import('../../utils/debounce').DebouncedFunc<TFunc>} Debounced function.\n */\nexport default function useDebounce( fn, wait, options ) {\n\tconst debounced = useMemoOne(\n\t\t() => debounce( fn, wait ?? 0, options ),\n\t\t[ fn, wait, options ]\n\t);\n\tuseEffect( () => () => debounced.cancel(), [ debounced ] );\n\treturn debounced;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,SAAA,GAAAF,OAAA;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASG,WAAWA,CAAEC,EAAE,EAAEC,IAAI,EAAEC,OAAO,EAAG;EACxD,MAAMC,SAAS,GAAG,IAAAC,sBAAU,EAC3B,MAAM,IAAAC,kBAAQ,EAAEL,EAAE,EAAEC,IAAI,aAAJA,IAAI,cAAJA,IAAI,GAAI,CAAC,EAAEC,OAAQ,CAAC,EACxC,CAAEF,EAAE,EAAEC,IAAI,EAAEC,OAAO,CACpB,CAAC;EACD,IAAAI,kBAAS,EAAE,MAAM,MAAMH,SAAS,CAACI,MAAM,CAAC,CAAC,EAAE,CAAEJ,SAAS,CAAG,CAAC;EAC1D,OAAOA,SAAS;AACjB","ignoreList":[]}
1
+ {"version":3,"names":["_useMemoOne","require","_element","_debounce","useDebounce","fn","wait","options","debounced","useMemoOne","debounce","useEffect","cancel"],"sources":["@wordpress/compose/src/hooks/use-debounce/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { debounce } from '../../utils/debounce';\n\n/**\n * Debounces a function similar to Lodash's `debounce`. A new debounced function will\n * be returned and any scheduled calls cancelled if any of the arguments change,\n * including the function to debounce, so please wrap functions created on\n * render in components in `useCallback`.\n *\n * @see https://lodash.com/docs/4#debounce\n *\n * @template {(...args: any[]) => void} TFunc\n *\n * @param {TFunc} fn The function to debounce.\n * @param {number} [wait] The number of milliseconds to delay.\n * @param {import('../../utils/debounce').DebounceOptions} [options] The options object.\n * @return {import('../../utils/debounce').DebouncedFunc<TFunc>} Debounced function.\n */\nexport default function useDebounce( fn, wait, options ) {\n\tconst debounced = useMemoOne(\n\t\t() => debounce( fn, wait ?? 0, options ),\n\t\t[ fn, wait, options ]\n\t);\n\tuseEffect( () => () => debounced.cancel(), [ debounced ] );\n\treturn debounced;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AAKA,IAAAE,SAAA,GAAAF,OAAA;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASG,WAAWA,CAAEC,EAAE,EAAEC,IAAI,EAAEC,OAAO,EAAG;EACxD,MAAMC,SAAS,GAAG,IAAAC,sBAAU,EAC3B,MAAM,IAAAC,kBAAQ,EAAEL,EAAE,EAAEC,IAAI,aAAJA,IAAI,cAAJA,IAAI,GAAI,CAAC,EAAEC,OAAQ,CAAC,EACxC,CAAEF,EAAE,EAAEC,IAAI,EAAEC,OAAO,CACpB,CAAC;EACD,IAAAI,kBAAS,EAAE,MAAM,MAAMH,SAAS,CAACI,MAAM,CAAC,CAAC,EAAE,CAAEJ,SAAS,CAAG,CAAC;EAC1D,OAAOA,SAAS;AACjB","ignoreList":[]}
@@ -18,8 +18,8 @@ var _useDebounce = _interopRequireDefault(require("../use-debounce"));
18
18
  /**
19
19
  * Helper hook for input fields that need to debounce the value before using it.
20
20
  *
21
- * @param {any} defaultValue The default value to use.
22
- * @return {[string, Function, string]} The input value, the setter and the debounced input value.
21
+ * @param defaultValue The default value to use.
22
+ * @return The input value, the setter and the debounced input value.
23
23
  */
24
24
  function useDebouncedInput(defaultValue = '') {
25
25
  const [input, setInput] = (0, _element.useState)(defaultValue);
@@ -27,7 +27,7 @@ function useDebouncedInput(defaultValue = '') {
27
27
  const setDebouncedInput = (0, _useDebounce.default)(setDebouncedState, 250);
28
28
  (0, _element.useEffect)(() => {
29
29
  setDebouncedInput(input);
30
- }, [input]);
30
+ }, [input, setDebouncedInput]);
31
31
  return [input, setInput, debouncedInput];
32
32
  }
33
33
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_useDebounce","_interopRequireDefault","useDebouncedInput","defaultValue","input","setInput","useState","debouncedInput","setDebouncedState","setDebouncedInput","useDebounce","useEffect"],"sources":["@wordpress/compose/src/hooks/use-debounced-input/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useDebounce from '../use-debounce';\n\n/**\n * Helper hook for input fields that need to debounce the value before using it.\n *\n * @param {any} defaultValue The default value to use.\n * @return {[string, Function, string]} The input value, the setter and the debounced input value.\n */\nexport default function useDebouncedInput( defaultValue = '' ) {\n\tconst [ input, setInput ] = useState( defaultValue );\n\tconst [ debouncedInput, setDebouncedState ] = useState( defaultValue );\n\n\tconst setDebouncedInput = useDebounce( setDebouncedState, 250 );\n\n\tuseEffect( () => {\n\t\tsetDebouncedInput( input );\n\t}, [ input ] );\n\n\treturn [ input, setInput, debouncedInput ];\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACe,SAASG,iBAAiBA,CAAEC,YAAY,GAAG,EAAE,EAAG;EAC9D,MAAM,CAAEC,KAAK,EAAEC,QAAQ,CAAE,GAAG,IAAAC,iBAAQ,EAAEH,YAAa,CAAC;EACpD,MAAM,CAAEI,cAAc,EAAEC,iBAAiB,CAAE,GAAG,IAAAF,iBAAQ,EAAEH,YAAa,CAAC;EAEtE,MAAMM,iBAAiB,GAAG,IAAAC,oBAAW,EAAEF,iBAAiB,EAAE,GAAI,CAAC;EAE/D,IAAAG,kBAAS,EAAE,MAAM;IAChBF,iBAAiB,CAAEL,KAAM,CAAC;EAC3B,CAAC,EAAE,CAAEA,KAAK,CAAG,CAAC;EAEd,OAAO,CAAEA,KAAK,EAAEC,QAAQ,EAAEE,cAAc,CAAE;AAC3C","ignoreList":[]}
1
+ {"version":3,"names":["_element","require","_useDebounce","_interopRequireDefault","useDebouncedInput","defaultValue","input","setInput","useState","debouncedInput","setDebouncedState","setDebouncedInput","useDebounce","useEffect"],"sources":["@wordpress/compose/src/hooks/use-debounced-input/index.ts"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useDebounce from '../use-debounce';\n\n/**\n * Helper hook for input fields that need to debounce the value before using it.\n *\n * @param defaultValue The default value to use.\n * @return The input value, the setter and the debounced input value.\n */\nexport default function useDebouncedInput(\n\tdefaultValue = ''\n): [ string, ( value: string ) => void, string ] {\n\tconst [ input, setInput ] = useState< string >( defaultValue );\n\tconst [ debouncedInput, setDebouncedState ] = useState( defaultValue );\n\n\tconst setDebouncedInput = useDebounce( setDebouncedState, 250 );\n\n\tuseEffect( () => {\n\t\tsetDebouncedInput( input );\n\t}, [ input, setDebouncedInput ] );\n\n\treturn [ input, setInput, debouncedInput ];\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAC,sBAAA,CAAAF,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACe,SAASG,iBAAiBA,CACxCC,YAAY,GAAG,EAAE,EAC+B;EAChD,MAAM,CAAEC,KAAK,EAAEC,QAAQ,CAAE,GAAG,IAAAC,iBAAQ,EAAYH,YAAa,CAAC;EAC9D,MAAM,CAAEI,cAAc,EAAEC,iBAAiB,CAAE,GAAG,IAAAF,iBAAQ,EAAEH,YAAa,CAAC;EAEtE,MAAMM,iBAAiB,GAAG,IAAAC,oBAAW,EAAEF,iBAAiB,EAAE,GAAI,CAAC;EAE/D,IAAAG,kBAAS,EAAE,MAAM;IAChBF,iBAAiB,CAAEL,KAAM,CAAC;EAC3B,CAAC,EAAE,CAAEA,KAAK,EAAEK,iBAAiB,CAAG,CAAC;EAEjC,OAAO,CAAEL,KAAK,EAAEC,QAAQ,EAAEE,cAAc,CAAE;AAC3C","ignoreList":[]}
@@ -1,15 +1,21 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = useFocusOnMount;
7
8
  var _element = require("@wordpress/element");
8
9
  var _dom = require("@wordpress/dom");
10
+ var _useRefEffect = _interopRequireDefault(require("../use-ref-effect"));
9
11
  /**
10
12
  * WordPress dependencies
11
13
  */
12
14
 
15
+ /**
16
+ * Internal dependencies
17
+ */
18
+
13
19
  /**
14
20
  * Hook used to focus the first tabbable element on mount.
15
21
  *
@@ -54,14 +60,7 @@ function useFocusOnMount(focusOnMount = 'firstElement') {
54
60
  (0, _element.useEffect)(() => {
55
61
  focusOnMountRef.current = focusOnMount;
56
62
  }, [focusOnMount]);
57
- (0, _element.useEffect)(() => {
58
- return () => {
59
- if (timerId.current) {
60
- clearTimeout(timerId.current);
61
- }
62
- };
63
- }, []);
64
- return (0, _element.useCallback)(node => {
63
+ return (0, _useRefEffect.default)(node => {
65
64
  var _node$ownerDocument$a;
66
65
  if (!node || focusOnMountRef.current === false) {
67
66
  return;
@@ -79,6 +78,11 @@ function useFocusOnMount(focusOnMount = 'firstElement') {
79
78
  return;
80
79
  }
81
80
  setFocus(node);
81
+ return () => {
82
+ if (timerId.current) {
83
+ clearTimeout(timerId.current);
84
+ }
85
+ };
82
86
  }, []);
83
87
  }
84
88
  //# sourceMappingURL=index.js.map