@wordpress/compose 5.8.0 → 5.11.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 (98) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -2
  3. package/build/higher-order/if-condition/index.js +14 -10
  4. package/build/higher-order/if-condition/index.js.map +1 -1
  5. package/build/higher-order/pure/index.js +9 -5
  6. package/build/higher-order/pure/index.js.map +1 -1
  7. package/build/higher-order/with-global-events/index.js +2 -2
  8. package/build/higher-order/with-global-events/index.js.map +1 -1
  9. package/build/higher-order/with-instance-id/index.js +3 -3
  10. package/build/higher-order/with-instance-id/index.js.map +1 -1
  11. package/build/higher-order/with-preferred-color-scheme/index.native.js +2 -2
  12. package/build/higher-order/with-preferred-color-scheme/index.native.js.map +1 -1
  13. package/build/higher-order/with-safe-timeout/index.js +10 -7
  14. package/build/higher-order/with-safe-timeout/index.js.map +1 -1
  15. package/build/higher-order/with-state/index.js +2 -2
  16. package/build/higher-order/with-state/index.js.map +1 -1
  17. package/build/hooks/use-debounce/index.js.map +1 -1
  18. package/build/hooks/use-dialog/index.js +3 -3
  19. package/build/hooks/use-dialog/index.js.map +1 -1
  20. package/build/hooks/use-disabled/index.js.map +1 -1
  21. package/build/hooks/use-focus-return/index.js.map +1 -1
  22. package/build/hooks/use-keyboard-shortcut/index.js.map +1 -1
  23. package/build/hooks/use-merge-refs/index.js.map +1 -1
  24. package/build/hooks/use-throttle/index.js.map +1 -1
  25. package/build/index.js +48 -7
  26. package/build/index.js.map +1 -1
  27. package/build/index.native.js +40 -7
  28. package/build/index.native.js.map +1 -1
  29. package/build/utils/create-higher-order-component/index.js +19 -5
  30. package/build/utils/create-higher-order-component/index.js.map +1 -1
  31. package/build-module/higher-order/if-condition/index.js +13 -7
  32. package/build-module/higher-order/if-condition/index.js.map +1 -1
  33. package/build-module/higher-order/pure/index.js +10 -9
  34. package/build-module/higher-order/pure/index.js.map +1 -1
  35. package/build-module/higher-order/with-global-events/index.js +1 -1
  36. package/build-module/higher-order/with-global-events/index.js.map +1 -1
  37. package/build-module/higher-order/with-instance-id/index.js +3 -3
  38. package/build-module/higher-order/with-instance-id/index.js.map +1 -1
  39. package/build-module/higher-order/with-preferred-color-scheme/index.native.js +1 -1
  40. package/build-module/higher-order/with-preferred-color-scheme/index.native.js.map +1 -1
  41. package/build-module/higher-order/with-safe-timeout/index.js +9 -7
  42. package/build-module/higher-order/with-safe-timeout/index.js.map +1 -1
  43. package/build-module/higher-order/with-state/index.js +1 -1
  44. package/build-module/higher-order/with-state/index.js.map +1 -1
  45. package/build-module/hooks/use-debounce/index.js.map +1 -1
  46. package/build-module/hooks/use-dialog/index.js +3 -3
  47. package/build-module/hooks/use-dialog/index.js.map +1 -1
  48. package/build-module/hooks/use-disabled/index.js.map +1 -1
  49. package/build-module/hooks/use-focus-return/index.js.map +1 -1
  50. package/build-module/hooks/use-keyboard-shortcut/index.js.map +1 -1
  51. package/build-module/hooks/use-merge-refs/index.js.map +1 -1
  52. package/build-module/hooks/use-throttle/index.js.map +1 -1
  53. package/build-module/index.js +2 -2
  54. package/build-module/index.js.map +1 -1
  55. package/build-module/index.native.js +2 -2
  56. package/build-module/index.native.js.map +1 -1
  57. package/build-module/utils/create-higher-order-component/index.js +18 -4
  58. package/build-module/utils/create-higher-order-component/index.js.map +1 -1
  59. package/build-types/higher-order/if-condition/index.d.ts +5 -1
  60. package/build-types/higher-order/if-condition/index.d.ts.map +1 -1
  61. package/build-types/higher-order/pure/index.d.ts +1 -1
  62. package/build-types/higher-order/pure/index.d.ts.map +1 -1
  63. package/build-types/higher-order/with-global-events/index.d.ts.map +1 -1
  64. package/build-types/higher-order/with-instance-id/index.d.ts +8 -3
  65. package/build-types/higher-order/with-instance-id/index.d.ts.map +1 -1
  66. package/build-types/higher-order/with-safe-timeout/index.d.ts +37 -4
  67. package/build-types/higher-order/with-safe-timeout/index.d.ts.map +1 -1
  68. package/build-types/hooks/use-debounce/index.d.ts.map +1 -1
  69. package/build-types/hooks/use-dialog/index.d.ts +5 -1
  70. package/build-types/hooks/use-dialog/index.d.ts.map +1 -1
  71. package/build-types/hooks/use-disabled/index.d.ts.map +1 -1
  72. package/build-types/hooks/use-focus-return/index.d.ts.map +1 -1
  73. package/build-types/hooks/use-merge-refs/index.d.ts.map +1 -1
  74. package/build-types/hooks/use-throttle/index.d.ts.map +1 -1
  75. package/build-types/index.d.ts +1 -1
  76. package/build-types/utils/create-higher-order-component/index.d.ts +5 -12
  77. package/build-types/utils/create-higher-order-component/index.d.ts.map +1 -1
  78. package/package.json +8 -8
  79. package/src/higher-order/if-condition/index.tsx +11 -7
  80. package/src/higher-order/pure/index.tsx +29 -31
  81. package/src/higher-order/with-global-events/index.js +4 -2
  82. package/src/higher-order/with-global-events/test/index.js +2 -2
  83. package/src/higher-order/with-instance-id/index.tsx +19 -10
  84. package/src/higher-order/with-preferred-color-scheme/index.native.js +1 -1
  85. package/src/higher-order/with-safe-timeout/index.tsx +22 -19
  86. package/src/higher-order/with-state/index.js +1 -1
  87. package/src/hooks/use-debounce/index.js +4 -5
  88. package/src/hooks/use-dialog/index.js +16 -14
  89. package/src/hooks/use-disabled/index.js +8 -9
  90. package/src/hooks/use-focus-return/index.js +3 -1
  91. package/src/hooks/use-keyboard-shortcut/index.js +1 -1
  92. package/src/hooks/use-merge-refs/index.js +2 -1
  93. package/src/hooks/use-throttle/index.js +4 -5
  94. package/src/index.js +2 -2
  95. package/src/index.native.js +2 -2
  96. package/src/utils/create-higher-order-component/index.ts +30 -27
  97. package/src/utils/create-higher-order-component/test/index.js +1 -1
  98. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 5.11.0 (2022-07-13)
6
+
7
+ ## 5.10.0 (2022-06-29)
8
+
9
+ ## 5.9.0 (2022-06-15)
10
+
5
11
  ## 5.8.0 (2022-06-01)
6
12
 
7
13
  ## 5.7.0 (2022-05-18)
package/README.md CHANGED
@@ -79,7 +79,7 @@ name, returns the enhanced component augmented with a generated displayName.
79
79
 
80
80
  _Parameters_
81
81
 
82
- - _mapComponent_ `HigherOrderComponent< HOCProps >`: Function mapping component to enhanced component.
82
+ - _mapComponent_ `( Inner: TInner ) => TOuter`: Function mapping component to enhanced component.
83
83
  - _modifierName_ `string`: Seed name from which to generated display name.
84
84
 
85
85
  _Returns_
@@ -105,7 +105,7 @@ const ConditionalComponent = ifCondition(
105
105
 
106
106
  _Parameters_
107
107
 
108
- - _predicate_ `( props: TProps ) => boolean`: Function to test condition.
108
+ - _predicate_ `( props: Props ) => boolean`: Function to test condition.
109
109
 
110
110
  _Returns_
111
111
 
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -9,7 +7,11 @@ exports.default = void 0;
9
7
 
10
8
  var _element = require("@wordpress/element");
11
9
 
12
- var _createHigherOrderComponent = _interopRequireDefault(require("../../utils/create-higher-order-component"));
10
+ var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
11
+
12
+ /**
13
+ * External dependencies
14
+ */
13
15
 
14
16
  /**
15
17
  * Internal dependencies
@@ -32,13 +34,15 @@ var _createHigherOrderComponent = _interopRequireDefault(require("../../utils/cr
32
34
  *
33
35
  * @return Higher-order component.
34
36
  */
35
- const ifCondition = predicate => (0, _createHigherOrderComponent.default)(WrappedComponent => props => {
36
- if (!predicate(props)) {
37
- return null;
38
- }
39
-
40
- return (0, _element.createElement)(WrappedComponent, props);
41
- }, 'ifCondition');
37
+ function ifCondition(predicate) {
38
+ return (0, _createHigherOrderComponent.createHigherOrderComponent)(WrappedComponent => props => {
39
+ if (!predicate(props)) {
40
+ return null;
41
+ }
42
+
43
+ return (0, _element.createElement)(WrappedComponent, props);
44
+ }, 'ifCondition');
45
+ }
42
46
 
43
47
  var _default = ifCondition;
44
48
  exports.default = _default;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/if-condition/index.tsx"],"names":["ifCondition","predicate","WrappedComponent","props"],"mappings":";;;;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,WAAW,GAChBC,SADmB,IAGnB,yCACGC,gBAAF,IAA0BC,KAAF,IAAa;AACpC,MAAK,CAAEF,SAAS,CAAEE,KAAF,CAAhB,EAAsC;AACrC,WAAO,IAAP;AACA;;AAED,SAAO,4BAAC,gBAAD,EAAuBA,KAAvB,CAAP;AACA,CAPF,EAQC,aARD,CAHD;;eAceH,W","sourcesContent":["/**\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 */\nconst ifCondition = < TProps extends Record< string, any > >(\n\tpredicate: ( props: TProps ) => boolean\n) =>\n\tcreateHigherOrderComponent< {} >(\n\t\t( WrappedComponent ) => ( props ) => {\n\t\t\tif ( ! predicate( props as TProps ) ) {\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\nexport default ifCondition;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/if-condition/index.tsx"],"names":["ifCondition","predicate","WrappedComponent","props"],"mappings":";;;;;;;;;AAQA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,WAAT,CAA+BC,SAA/B,EAAwE;AACvE,SAAO,4DACJC,gBAAF,IAAkDC,KAAF,IAAoB;AACnE,QAAK,CAAEF,SAAS,CAAEE,KAAF,CAAhB,EAA4B;AAC3B,aAAO,IAAP;AACA;;AAED,WAAO,4BAAC,gBAAD,EAAuBA,KAAvB,CAAP;AACA,GAPK,EAQN,aARM,CAAP;AAUA;;eAEcH,W","sourcesContent":["/**\n * External dependencies\n */\nimport type { ComponentType } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * Higher-order component creator, creating a new component which renders if\n * the given condition is satisfied or with the given optional prop name.\n *\n * @example\n * ```ts\n * type Props = { foo: string };\n * const Component = ( props: Props ) => <div>{ props.foo }</div>;\n * const ConditionalComponent = ifCondition( ( props: Props ) => props.foo.length !== 0 )( Component );\n * <ConditionalComponent foo=\"\" />; // => null\n * <ConditionalComponent foo=\"bar\" />; // => <div>bar</div>;\n * ```\n *\n * @param predicate Function to test condition.\n *\n * @return Higher-order component.\n */\nfunction ifCondition< Props >( predicate: ( props: Props ) => boolean ) {\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"]}
@@ -11,7 +11,11 @@ var _element = require("@wordpress/element");
11
11
 
12
12
  var _isShallowEqual = _interopRequireDefault(require("@wordpress/is-shallow-equal"));
13
13
 
14
- var _createHigherOrderComponent = _interopRequireDefault(require("../../utils/create-higher-order-component"));
14
+ var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
15
+
16
+ /**
17
+ * External dependencies
18
+ */
15
19
 
16
20
  /**
17
21
  * WordPress dependencies
@@ -25,9 +29,9 @@ var _createHigherOrderComponent = _interopRequireDefault(require("../../utils/cr
25
29
  * Given a component returns the enhanced component augmented with a component
26
30
  * only re-rendering when its props/state change
27
31
  */
28
- const pure = (0, _createHigherOrderComponent.default)(Wrapped => {
29
- if (Wrapped.prototype instanceof _element.Component) {
30
- return class extends Wrapped {
32
+ const pure = (0, _createHigherOrderComponent.createHigherOrderComponent)(function (WrappedComponent) {
33
+ if (WrappedComponent.prototype instanceof _element.Component) {
34
+ return class extends WrappedComponent {
31
35
  shouldComponentUpdate(nextProps, nextState) {
32
36
  return !(0, _isShallowEqual.default)(nextProps, this.props) || !(0, _isShallowEqual.default)(nextState, this.state);
33
37
  }
@@ -41,7 +45,7 @@ const pure = (0, _createHigherOrderComponent.default)(Wrapped => {
41
45
  }
42
46
 
43
47
  render() {
44
- return (0, _element.createElement)(Wrapped, this.props);
48
+ return (0, _element.createElement)(WrappedComponent, this.props);
45
49
  }
46
50
 
47
51
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/pure/index.tsx"],"names":["pure","Wrapped","prototype","Component","shouldComponentUpdate","nextProps","nextState","props","state","render"],"mappings":";;;;;;;;;AAIA;;AADA;;AAMA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA,MAAMA,IAAI,GAAG,yCAEXC,OADD,IAEK;AACJ,MAAKA,OAAO,CAACC,SAAR,YAA6BC,kBAAlC,EAA8C;AAC7C,WAAO,cAAgBF,OAAhB,CAAsD;AAC5DG,MAAAA,qBAAqB,CAAEC,SAAF,EAAqBC,SAArB,EAAsC;AAC1D,eACC,CAAE,6BAAgBD,SAAhB,EAA2B,KAAKE,KAAhC,CAAF,IACA,CAAE,6BAAgBD,SAAhB,EAA2B,KAAKE,KAAhC,CAFH;AAIA;;AAN2D,KAA7D;AAQA;;AAED,SAAO,cAAcL,kBAAd,CAAkC;AACxCC,IAAAA,qBAAqB,CAAEC,SAAF,EAAsB;AAC1C,aAAO,CAAE,6BAAgBA,SAAhB,EAA2B,KAAKE,KAAhC,CAAT;AACA;;AAEDE,IAAAA,MAAM,GAAG;AACR,aAAO,4BAAC,OAAD,EAAc,KAAKF,KAAnB,CAAP;AACA;;AAPuC,GAAzC;AASA,CAxBW,EAyBZ,MAzBY,CAAb;eA4BeP,I","sourcesContent":["/**\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 * External dependencies\n */\nimport type { ComponentType, ComponentClass } from 'react';\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(\n\t< TProps extends Record< string, any > >(\n\t\tWrapped: ComponentType< TProps >\n\t) => {\n\t\tif ( Wrapped.prototype instanceof Component ) {\n\t\t\treturn class extends ( Wrapped as ComponentClass< TProps > ) {\n\t\t\t\tshouldComponentUpdate( nextProps: TProps, nextState: any ) {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! isShallowEqual( nextProps, this.props ) ||\n\t\t\t\t\t\t! isShallowEqual( nextState, this.state )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\treturn class extends Component< TProps > {\n\t\t\tshouldComponentUpdate( nextProps: TProps ) {\n\t\t\t\treturn ! isShallowEqual( nextProps, this.props );\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\treturn <Wrapped { ...this.props } />;\n\t\t\t}\n\t\t};\n\t},\n\t'pure'\n);\n\nexport default pure;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/pure/index.tsx"],"names":["pure","WrappedComponent","prototype","Component","shouldComponentUpdate","nextProps","nextState","props","state","render"],"mappings":";;;;;;;;;AASA;;AADA;;AAMA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA,MAAMA,IAAI,GAAG,4DAA4B,UACxCC,gBADwC,EAEf;AACzB,MAAKA,gBAAgB,CAACC,SAAjB,YAAsCC,kBAA3C,EAAuD;AACtD,WAAO,cAAgBF,gBAAhB,CAA8D;AACpEG,MAAAA,qBAAqB,CAAEC,SAAF,EAAoBC,SAApB,EAAqC;AACzD,eACC,CAAE,6BAAgBD,SAAhB,EAA2B,KAAKE,KAAhC,CAAF,IACA,CAAE,6BAAgBD,SAAhB,EAA2B,KAAKE,KAAhC,CAFH;AAIA;;AANmE,KAArE;AAQA;;AAED,SAAO,cAAcL,kBAAd,CAAiC;AACvCC,IAAAA,qBAAqB,CAAEC,SAAF,EAAqB;AACzC,aAAO,CAAE,6BAAgBA,SAAhB,EAA2B,KAAKE,KAAhC,CAAT;AACA;;AAEDE,IAAAA,MAAM,GAAG;AACR,aAAO,4BAAC,gBAAD,EAAuB,KAAKF,KAA5B,CAAP;AACA;;AAPsC,GAAxC;AASA,CAvBY,EAwBb,MAxBa,CAAb;eA0BeP,I","sourcesContent":["/**\n * External dependencies\n */\nimport type { ComponentType, ComponentClass } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * Given a component returns the enhanced component augmented with a component\n * only re-rendering when its props/state change\n */\nconst pure = createHigherOrderComponent( function < Props >(\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"]}
@@ -15,7 +15,7 @@ var _lodash = require("lodash");
15
15
 
16
16
  var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
17
17
 
18
- var _createHigherOrderComponent = _interopRequireDefault(require("../../utils/create-higher-order-component"));
18
+ var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
19
19
 
20
20
  var _listener = _interopRequireDefault(require("./listener"));
21
21
 
@@ -63,7 +63,7 @@ function withGlobalEvents(eventTypesToHandlers) {
63
63
  alternative: 'useEffect'
64
64
  }); // @ts-ignore We don't need to fix the type-related issues because this is deprecated.
65
65
 
66
- return (0, _createHigherOrderComponent.default)(WrappedComponent => {
66
+ return (0, _createHigherOrderComponent.createHigherOrderComponent)(WrappedComponent => {
67
67
  class Wrapper extends _element.Component {
68
68
  constructor(
69
69
  /** @type {any} */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/with-global-events/index.js"],"names":["listener","Listener","withGlobalEvents","eventTypesToHandlers","since","alternative","WrappedComponent","Wrapper","Component","constructor","props","handleEvent","bind","handleRef","componentDidMount","_","eventType","add","componentWillUnmount","remove","event","handler","type","wrappedRef","el","forwardedRef","render","ownProps","ref"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAMA;;AAKA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA,MAAMA,QAAQ,GAAG,IAAIC,iBAAJ,EAAjB;AAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASC,gBAAT,CAA2BC,oBAA3B,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AAKf,KAAL,CAAWe,YAAX,CAAyBD,EAAzB;AACA;AACD;;AAEDE,MAAAA,MAAM,GAAG;AACR,eACC,4BAAC,gBAAD,6BACM,KAAKhB,KAAL,CAAWiB,QADjB;AAEC,UAAA,GAAG,EAAG,KAAKd;AAFZ,WADD;AAMA;;AAhD8B;;AAmDhC,WAAO,yBAAY,CAAEH,KAAF,EAASkB,GAAT,KAAkB;AACpC,aAAO,4BAAC,OAAD;AAAS,QAAA,QAAQ,EAAGlB,KAApB;AAA4B,QAAA,YAAY,EAAGkB;AAA3C,QAAP;AACA,KAFM,CAAP;AAGA,GAvDM,EAuDJ,kBAvDI,CAAP;AAwDA","sourcesContent":["/**\n * External dependencies\n */\nimport { forEach } from 'lodash';\n\n/**\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\tforEach( eventTypesToHandlers, ( _, 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\tforEach( eventTypesToHandlers, ( _, 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} */ ( event.type )\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"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/with-global-events/index.js"],"names":["listener","Listener","withGlobalEvents","eventTypesToHandlers","since","alternative","WrappedComponent","Wrapper","Component","constructor","props","handleEvent","bind","handleRef","componentDidMount","_","eventType","add","componentWillUnmount","remove","event","handler","type","wrappedRef","el","forwardedRef","render","ownProps","ref"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAMA;;AAKA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;;AAIA;AACA;AACA;AACA,MAAMA,QAAQ,GAAG,IAAIC,iBAAJ,EAAjB;AAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASC,gBAAT,CAA2BC,oBAA3B,EAAkD;AAChE,2BAAY,6BAAZ,EAA2C;AAC1CC,IAAAA,KAAK,EAAE,KADmC;AAE1CC,IAAAA,WAAW,EAAE;AAF6B,GAA3C,EADgE,CAMhE;;AACA,SAAO,4DAA8BC,gBAAF,IAAwB;AAC1D,UAAMC,OAAN,SAAsBC,kBAAtB,CAAgC;AAC/BC,MAAAA,WAAW;AAAE;AAAmBC,MAAAA,KAArB,EAA6B;AACvC,cAAOA,KAAP;AAEA,aAAKC,WAAL,GAAmB,KAAKA,WAAL,CAAiBC,IAAjB,CAAuB,IAAvB,CAAnB;AACA,aAAKC,SAAL,GAAiB,KAAKA,SAAL,CAAeD,IAAf,CAAqB,IAArB,CAAjB;AACA;;AAEDE,MAAAA,iBAAiB,GAAG;AACnB,6BAASX,oBAAT,EAA+B,CAAEY,CAAF,EAAKC,SAAL,KAAoB;AAClDhB,UAAAA,QAAQ,CAACiB,GAAT,CAAcD,SAAd,EAAyB,IAAzB;AACA,SAFD;AAGA;;AAEDE,MAAAA,oBAAoB,GAAG;AACtB,6BAASf,oBAAT,EAA+B,CAAEY,CAAF,EAAKC,SAAL,KAAoB;AAClDhB,UAAAA,QAAQ,CAACmB,MAAT,CAAiBH,SAAjB,EAA4B,IAA5B;AACA,SAFD;AAGA;;AAEDL,MAAAA,WAAW;AAAE;AAAmBS,MAAAA,KAArB,EAA6B;AACvC,cAAMC,OAAO,GACZlB,oBAAoB;AACnB;AACCiB,QAAAA,KAAK,CAACE;AAEP;AAJmB,SADrB;;AAOA,YAAK,OAAO,KAAKC,UAAL,CAAiBF,OAAjB,CAAP,KAAsC,UAA3C,EAAwD;AACvD,eAAKE,UAAL,CAAiBF,OAAjB,EAA4BD,KAA5B;AACA;AACD;;AAEDP,MAAAA,SAAS;AAAE;AAAmBW,MAAAA,EAArB,EAA0B;AAClC,aAAKD,UAAL,GAAkBC,EAAlB,CADkC,CAElC;AACA;AACA;;AACA,YAAK,KAAKd,KAAL,CAAWe,YAAhB,EAA+B;AAC9B,eAAKf,KAAL,CAAWe,YAAX,CAAyBD,EAAzB;AACA;AACD;;AAEDE,MAAAA,MAAM,GAAG;AACR,eACC,4BAAC,gBAAD,6BACM,KAAKhB,KAAL,CAAWiB,QADjB;AAEC,UAAA,GAAG,EAAG,KAAKd;AAFZ,WADD;AAMA;;AAlD8B;;AAqDhC,WAAO,yBAAY,CAAEH,KAAF,EAASkB,GAAT,KAAkB;AACpC,aAAO,4BAAC,OAAD;AAAS,QAAA,QAAQ,EAAGlB,KAApB;AAA4B,QAAA,YAAY,EAAGkB;AAA3C,QAAP;AACA,KAFM,CAAP;AAGA,GAzDM,EAyDJ,kBAzDI,CAAP;AA0DA","sourcesContent":["/**\n * External dependencies\n */\nimport { forEach } from 'lodash';\n\n/**\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\tforEach( eventTypesToHandlers, ( _, 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\tforEach( eventTypesToHandlers, ( _, 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"]}
@@ -11,7 +11,7 @@ var _element = require("@wordpress/element");
11
11
 
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
14
- var _createHigherOrderComponent = _interopRequireDefault(require("../../utils/create-higher-order-component"));
14
+ var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
15
15
 
16
16
  var _useInstanceId = _interopRequireDefault(require("../../hooks/use-instance-id"));
17
17
 
@@ -23,7 +23,7 @@ var _useInstanceId = _interopRequireDefault(require("../../hooks/use-instance-id
23
23
  * A Higher Order Component used to be provide a unique instance ID by
24
24
  * component.
25
25
  */
26
- const withInstanceId = (0, _createHigherOrderComponent.default)(WrappedComponent => {
26
+ const withInstanceId = (0, _createHigherOrderComponent.createHigherOrderComponent)(WrappedComponent => {
27
27
  return props => {
28
28
  const instanceId = (0, _useInstanceId.default)(WrappedComponent); // @ts-ignore
29
29
 
@@ -31,7 +31,7 @@ const withInstanceId = (0, _createHigherOrderComponent.default)(WrappedComponent
31
31
  instanceId: instanceId
32
32
  }));
33
33
  };
34
- }, 'withInstanceId');
34
+ }, 'instanceId');
35
35
  var _default = withInstanceId;
36
36
  exports.default = _default;
37
37
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/with-instance-id/index.tsx"],"names":["withInstanceId","WrappedComponent","props","instanceId"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA,MAAMA,cAAc,GAAG,yCAEhBC,gBAAF,IAAwB;AAC5B,SAASC,KAAF,IAAa;AACnB,UAAMC,UAAU,GAAG,4BAAeF,gBAAf,CAAnB,CADmB,CAEnB;;AACA,WAAO,4BAAC,gBAAD,6BAAuBC,KAAvB;AAA+B,MAAA,UAAU,EAAGC;AAA5C,OAAP;AACA,GAJD;AAKA,CARsB,EAQpB,gBARoB,CAAvB;eAUeH,c","sourcesContent":["/**\n * Internal dependencies\n */\nimport createHigherOrderComponent from '../../utils/create-higher-order-component';\nimport useInstanceId from '../../hooks/use-instance-id';\n\n/**\n * A Higher Order Component used to be provide a unique instance ID by\n * component.\n */\nconst withInstanceId = createHigherOrderComponent< {\n\tinstanceId: string | number;\n} >( ( WrappedComponent ) => {\n\treturn ( props ) => {\n\t\tconst instanceId = useInstanceId( WrappedComponent );\n\t\t// @ts-ignore\n\t\treturn <WrappedComponent { ...props } instanceId={ instanceId } />;\n\t};\n}, 'withInstanceId' );\n\nexport default withInstanceId;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/with-instance-id/index.tsx"],"names":["withInstanceId","WrappedComponent","props","instanceId"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA,MAAMA,cAAc,GAAG,4DAErBC,gBADD,IAEK;AACJ,SAASC,KAAF,IAAyD;AAC/D,UAAMC,UAAU,GAAG,4BAAeF,gBAAf,CAAnB,CAD+D,CAE/D;;AACA,WAAO,4BAAC,gBAAD,6BAAuBC,KAAvB;AAA+B,MAAA,UAAU,EAAGC;AAA5C,OAAP;AACA,GAJD;AAKA,CATqB,EAUtB,YAVsB,CAAvB;eAaeH,c","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateHigherOrderComponent,\n\tWithInjectedProps,\n\tWithoutInjectedProps,\n} 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"]}
@@ -11,7 +11,7 @@ var _element = require("@wordpress/element");
11
11
 
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
14
- var _createHigherOrderComponent = _interopRequireDefault(require("../../utils/create-higher-order-component"));
14
+ var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
15
15
 
16
16
  var _usePreferredColorScheme = _interopRequireDefault(require("../../hooks/use-preferred-color-scheme"));
17
17
 
@@ -22,7 +22,7 @@ var _usePreferredColorScheme = _interopRequireDefault(require("../../hooks/use-p
22
22
  /**
23
23
  * WordPress dependencies
24
24
  */
25
- const withPreferredColorScheme = (0, _createHigherOrderComponent.default)(WrappedComponent => props => {
25
+ const withPreferredColorScheme = (0, _createHigherOrderComponent.createHigherOrderComponent)(WrappedComponent => props => {
26
26
  const colorScheme = (0, _usePreferredColorScheme.default)();
27
27
  const isDarkMode = colorScheme === 'dark';
28
28
  const getStyles = (0, _element.useCallback)((lightStyles, darkStyles) => {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/with-preferred-color-scheme/index.native.js"],"names":["withPreferredColorScheme","WrappedComponent","props","colorScheme","isDarkMode","getStyles","lightStyles","darkStyles","finalDarkStyles"],"mappings":";;;;;;;;;AASA;;;;AANA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AAGA,MAAMA,wBAAwB,GAAG,yCAC9BC,gBAAF,IAA0BC,KAAF,IAAa;AACpC,QAAMC,WAAW,GAAG,uCAApB;AACA,QAAMC,UAAU,GAAGD,WAAW,KAAK,MAAnC;AAEA,QAAME,SAAS,GAAG,0BACjB,CAAEC,WAAF,EAAeC,UAAf,KAA+B;AAC9B,UAAMC,eAAe,GAAG,EACvB,GAAGF,WADoB;AAEvB,SAAGC;AAFoB,KAAxB;AAKA,WAAOH,UAAU,GAAGI,eAAH,GAAqBF,WAAtC;AACA,GARgB,EASjB,CAAEF,UAAF,CATiB,CAAlB;AAYA,SACC,4BAAC,gBAAD;AACC,IAAA,oBAAoB,EAAGD,WADxB;AAEC,IAAA,wBAAwB,EAAGE;AAF5B,KAGMH,KAHN,EADD;AAOA,CAxB+B,EAyBhC,0BAzBgC,CAAjC;eA4BeF,wB","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"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/with-preferred-color-scheme/index.native.js"],"names":["withPreferredColorScheme","WrappedComponent","props","colorScheme","isDarkMode","getStyles","lightStyles","darkStyles","finalDarkStyles"],"mappings":";;;;;;;;;AASA;;;;AANA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AAGA,MAAMA,wBAAwB,GAAG,4DAC9BC,gBAAF,IAA0BC,KAAF,IAAa;AACpC,QAAMC,WAAW,GAAG,uCAApB;AACA,QAAMC,UAAU,GAAGD,WAAW,KAAK,MAAnC;AAEA,QAAME,SAAS,GAAG,0BACjB,CAAEC,WAAF,EAAeC,UAAf,KAA+B;AAC9B,UAAMC,eAAe,GAAG,EACvB,GAAGF,WADoB;AAEvB,SAAGC;AAFoB,KAAxB;AAKA,WAAOH,UAAU,GAAGI,eAAH,GAAqBF,WAAtC;AACA,GARgB,EASjB,CAAEF,UAAF,CATiB,CAAlB;AAYA,SACC,4BAAC,gBAAD;AACC,IAAA,oBAAoB,EAAGD,WADxB;AAEC,IAAA,wBAAwB,EAAGE;AAF5B,KAGMH,KAHN,EADD;AAOA,CAxB+B,EAyBhC,0BAzBgC,CAAjC;eA4BeF,wB","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"]}
@@ -9,9 +9,11 @@ exports.default = void 0;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
12
14
  var _lodash = require("lodash");
13
15
 
14
- var _createHigherOrderComponent = _interopRequireDefault(require("../../utils/create-higher-order-component"));
16
+ var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
15
17
 
16
18
  /**
17
19
  * External dependencies
@@ -29,7 +31,7 @@ var _createHigherOrderComponent = _interopRequireDefault(require("../../utils/cr
29
31
  * A higher-order component used to provide and manage delayed function calls
30
32
  * that ought to be bound to a component's lifecycle.
31
33
  */
32
- const withSafeTimeout = (0, _createHigherOrderComponent.default)(OriginalComponent => {
34
+ const withSafeTimeout = (0, _createHigherOrderComponent.createHigherOrderComponent)(OriginalComponent => {
33
35
  return class WrappedComponent extends _element.Component {
34
36
  constructor(props) {
35
37
  super(props);
@@ -57,11 +59,12 @@ const withSafeTimeout = (0, _createHigherOrderComponent.default)(OriginalCompone
57
59
  }
58
60
 
59
61
  render() {
60
- const props = { ...this.props,
61
- setTimeout: this.setTimeout,
62
- clearTimeout: this.clearTimeout
63
- };
64
- return (0, _element.createElement)(OriginalComponent, props);
62
+ return (// @ts-ignore
63
+ (0, _element.createElement)(OriginalComponent, (0, _extends2.default)({}, this.props, {
64
+ setTimeout: this.setTimeout,
65
+ clearTimeout: this.clearTimeout
66
+ }))
67
+ );
65
68
  }
66
69
 
67
70
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/with-safe-timeout/index.tsx"],"names":["withSafeTimeout","OriginalComponent","WrappedComponent","Component","constructor","props","timeouts","setTimeout","bind","clearTimeout","componentWillUnmount","forEach","fn","delay","id","push","render"],"mappings":";;;;;;;;;AASA;;AANA;;AAWA;;AAdA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA,MAAMA,eAAe,GAAG,yCAEtBC,iBADD,IAEK;AACJ,SAAO,MAAMC,gBAAN,SAA+BC,kBAA/B,CAEL;AAGDC,IAAAA,WAAW,CAAEC,KAAF,EAA8C;AACxD,YAAOA,KAAP;AACA,WAAKC,QAAL,GAAgB,EAAhB;AACA,WAAKC,UAAL,GAAkB,KAAKA,UAAL,CAAgBC,IAAhB,CAAsB,IAAtB,CAAlB;AACA,WAAKC,YAAL,GAAoB,KAAKA,YAAL,CAAkBD,IAAlB,CAAwB,IAAxB,CAApB;AACA;;AAEDE,IAAAA,oBAAoB,GAAG;AACtB,WAAKJ,QAAL,CAAcK,OAAd,CAAuBF,YAAvB;AACA;;AAEDF,IAAAA,UAAU,CAAEK,EAAF,EAAkCC,KAAlC,EAAkD;AAC3D,YAAMC,EAAE,GAAGP,UAAU,CAAE,MAAM;AAC5BK,QAAAA,EAAE;AACF,aAAKH,YAAL,CAAmBK,EAAnB;AACA,OAHoB,EAGlBD,KAHkB,CAArB;AAIA,WAAKP,QAAL,CAAcS,IAAd,CAAoBD,EAApB;AACA,aAAOA,EAAP;AACA;;AAEDL,IAAAA,YAAY,CAAEK,EAAF,EAAe;AAC1BL,MAAAA,YAAY,CAAEK,EAAF,CAAZ;AACA,WAAKR,QAAL,GAAgB,qBAAS,KAAKA,QAAd,EAAwBQ,EAAxB,CAAhB;AACA;;AAEDE,IAAAA,MAAM,GAAG;AACR,YAAMX,KAAK,GAAG,EACb,GAAG,KAAKA,KADK;AAEbE,QAAAA,UAAU,EAAE,KAAKA,UAFJ;AAGbE,QAAAA,YAAY,EAAE,KAAKA;AAHN,OAAd;AAMA,aAAO,4BAAC,iBAAD,EAAwBJ,KAAxB,CAAP;AACA;;AApCA,GAFF;AAwCA,CA5CsB,EA6CvB,iBA7CuB,CAAxB;eAgDeL,e","sourcesContent":["/**\n * External dependencies\n */\nimport { without } from 'lodash';\nimport type { ComponentType } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\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 */\ntype 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< TimeoutProps >(\n\t< TProps extends TimeoutProps >(\n\t\tOriginalComponent: ComponentType< TProps >\n\t) => {\n\t\treturn class WrappedComponent extends Component<\n\t\t\tOmit< TProps, keyof TimeoutProps >\n\t\t> {\n\t\t\ttimeouts: number[];\n\n\t\t\tconstructor( props: Omit< TProps, keyof TimeoutProps > ) {\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: ( ...args: any[] ) => 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 = without( this.timeouts, id );\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\tconst props = {\n\t\t\t\t\t...this.props,\n\t\t\t\t\tsetTimeout: this.setTimeout,\n\t\t\t\t\tclearTimeout: this.clearTimeout,\n\t\t\t\t} as TProps;\n\n\t\t\t\treturn <OriginalComponent { ...props } />;\n\t\t\t}\n\t\t};\n\t},\n\t'withSafeTimeout'\n);\n\nexport default withSafeTimeout;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/with-safe-timeout/index.tsx"],"names":["withSafeTimeout","OriginalComponent","WrappedComponent","Component","constructor","props","timeouts","setTimeout","bind","clearTimeout","componentWillUnmount","forEach","fn","delay","id","push","render"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAUA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA,MAAMA,eAAe,GAAG,4DAEtBC,iBADD,IAEK;AAEJ,SAAO,MAAMC,gBAAN,SAA+BC,kBAA/B,CAAyD;AAG/DC,IAAAA,WAAW,CAAEC,KAAF,EAAwB;AAClC,YAAOA,KAAP;AACA,WAAKC,QAAL,GAAgB,EAAhB;AACA,WAAKC,UAAL,GAAkB,KAAKA,UAAL,CAAgBC,IAAhB,CAAsB,IAAtB,CAAlB;AACA,WAAKC,YAAL,GAAoB,KAAKA,YAAL,CAAkBD,IAAlB,CAAwB,IAAxB,CAApB;AACA;;AAEDE,IAAAA,oBAAoB,GAAG;AACtB,WAAKJ,QAAL,CAAcK,OAAd,CAAuBF,YAAvB;AACA;;AAEDF,IAAAA,UAAU,CAAEK,EAAF,EAAkBC,KAAlB,EAAkC;AAC3C,YAAMC,EAAE,GAAGP,UAAU,CAAE,MAAM;AAC5BK,QAAAA,EAAE;AACF,aAAKH,YAAL,CAAmBK,EAAnB;AACA,OAHoB,EAGlBD,KAHkB,CAArB;AAIA,WAAKP,QAAL,CAAcS,IAAd,CAAoBD,EAApB;AACA,aAAOA,EAAP;AACA;;AAEDL,IAAAA,YAAY,CAAEK,EAAF,EAAe;AAC1BL,MAAAA,YAAY,CAAEK,EAAF,CAAZ;AACA,WAAKR,QAAL,GAAgB,qBAAS,KAAKA,QAAd,EAAwBQ,EAAxB,CAAhB;AACA;;AAEDE,IAAAA,MAAM,GAAG;AACR,aACC;AACA,oCAAC,iBAAD,6BACM,KAAKX,KADX;AAEC,UAAA,UAAU,EAAG,KAAKE,UAFnB;AAGC,UAAA,YAAY,EAAG,KAAKE;AAHrB;AAFD;AAQA;;AArC8D,GAAhE;AAuCA,CA5CsB,EA6CvB,iBA7CuB,CAAxB;eAgDeT,e","sourcesContent":["/**\n * External dependencies\n */\nimport { without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcreateHigherOrderComponent,\n\tWithInjectedProps,\n\tWithoutInjectedProps,\n} 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 = without( this.timeouts, id );\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"]}
@@ -13,7 +13,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
13
13
 
14
14
  var _deprecated = _interopRequireDefault(require("@wordpress/deprecated"));
15
15
 
16
- var _createHigherOrderComponent = _interopRequireDefault(require("../../utils/create-higher-order-component"));
16
+ var _createHigherOrderComponent = require("../../utils/create-higher-order-component");
17
17
 
18
18
  /**
19
19
  * WordPress dependencies
@@ -39,7 +39,7 @@ function withState() {
39
39
  since: '5.8',
40
40
  alternative: 'wp.element.useState'
41
41
  });
42
- return (0, _createHigherOrderComponent.default)(OriginalComponent => {
42
+ return (0, _createHigherOrderComponent.createHigherOrderComponent)(OriginalComponent => {
43
43
  return class WrappedComponent extends _element.Component {
44
44
  constructor(
45
45
  /** @type {any} */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/with-state/index.js"],"names":["withState","initialState","since","alternative","OriginalComponent","WrappedComponent","Component","constructor","props","setState","bind","state","render"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,SAAT,GAAwC;AAAA,MAApBC,YAAoB,uEAAL,EAAK;AACtD,2BAAY,sBAAZ,EAAoC;AACnCC,IAAAA,KAAK,EAAE,KAD4B;AAEnCC,IAAAA,WAAW,EAAE;AAFsB,GAApC;AAKA,SAAO,yCAA8BC,iBAAF,IAAyB;AAC3D,WAAO,MAAMC,gBAAN,SAA+BC,kBAA/B,CAAyC;AAC/CC,MAAAA,WAAW;AAAE;AAAmBC,MAAAA,KAArB,EAA6B;AACvC,cAAOA,KAAP;AAEA,aAAKC,QAAL,GAAgB,KAAKA,QAAL,CAAcC,IAAd,CAAoB,IAApB,CAAhB;AAEA,aAAKC,KAAL,GAAaV,YAAb;AACA;;AAEDW,MAAAA,MAAM,GAAG;AACR,eACC,4BAAC,iBAAD,6BACM,KAAKJ,KADX,EAEM,KAAKG,KAFX;AAGC,UAAA,QAAQ,EAAG,KAAKF;AAHjB,WADD;AAOA;;AAjB8C,KAAhD;AAmBA,GApBM,EAoBJ,WApBI,CAAP;AAqBA","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"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/with-state/index.js"],"names":["withState","initialState","since","alternative","OriginalComponent","WrappedComponent","Component","constructor","props","setState","bind","state","render"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,SAAT,GAAwC;AAAA,MAApBC,YAAoB,uEAAL,EAAK;AACtD,2BAAY,sBAAZ,EAAoC;AACnCC,IAAAA,KAAK,EAAE,KAD4B;AAEnCC,IAAAA,WAAW,EAAE;AAFsB,GAApC;AAKA,SAAO,4DAA8BC,iBAAF,IAAyB;AAC3D,WAAO,MAAMC,gBAAN,SAA+BC,kBAA/B,CAAyC;AAC/CC,MAAAA,WAAW;AAAE;AAAmBC,MAAAA,KAArB,EAA6B;AACvC,cAAOA,KAAP;AAEA,aAAKC,QAAL,GAAgB,KAAKA,QAAL,CAAcC,IAAd,CAAoB,IAApB,CAAhB;AAEA,aAAKC,KAAL,GAAaV,YAAb;AACA;;AAEDW,MAAAA,MAAM,GAAG;AACR,eACC,4BAAC,iBAAD,6BACM,KAAKJ,KADX,EAEM,KAAKG,KAFX;AAGC,UAAA,QAAQ,EAAG,KAAKF;AAHjB,WADD;AAOA;;AAjB8C,KAAhD;AAmBA,GApBM,EAoBJ,WApBI,CAAP;AAqBA","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"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-debounce/index.js"],"names":["useDebounce","fn","wait","options","debounced","cancel"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,WAAT,CAAsBC,EAAtB,EAA0BC,IAA1B,EAAgCC,OAAhC,EAA0C;AACxD;AACA,QAAMC,SAAS,GAAG,4BAAY,MAAM,sBAAUH,EAAV,EAAcC,IAAd,EAAoBC,OAApB,CAAlB,EAAiD,CAClEF,EADkE,EAElEC,IAFkE,EAGlEC,OAHkE,CAAjD,CAAlB;AAKA,0BAAW,MAAM,MAAMC,SAAS,CAACC,MAAV,EAAvB,EAA2C,CAAED,SAAF,CAA3C;AACA,SAAOA,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Debounces a function with 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('lodash').DebounceSettings} [options] The options object.\n * @return {import('lodash').DebouncedFunc<TFunc>} Debounced function.\n */\nexport default function useDebounce( fn, wait, options ) {\n\t/* eslint-enable jsdoc/valid-types */\n\tconst debounced = useMemoOne( () => debounce( fn, wait, options ), [\n\t\tfn,\n\t\twait,\n\t\toptions,\n\t] );\n\tuseEffect( () => () => debounced.cancel(), [ debounced ] );\n\treturn debounced;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-debounce/index.js"],"names":["useDebounce","fn","wait","options","debounced","cancel"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,WAAT,CAAsBC,EAAtB,EAA0BC,IAA1B,EAAgCC,OAAhC,EAA0C;AACxD;AACA,QAAMC,SAAS,GAAG,4BACjB,MAAM,sBAAUH,EAAV,EAAcC,IAAd,EAAoBC,OAApB,CADW,EAEjB,CAAEF,EAAF,EAAMC,IAAN,EAAYC,OAAZ,CAFiB,CAAlB;AAIA,0BAAW,MAAM,MAAMC,SAAS,CAACC,MAAV,EAAvB,EAA2C,CAAED,SAAF,CAA3C;AACA,SAAOA,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Debounces a function with 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('lodash').DebounceSettings} [options] The options object.\n * @return {import('lodash').DebouncedFunc<TFunc>} Debounced function.\n */\nexport default function useDebounce( fn, wait, options ) {\n\t/* eslint-enable jsdoc/valid-types */\n\tconst debounced = useMemoOne(\n\t\t() => debounce( fn, wait, options ),\n\t\t[ fn, wait, options ]\n\t);\n\tuseEffect( () => () => debounced.cancel(), [ debounced ] );\n\treturn debounced;\n}\n"]}
@@ -29,7 +29,9 @@ var _useMergeRefs = _interopRequireDefault(require("../use-merge-refs"));
29
29
  * Internal dependencies
30
30
  */
31
31
 
32
- /* eslint-disable jsdoc/valid-types */
32
+ /**
33
+ * @typedef {import('../use-focus-on-mount').default} useFocusOnMount
34
+ */
33
35
 
34
36
  /**
35
37
  * @typedef DialogOptions
@@ -37,8 +39,6 @@ var _useMergeRefs = _interopRequireDefault(require("../use-merge-refs"));
37
39
  * @property {() => void} onClose Function to call when the dialog is closed.
38
40
  */
39
41
 
40
- /* eslint-enable jsdoc/valid-types */
41
-
42
42
  /**
43
43
  * Returns a ref and props to apply to a dialog wrapper to enable the following behaviors:
44
44
  * - constrained tabbing.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-dialog/index.js"],"names":["useDialog","options","currentOptions","current","Object","values","constrainedTabbingRef","focusOnMountRef","focusOnMount","focusReturnRef","focusOutsideProps","event","__unstableOnClose","onClose","closeOnEscapeRef","node","addEventListener","keyCode","ESCAPE","defaultPrevented","preventDefault","tabIndex"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAT,CAAoBC,OAApB,EAA8B;AAC7B;AACD;AACA;AACC,QAAMC,cAAc,GAAG,sBAAvB;AACA,0BAAW,MAAM;AAChBA,IAAAA,cAAc,CAACC,OAAf,GAAyBF,OAAzB;AACA,GAFD,EAEGG,MAAM,CAACC,MAAP,CAAeJ,OAAf,CAFH;AAGA,QAAMK,qBAAqB,GAAG,qCAA9B;AACA,QAAMC,eAAe,GAAG,8BAAiBN,OAAO,CAACO,YAAzB,CAAxB;AACA,QAAMC,cAAc,GAAG,8BAAvB;AACA,QAAMC,iBAAiB,GAAG,8BAAmBC,KAAF,IAAa;AAAA;;AACvD;AACA;AACA;AACA,iCAAKT,cAAc,CAACC,OAApB,kDAAK,sBAAwBS,iBAA7B,EAAiD;AAChD;AACAV,MAAAA,cAAc,CAACC,OAAf,CAAuBS,iBAAvB,CAA0C,eAA1C,EAA2DD,KAA3D;AACA,KAHD,MAGO,8BAAKT,cAAc,CAACC,OAApB,mDAAK,uBAAwBU,OAA7B,EAAuC;AAC7CX,MAAAA,cAAc,CAACC,OAAf,CAAuBU,OAAvB;AACA;AACD,GAVyB,CAA1B;AAWA,QAAMC,gBAAgB,GAAG,0BAAeC,IAAF,IAAY;AACjD,QAAK,CAAEA,IAAP,EAAc;AACb;AACA;;AAEDA,IAAAA,IAAI,CAACC,gBAAL,CAAuB,SAAvB,EAAkC;AACjC;AAA6BL,IAAAA,KADI,KAE7B;AAAA;;AACJ;AACA,UACCA,KAAK,CAACM,OAAN,KAAkBC,gBAAlB,IACA,CAAEP,KAAK,CAACQ,gBADR,8BAEAjB,cAAc,CAACC,OAFf,mDAEA,uBAAwBU,OAHzB,EAIE;AACDF,QAAAA,KAAK,CAACS,cAAN;AACAlB,QAAAA,cAAc,CAACC,OAAf,CAAuBU,OAAvB;AACA;AACD,KAZD;AAaA,GAlBwB,EAkBtB,EAlBsB,CAAzB;AAoBA,SAAO,CACN,2BAAc,CACbZ,OAAO,CAACO,YAAR,KAAyB,KAAzB,GAAiCF,qBAAjC,GAAyD,IAD5C,EAEbL,OAAO,CAACO,YAAR,KAAyB,KAAzB,GAAiCC,cAAjC,GAAkD,IAFrC,EAGbR,OAAO,CAACO,YAAR,KAAyB,KAAzB,GAAiCD,eAAjC,GAAmD,IAHtC,EAIbO,gBAJa,CAAd,CADM,EAON,EACC,GAAGJ,iBADJ;AAECW,IAAAA,QAAQ,EAAE;AAFX,GAPM,CAAP;AAYA;;eAEcrB,S","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect, useCallback } from '@wordpress/element';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport useConstrainedTabbing from '../use-constrained-tabbing';\nimport useFocusOnMount from '../use-focus-on-mount';\nimport useFocusReturn from '../use-focus-return';\nimport useFocusOutside from '../use-focus-outside';\nimport useMergeRefs from '../use-merge-refs';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @typedef DialogOptions\n * @property {Parameters<useFocusOnMount>[0]} focusOnMount Focus on mount arguments.\n * @property {() => void} onClose Function to call when the dialog is closed.\n */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * Returns a ref and props to apply to a dialog wrapper to enable the following behaviors:\n * - constrained tabbing.\n * - focus on mount.\n * - return focus on unmount.\n * - focus outside.\n *\n * @param {DialogOptions} options Dialog Options.\n */\nfunction useDialog( options ) {\n\t/**\n\t * @type {import('react').MutableRefObject<DialogOptions | undefined>}\n\t */\n\tconst currentOptions = useRef();\n\tuseEffect( () => {\n\t\tcurrentOptions.current = options;\n\t}, Object.values( options ) );\n\tconst constrainedTabbingRef = useConstrainedTabbing();\n\tconst focusOnMountRef = useFocusOnMount( options.focusOnMount );\n\tconst focusReturnRef = useFocusReturn();\n\tconst focusOutsideProps = useFocusOutside( ( event ) => {\n\t\t// This unstable prop is here only to manage backward compatibility\n\t\t// for the Popover component otherwise, the onClose should be enough.\n\t\t// @ts-ignore unstable property\n\t\tif ( currentOptions.current?.__unstableOnClose ) {\n\t\t\t// @ts-ignore unstable property\n\t\t\tcurrentOptions.current.__unstableOnClose( 'focus-outside', event );\n\t\t} else if ( currentOptions.current?.onClose ) {\n\t\t\tcurrentOptions.current.onClose();\n\t\t}\n\t} );\n\tconst closeOnEscapeRef = useCallback( ( node ) => {\n\t\tif ( ! node ) {\n\t\t\treturn;\n\t\t}\n\n\t\tnode.addEventListener( 'keydown', (\n\t\t\t/** @type {KeyboardEvent} */ event\n\t\t) => {\n\t\t\t// Close on escape.\n\t\t\tif (\n\t\t\t\tevent.keyCode === ESCAPE &&\n\t\t\t\t! event.defaultPrevented &&\n\t\t\t\tcurrentOptions.current?.onClose\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tcurrentOptions.current.onClose();\n\t\t\t}\n\t\t} );\n\t}, [] );\n\n\treturn [\n\t\tuseMergeRefs( [\n\t\t\toptions.focusOnMount !== false ? constrainedTabbingRef : null,\n\t\t\toptions.focusOnMount !== false ? focusReturnRef : null,\n\t\t\toptions.focusOnMount !== false ? focusOnMountRef : null,\n\t\t\tcloseOnEscapeRef,\n\t\t] ),\n\t\t{\n\t\t\t...focusOutsideProps,\n\t\t\ttabIndex: '-1',\n\t\t},\n\t];\n}\n\nexport default useDialog;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-dialog/index.js"],"names":["useDialog","options","currentOptions","current","Object","values","constrainedTabbingRef","focusOnMountRef","focusOnMount","focusReturnRef","focusOutsideProps","event","__unstableOnClose","onClose","closeOnEscapeRef","node","addEventListener","keyCode","ESCAPE","defaultPrevented","preventDefault","tabIndex"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAT,CAAoBC,OAApB,EAA8B;AAC7B;AACD;AACA;AACC,QAAMC,cAAc,GAAG,sBAAvB;AACA,0BAAW,MAAM;AAChBA,IAAAA,cAAc,CAACC,OAAf,GAAyBF,OAAzB;AACA,GAFD,EAEGG,MAAM,CAACC,MAAP,CAAeJ,OAAf,CAFH;AAGA,QAAMK,qBAAqB,GAAG,qCAA9B;AACA,QAAMC,eAAe,GAAG,8BAAiBN,OAAO,CAACO,YAAzB,CAAxB;AACA,QAAMC,cAAc,GAAG,8BAAvB;AACA,QAAMC,iBAAiB,GAAG,8BAAmBC,KAAF,IAAa;AAAA;;AACvD;AACA;AACA;AACA,iCAAKT,cAAc,CAACC,OAApB,kDAAK,sBAAwBS,iBAA7B,EAAiD;AAChD;AACAV,MAAAA,cAAc,CAACC,OAAf,CAAuBS,iBAAvB,CAA0C,eAA1C,EAA2DD,KAA3D;AACA,KAHD,MAGO,8BAAKT,cAAc,CAACC,OAApB,mDAAK,uBAAwBU,OAA7B,EAAuC;AAC7CX,MAAAA,cAAc,CAACC,OAAf,CAAuBU,OAAvB;AACA;AACD,GAVyB,CAA1B;AAWA,QAAMC,gBAAgB,GAAG,0BAAeC,IAAF,IAAY;AACjD,QAAK,CAAEA,IAAP,EAAc;AACb;AACA;;AAEDA,IAAAA,IAAI,CAACC,gBAAL,CACC,SADD,EAEC;AAAE;AAA6BL,IAAAA,KAA/B,KAA0C;AAAA;;AACzC;AACA,UACCA,KAAK,CAACM,OAAN,KAAkBC,gBAAlB,IACA,CAAEP,KAAK,CAACQ,gBADR,8BAEAjB,cAAc,CAACC,OAFf,mDAEA,uBAAwBU,OAHzB,EAIE;AACDF,QAAAA,KAAK,CAACS,cAAN;AACAlB,QAAAA,cAAc,CAACC,OAAf,CAAuBU,OAAvB;AACA;AACD,KAZF;AAcA,GAnBwB,EAmBtB,EAnBsB,CAAzB;AAqBA,SAAO,CACN,2BAAc,CACbZ,OAAO,CAACO,YAAR,KAAyB,KAAzB,GAAiCF,qBAAjC,GAAyD,IAD5C,EAEbL,OAAO,CAACO,YAAR,KAAyB,KAAzB,GAAiCC,cAAjC,GAAkD,IAFrC,EAGbR,OAAO,CAACO,YAAR,KAAyB,KAAzB,GAAiCD,eAAjC,GAAmD,IAHtC,EAIbO,gBAJa,CAAd,CADM,EAON,EACC,GAAGJ,iBADJ;AAECW,IAAAA,QAAQ,EAAE;AAFX,GAPM,CAAP;AAYA;;eAEcrB,S","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect, useCallback } from '@wordpress/element';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport useConstrainedTabbing from '../use-constrained-tabbing';\nimport useFocusOnMount from '../use-focus-on-mount';\nimport useFocusReturn from '../use-focus-return';\nimport useFocusOutside from '../use-focus-outside';\nimport useMergeRefs from '../use-merge-refs';\n\n/**\n * @typedef {import('../use-focus-on-mount').default} useFocusOnMount\n */\n/**\n * @typedef DialogOptions\n * @property {Parameters<useFocusOnMount>[0]} focusOnMount Focus on mount arguments.\n * @property {() => void} onClose Function to call when the dialog is closed.\n */\n\n/**\n * Returns a ref and props to apply to a dialog wrapper to enable the following behaviors:\n * - constrained tabbing.\n * - focus on mount.\n * - return focus on unmount.\n * - focus outside.\n *\n * @param {DialogOptions} options Dialog Options.\n */\nfunction useDialog( options ) {\n\t/**\n\t * @type {import('react').MutableRefObject<DialogOptions | undefined>}\n\t */\n\tconst currentOptions = useRef();\n\tuseEffect( () => {\n\t\tcurrentOptions.current = options;\n\t}, Object.values( options ) );\n\tconst constrainedTabbingRef = useConstrainedTabbing();\n\tconst focusOnMountRef = useFocusOnMount( options.focusOnMount );\n\tconst focusReturnRef = useFocusReturn();\n\tconst focusOutsideProps = useFocusOutside( ( event ) => {\n\t\t// This unstable prop is here only to manage backward compatibility\n\t\t// for the Popover component otherwise, the onClose should be enough.\n\t\t// @ts-ignore unstable property\n\t\tif ( currentOptions.current?.__unstableOnClose ) {\n\t\t\t// @ts-ignore unstable property\n\t\t\tcurrentOptions.current.__unstableOnClose( 'focus-outside', event );\n\t\t} else if ( currentOptions.current?.onClose ) {\n\t\t\tcurrentOptions.current.onClose();\n\t\t}\n\t} );\n\tconst closeOnEscapeRef = useCallback( ( node ) => {\n\t\tif ( ! node ) {\n\t\t\treturn;\n\t\t}\n\n\t\tnode.addEventListener(\n\t\t\t'keydown',\n\t\t\t( /** @type {KeyboardEvent} */ event ) => {\n\t\t\t\t// Close on escape.\n\t\t\t\tif (\n\t\t\t\t\tevent.keyCode === ESCAPE &&\n\t\t\t\t\t! event.defaultPrevented &&\n\t\t\t\t\tcurrentOptions.current?.onClose\n\t\t\t\t) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tcurrentOptions.current.onClose();\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}, [] );\n\n\treturn [\n\t\tuseMergeRefs( [\n\t\t\toptions.focusOnMount !== false ? constrainedTabbingRef : null,\n\t\t\toptions.focusOnMount !== false ? focusReturnRef : null,\n\t\t\toptions.focusOnMount !== false ? focusOnMountRef : null,\n\t\t\tcloseOnEscapeRef,\n\t\t] ),\n\t\t{\n\t\t\t...focusOutsideProps,\n\t\t\ttabIndex: '-1',\n\t\t},\n\t];\n}\n\nexport default useDialog;\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-disabled/index.js"],"names":["DISABLED_ELIGIBLE_NODE_NAMES","useDisabled","isDisabled","isDisabledProp","node","updates","disable","style","getPropertyValue","previousValue","setProperty","push","isConnected","focus","focusable","find","forEach","nodeName","disabled","setAttribute","getAttribute","removeAttribute","tabIndex","hasAttribute","ownerDocument","defaultView","HTMLElement","debouncedDisable","undefined","leading","observer","window","MutationObserver","observe","childList","attributes","subtree","disconnect","cancel","update"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,4BAA4B,GAAG,CACpC,QADoC,EAEpC,UAFoC,EAGpC,OAHoC,EAIpC,UAJoC,EAKpC,QALoC,EAMpC,QANoC,EAOpC,UAPoC,CAArC;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASC,WAAT,GAEN;AAAA,MAF4B;AACpCC,IAAAA,UAAU,EAAEC,cAAc,GAAG;AADO,GAE5B,uEAAL,EAAK;AACR,SAAO,2BACJC,IAAF,IAAY;AACX,QAAKD,cAAL,EAAsB;AACrB;AACA;AAED;;AACA;;;AACA,UAAME,OAAO,GAAG,EAAhB;;AAEA,UAAMC,OAAO,GAAG,MAAM;AACrB,UAAKF,IAAI,CAACG,KAAL,CAAWC,gBAAX,CAA6B,aAA7B,MAAiD,MAAtD,EAA+D;AAC9D,cAAMC,aAAa,GAAGL,IAAI,CAACG,KAAL,CAAWC,gBAAX,CACrB,aADqB,CAAtB;AAGAJ,QAAAA,IAAI,CAACG,KAAL,CAAWG,WAAX,CAAwB,aAAxB,EAAuC,MAAvC;AACAN,QAAAA,IAAI,CAACG,KAAL,CAAWG,WAAX,CAAwB,qBAAxB,EAA+C,MAA/C;AACAL,QAAAA,OAAO,CAACM,IAAR,CAAc,MAAM;AACnB,cAAK,CAAEP,IAAI,CAACQ,WAAZ,EAA0B;AACzB;AACA;;AACDR,UAAAA,IAAI,CAACG,KAAL,CAAWG,WA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,GAAG,IAAIC,MAAM,CAACC,gBAAX,CAA6BL,gBAA7B,CAAjB;AACAG,IAAAA,QAAQ,CAACG,OAAT,CAAkB7B,IAAlB,EAAwB;AACvB8B,MAAAA,SAAS,EAAE,IADY;AAEvBC,MAAAA,UAAU,EAAE,IAFW;AAGvBC,MAAAA,OAAO,EAAE;AAHc,KAAxB;AAMA,WAAO,MAAM;AACZ,UAAKN,QAAL,EAAgB;AACfA,QAAAA,QAAQ,CAACO,UAAT;AACA;;AACDV,MAAAA,gBAAgB,CAACW,MAAjB;AACAjC,MAAAA,OAAO,CAACW,OAAR,CAAmBuB,MAAF,IAAcA,MAAM,EAArC;AACA,KAND;AAOA,GA3IK,EA4IN,CAAEpC,cAAF,CA5IM,CAAP;AA8IA","sourcesContent":["/**\n * External dependencies\n */\nimport { includes, debounce } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { focus } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport useRefEffect from '../use-ref-effect';\n\n/**\n * Names of control nodes which qualify for disabled behavior.\n *\n * See WHATWG HTML Standard: 4.10.18.5: \"Enabling and disabling form controls: the disabled attribute\".\n *\n * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#enabling-and-disabling-form-controls:-the-disabled-attribute\n *\n * @type {string[]}\n */\nconst DISABLED_ELIGIBLE_NODE_NAMES = [\n\t'BUTTON',\n\t'FIELDSET',\n\t'INPUT',\n\t'OPTGROUP',\n\t'OPTION',\n\t'SELECT',\n\t'TEXTAREA',\n];\n\n/**\n * In some circumstances, such as block previews, all focusable DOM elements\n * (input fields, links, buttons, etc.) need to be disabled. This hook adds the\n * behavior to disable nested DOM elements to the returned ref.\n *\n * @param {Object} config Configuration object.\n * @param {boolean=} config.isDisabled Whether the element should be disabled.\n * @return {import('react').RefCallback<HTMLElement>} Element Ref.\n *\n * @example\n * ```js\n * import { useDisabled } from '@wordpress/compose';\n * const DisabledExample = () => {\n * \tconst disabledRef = useDisabled();\n *\treturn (\n *\t\t<div ref={ disabledRef }>\n *\t\t\t<a href=\"#\">This link will have tabindex set to -1</a>\n *\t\t\t<input placeholder=\"This input will have the disabled attribute added to it.\" type=\"text\" />\n *\t\t</div>\n *\t);\n * };\n * ```\n */\nexport default function useDisabled( {\n\tisDisabled: isDisabledProp = false,\n} = {} ) {\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( isDisabledProp ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t/** A variable keeping track of the previous updates in order to restore them. */\n\t\t\t/** @type {Function[]} */\n\t\t\tconst updates = [];\n\n\t\t\tconst disable = () => {\n\t\t\t\tif ( node.style.getPropertyValue( 'user-select' ) !== 'none' ) {\n\t\t\t\t\tconst previousValue = node.style.getPropertyValue(\n\t\t\t\t\t\t'user-select'\n\t\t\t\t\t);\n\t\t\t\t\tnode.style.setProperty( 'user-select', 'none' );\n\t\t\t\t\tnode.style.setProperty( '-webkit-user-select', 'none' );\n\t\t\t\t\tupdates.push( () => {\n\t\t\t\t\t\tif ( ! node.isConnected ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnode.style.setProperty( 'user-select', previousValue );\n\t\t\t\t\t\tnode.style.setProperty(\n\t\t\t\t\t\t\t'-webkit-user-select',\n\t\t\t\t\t\t\tpreviousValue\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tfocus.focusable.find( node ).forEach( ( focusable ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tincludes(\n\t\t\t\t\t\t\tDISABLED_ELIGIBLE_NODE_NAMES,\n\t\t\t\t\t\t\tfocusable.nodeName\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t! focusable.disabled\n\t\t\t\t\t) {\n\t\t\t\t\t\tfocusable.setAttribute( 'disabled', '' );\n\t\t\t\t\t\tupdates.push( () => {\n\t\t\t\t\t\t\tif ( ! focusable.isConnected ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tfocusable.disabled = false;\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tfocusable.nodeName === 'A' &&\n\t\t\t\t\t\tfocusable.getAttribute( 'tabindex' ) !== '-1'\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst previousValue = focusable.getAttribute(\n\t\t\t\t\t\t\t'tabindex'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tfocusable.setAttribute( 'tabindex', '-1' );\n\t\t\t\t\t\tupdates.push( () => {\n\t\t\t\t\t\t\tif ( ! focusable.isConnected ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ( ! previousValue ) {\n\t\t\t\t\t\t\t\tfocusable.removeAttribute( 'tabindex' );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tfocusable.setAttribute(\n\t\t\t\t\t\t\t\t\t'tabindex',\n\t\t\t\t\t\t\t\t\tpreviousValue\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\tconst tabIndex = focusable.getAttribute( 'tabindex' );\n\t\t\t\t\tif ( tabIndex !== null && tabIndex !== '-1' ) {\n\t\t\t\t\t\tfocusable.removeAttribute( 'tabindex' );\n\t\t\t\t\t\tupdates.push( () => {\n\t\t\t\t\t\t\tif ( ! focusable.isConnected ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfocusable.setAttribute( 'tabindex', tabIndex );\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tfocusable.hasAttribute( 'contenteditable' ) &&\n\t\t\t\t\t\tfocusable.getAttribute( 'contenteditable' ) !== 'false'\n\t\t\t\t\t) {\n\t\t\t\t\t\tfocusable.setAttribute( 'contenteditable', 'false' );\n\t\t\t\t\t\tupdates.push( () => {\n\t\t\t\t\t\t\tif ( ! focusable.isConnected ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfocusable.setAttribute( 'contenteditable', 'true' );\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.ownerDocument.defaultView?.HTMLElement &&\n\t\t\t\t\t\tfocusable instanceof\n\t\t\t\t\t\t\tnode.ownerDocument.defaultView.HTMLElement\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst previousValue = focusable.style.getPropertyValue(\n\t\t\t\t\t\t\t'pointer-events'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tfocusable.style.setProperty( 'pointer-events', 'none' );\n\t\t\t\t\t\tupdates.push( () => {\n\t\t\t\t\t\t\tif ( ! focusable.isConnected ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfocusable.style.setProperty(\n\t\t\t\t\t\t\t\t'pointer-events',\n\t\t\t\t\t\t\t\tpreviousValue\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t};\n\n\t\t\t// Debounce re-disable since disabling process itself will incur\n\t\t\t// additional mutations which should be ignored.\n\t\t\tconst debouncedDisable = debounce( disable, undefined, {\n\t\t\t\tleading: true,\n\t\t\t} );\n\t\t\tdisable();\n\n\t\t\t/** @type {MutationObserver | undefined} */\n\t\t\tconst observer = new window.MutationObserver( debouncedDisable );\n\t\t\tobserver.observe( node, {\n\t\t\t\tchildList: true,\n\t\t\t\tattributes: true,\n\t\t\t\tsubtree: true,\n\t\t\t} );\n\n\t\t\treturn () => {\n\t\t\t\tif ( observer ) {\n\t\t\t\t\tobserver.disconnect();\n\t\t\t\t}\n\t\t\t\tdebouncedDisable.cancel();\n\t\t\t\tupdates.forEach( ( update ) => update() );\n\t\t\t};\n\t\t},\n\t\t[ isDisabledProp ]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-disabled/index.js"],"names":["DISABLED_ELIGIBLE_NODE_NAMES","useDisabled","isDisabled","isDisabledProp","node","updates","disable","style","getPropertyValue","previousValue","setProperty","push","isConnected","focus","focusable","find","forEach","nodeName","disabled","setAttribute","getAttribute","removeAttribute","tabIndex","hasAttribute","ownerDocument","defaultView","HTMLElement","debouncedDisable","undefined","leading","observer","window","MutationObserver","observe","childList","attributes","subtree","disconnect","cancel","update"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,4BAA4B,GAAG,CACpC,QADoC,EAEpC,UAFoC,EAGpC,OAHoC,EAIpC,UAJoC,EAKpC,QALoC,EAMpC,QANoC,EAOpC,UAPoC,CAArC;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASC,WAAT,GAEN;AAAA,MAF4B;AACpCC,IAAAA,UAAU,EAAEC,cAAc,GAAG;AADO,GAE5B,uEAAL,EAAK;AACR,SAAO,2BACJC,IAAF,IAAY;AACX,QAAKD,cAAL,EAAsB;AACrB;AACA;AAED;;AACA;;;AACA,UAAME,OAAO,GAAG,EAAhB;;AAEA,UAAMC,OAAO,GAAG,MAAM;AACrB,UAAKF,IAAI,CAACG,KAAL,CAAWC,gBAAX,CAA6B,aAA7B,MAAiD,MAAtD,EAA+D;AAC9D,cAAMC,aAAa,GAClBL,IAAI,CAACG,KAAL,CAAWC,gBAAX,CAA6B,aAA7B,CADD;AAEAJ,QAAAA,IAAI,CAACG,KAAL,CAAWG,WAAX,CAAwB,aAAxB,EAAuC,M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A,WARD;AASA;AACD,OArFD;AAsFA,KAxGD,CATW,CAmHX;AACA;;;AACA,UAAMkB,gBAAgB,GAAG,sBAAUrB,OAAV,EAAmBsB,SAAnB,EAA8B;AACtDC,MAAAA,OAAO,EAAE;AAD6C,KAA9B,CAAzB;AAGAvB,IAAAA,OAAO;AAEP;;AACA,UAAMwB,QAAQ,GAAG,IAAIC,MAAM,CAACC,gBAAX,CAA6BL,gBAA7B,CAAjB;AACAG,IAAAA,QAAQ,CAACG,OAAT,CAAkB7B,IAAlB,EAAwB;AACvB8B,MAAAA,SAAS,EAAE,IADY;AAEvBC,MAAAA,UAAU,EAAE,IAFW;AAGvBC,MAAAA,OAAO,EAAE;AAHc,KAAxB;AAMA,WAAO,MAAM;AACZ,UAAKN,QAAL,EAAgB;AACfA,QAAAA,QAAQ,CAACO,UAAT;AACA;;AACDV,MAAAA,gBAAgB,CAACW,MAAjB;AACAjC,MAAAA,OAAO,CAACW,OAAR,CAAmBuB,MAAF,IAAcA,MAAM,EAArC;AACA,KAND;AAOA,GA1IK,EA2IN,CAAEpC,cAAF,CA3IM,CAAP;AA6IA","sourcesContent":["/**\n * External dependencies\n */\nimport { includes, debounce } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { focus } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport useRefEffect from '../use-ref-effect';\n\n/**\n * Names of control nodes which qualify for disabled behavior.\n *\n * See WHATWG HTML Standard: 4.10.18.5: \"Enabling and disabling form controls: the disabled attribute\".\n *\n * @see https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#enabling-and-disabling-form-controls:-the-disabled-attribute\n *\n * @type {string[]}\n */\nconst DISABLED_ELIGIBLE_NODE_NAMES = [\n\t'BUTTON',\n\t'FIELDSET',\n\t'INPUT',\n\t'OPTGROUP',\n\t'OPTION',\n\t'SELECT',\n\t'TEXTAREA',\n];\n\n/**\n * In some circumstances, such as block previews, all focusable DOM elements\n * (input fields, links, buttons, etc.) need to be disabled. This hook adds the\n * behavior to disable nested DOM elements to the returned ref.\n *\n * @param {Object} config Configuration object.\n * @param {boolean=} config.isDisabled Whether the element should be disabled.\n * @return {import('react').RefCallback<HTMLElement>} Element Ref.\n *\n * @example\n * ```js\n * import { useDisabled } from '@wordpress/compose';\n * const DisabledExample = () => {\n * \tconst disabledRef = useDisabled();\n *\treturn (\n *\t\t<div ref={ disabledRef }>\n *\t\t\t<a href=\"#\">This link will have tabindex set to -1</a>\n *\t\t\t<input placeholder=\"This input will have the disabled attribute added to it.\" type=\"text\" />\n *\t\t</div>\n *\t);\n * };\n * ```\n */\nexport default function useDisabled( {\n\tisDisabled: isDisabledProp = false,\n} = {} ) {\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( isDisabledProp ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t/** A variable keeping track of the previous updates in order to restore them. */\n\t\t\t/** @type {Function[]} */\n\t\t\tconst updates = [];\n\n\t\t\tconst disable = () => {\n\t\t\t\tif ( node.style.getPropertyValue( 'user-select' ) !== 'none' ) {\n\t\t\t\t\tconst previousValue =\n\t\t\t\t\t\tnode.style.getPropertyValue( 'user-select' );\n\t\t\t\t\tnode.style.setProperty( 'user-select', 'none' );\n\t\t\t\t\tnode.style.setProperty( '-webkit-user-select', 'none' );\n\t\t\t\t\tupdates.push( () => {\n\t\t\t\t\t\tif ( ! node.isConnected ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnode.style.setProperty( 'user-select', previousValue );\n\t\t\t\t\t\tnode.style.setProperty(\n\t\t\t\t\t\t\t'-webkit-user-select',\n\t\t\t\t\t\t\tpreviousValue\n\t\t\t\t\t\t);\n\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tfocus.focusable.find( node ).forEach( ( focusable ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tincludes(\n\t\t\t\t\t\t\tDISABLED_ELIGIBLE_NODE_NAMES,\n\t\t\t\t\t\t\tfocusable.nodeName\n\t\t\t\t\t\t) &&\n\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t! focusable.disabled\n\t\t\t\t\t) {\n\t\t\t\t\t\tfocusable.setAttribute( 'disabled', '' );\n\t\t\t\t\t\tupdates.push( () => {\n\t\t\t\t\t\t\tif ( ! focusable.isConnected ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tfocusable.disabled = false;\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tfocusable.nodeName === 'A' &&\n\t\t\t\t\t\tfocusable.getAttribute( 'tabindex' ) !== '-1'\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst previousValue =\n\t\t\t\t\t\t\tfocusable.getAttribute( 'tabindex' );\n\t\t\t\t\t\tfocusable.setAttribute( 'tabindex', '-1' );\n\t\t\t\t\t\tupdates.push( () => {\n\t\t\t\t\t\t\tif ( ! focusable.isConnected ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tif ( ! previousValue ) {\n\t\t\t\t\t\t\t\tfocusable.removeAttribute( 'tabindex' );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tfocusable.setAttribute(\n\t\t\t\t\t\t\t\t\t'tabindex',\n\t\t\t\t\t\t\t\t\tpreviousValue\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\tconst tabIndex = focusable.getAttribute( 'tabindex' );\n\t\t\t\t\tif ( tabIndex !== null && tabIndex !== '-1' ) {\n\t\t\t\t\t\tfocusable.removeAttribute( 'tabindex' );\n\t\t\t\t\t\tupdates.push( () => {\n\t\t\t\t\t\t\tif ( ! focusable.isConnected ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfocusable.setAttribute( 'tabindex', tabIndex );\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tfocusable.hasAttribute( 'contenteditable' ) &&\n\t\t\t\t\t\tfocusable.getAttribute( 'contenteditable' ) !== 'false'\n\t\t\t\t\t) {\n\t\t\t\t\t\tfocusable.setAttribute( 'contenteditable', 'false' );\n\t\t\t\t\t\tupdates.push( () => {\n\t\t\t\t\t\t\tif ( ! focusable.isConnected ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfocusable.setAttribute( 'contenteditable', 'true' );\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.ownerDocument.defaultView?.HTMLElement &&\n\t\t\t\t\t\tfocusable instanceof\n\t\t\t\t\t\t\tnode.ownerDocument.defaultView.HTMLElement\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst previousValue =\n\t\t\t\t\t\t\tfocusable.style.getPropertyValue(\n\t\t\t\t\t\t\t\t'pointer-events'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tfocusable.style.setProperty( 'pointer-events', 'none' );\n\t\t\t\t\t\tupdates.push( () => {\n\t\t\t\t\t\t\tif ( ! focusable.isConnected ) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfocusable.style.setProperty(\n\t\t\t\t\t\t\t\t'pointer-events',\n\t\t\t\t\t\t\t\tpreviousValue\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t};\n\n\t\t\t// Debounce re-disable since disabling process itself will incur\n\t\t\t// additional mutations which should be ignored.\n\t\t\tconst debouncedDisable = debounce( disable, undefined, {\n\t\t\t\tleading: true,\n\t\t\t} );\n\t\t\tdisable();\n\n\t\t\t/** @type {MutationObserver | undefined} */\n\t\t\tconst observer = new window.MutationObserver( debouncedDisable );\n\t\t\tobserver.observe( node, {\n\t\t\t\tchildList: true,\n\t\t\t\tattributes: true,\n\t\t\t\tsubtree: true,\n\t\t\t} );\n\n\t\t\treturn () => {\n\t\t\t\tif ( observer ) {\n\t\t\t\t\tobserver.disconnect();\n\t\t\t\t}\n\t\t\t\tdebouncedDisable.cancel();\n\t\t\t\tupdates.forEach( ( update ) => update() );\n\t\t\t};\n\t\t},\n\t\t[ isDisabledProp ]\n\t);\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-focus-return/index.js"],"names":["useFocusReturn","onFocusReturn","ref","focusedBeforeMount","onFocusReturnRef","current","node","ownerDocument","activeElement","isFocused","contains","isConnected","focus"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,cAAT,CAAyBC,aAAzB,EAAyC;AACxC;AACA,QAAMC,GAAG,GAAG,qBAAQ,IAAR,CAAZ;AACA;;AACA,QAAMC,kBAAkB,GAAG,qBAAQ,IAAR,CAA3B;AACA,QAAMC,gBAAgB,GAAG,qBAAQH,aAAR,CAAzB;AACA,0BAAW,MAAM;AAChBG,IAAAA,gBAAgB,CAACC,OAAjB,GAA2BJ,aAA3B;AACA,GAFD,EAEG,CAAEA,aAAF,CAFH;AAIA,SAAO,0BAAeK,IAAF,IAAY;AAC/B,QAAKA,IAAL,EAAY;AACX;AACAJ,MAAAA,GAAG,CAACG,OAAJ,GAAcC,IAAd,CAFW,CAIX;;AACA,UAAKH,kBAAkB,CAACE,OAAxB,EAAkC;AACjC;AACA;;AAEDF,MAAAA,kBAAkB,CAACE,OAAnB,GAA6BC,IAAI,CAACC,aAAL,CAAmBC,aAAhD;AACA,KAVD,MAUO,IAAKL,kBAAkB,CAACE,OAAxB,EAAkC;AAAA;;AACxC,YAAMI,SAAS,mBAAGP,GAAG,CAACG,OAAP,iDAAG,aAAaK,QAAb,kBACjBR,GAAG,CAACG,OADa,kDACjB,cAAaE,aAAb,CAA2BC,aADV,CAAlB;;AAIA,UAAK,iBAAAN,GAAG,CAACG,OAAJ,wDAAaM,WAAb,IAA4B,CAAEF,SAAnC,EAA+C;AAC9C;AACA,OAPuC,CASxC;AACA;AACA;AACA;;;AACA,UAAKL,gBAAgB,CAACC,OAAtB,EAAgC;AAC/BD,QAAAA,gBAAgB,CAACC,OAAjB;AACA,OAFD,MAEO;AAAA;;AACN;AAAkC,iCAAEF,kBAAkB,CAACE,OAArB,gFAAgCO,KAAhC;AAClC;AACD;AACD,GA9BM,EA8BJ,EA9BI,CAAP;AA+BA;;eAEcZ,c","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect, useCallback } from '@wordpress/element';\n\n/**\n * When opening modals/sidebars/dialogs, the focus\n * must move to the opened area and return to the\n * previously focused element when closed.\n * The current hook implements the returning behavior.\n *\n * @param {() => void} [onFocusReturn] Overrides the default return behavior.\n * @return {import('react').RefCallback<HTMLElement>} Element Ref.\n *\n * @example\n * ```js\n * import { useFocusReturn } from '@wordpress/compose';\n *\n * const WithFocusReturn = () => {\n * const ref = useFocusReturn()\n * return (\n * <div ref={ ref }>\n * <Button />\n * <Button />\n * </div>\n * );\n * }\n * ```\n */\nfunction useFocusReturn( onFocusReturn ) {\n\t/** @type {import('react').MutableRefObject<null | HTMLElement>} */\n\tconst ref = useRef( null );\n\t/** @type {import('react').MutableRefObject<null | Element>} */\n\tconst focusedBeforeMount = useRef( null );\n\tconst onFocusReturnRef = useRef( onFocusReturn );\n\tuseEffect( () => {\n\t\tonFocusReturnRef.current = onFocusReturn;\n\t}, [ onFocusReturn ] );\n\n\treturn useCallback( ( node ) => {\n\t\tif ( node ) {\n\t\t\t// Set ref to be used when unmounting.\n\t\t\tref.current = node;\n\n\t\t\t// Only set when the node mounts.\n\t\t\tif ( focusedBeforeMount.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfocusedBeforeMount.current = node.ownerDocument.activeElement;\n\t\t} else if ( focusedBeforeMount.current ) {\n\t\t\tconst isFocused = ref.current?.contains(\n\t\t\t\tref.current?.ownerDocument.activeElement\n\t\t\t);\n\n\t\t\tif ( ref.current?.isConnected && ! isFocused ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Defer to the component's own explicit focus return behavior, if\n\t\t\t// specified. This allows for support that the `onFocusReturn`\n\t\t\t// decides to allow the default behavior to occur under some\n\t\t\t// conditions.\n\t\t\tif ( onFocusReturnRef.current ) {\n\t\t\t\tonFocusReturnRef.current();\n\t\t\t} else {\n\t\t\t\t/** @type {null | HTMLElement} */ ( focusedBeforeMount.current )?.focus();\n\t\t\t}\n\t\t}\n\t}, [] );\n}\n\nexport default useFocusReturn;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-focus-return/index.js"],"names":["useFocusReturn","onFocusReturn","ref","focusedBeforeMount","onFocusReturnRef","current","node","ownerDocument","activeElement","isFocused","contains","isConnected","focus"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,cAAT,CAAyBC,aAAzB,EAAyC;AACxC;AACA,QAAMC,GAAG,GAAG,qBAAQ,IAAR,CAAZ;AACA;;AACA,QAAMC,kBAAkB,GAAG,qBAAQ,IAAR,CAA3B;AACA,QAAMC,gBAAgB,GAAG,qBAAQH,aAAR,CAAzB;AACA,0BAAW,MAAM;AAChBG,IAAAA,gBAAgB,CAACC,OAAjB,GAA2BJ,aAA3B;AACA,GAFD,EAEG,CAAEA,aAAF,CAFH;AAIA,SAAO,0BAAeK,IAAF,IAAY;AAC/B,QAAKA,IAAL,EAAY;AACX;AACAJ,MAAAA,GAAG,CAACG,OAAJ,GAAcC,IAAd,CAFW,CAIX;;AACA,UAAKH,kBAAkB,CAACE,OAAxB,EAAkC;AACjC;AACA;;AAEDF,MAAAA,kBAAkB,CAACE,OAAnB,GAA6BC,IAAI,CAACC,aAAL,CAAmBC,aAAhD;AACA,KAVD,MAUO,IAAKL,kBAAkB,CAACE,OAAxB,EAAkC;AAAA;;AACxC,YAAMI,SAAS,mBAAGP,GAAG,CAACG,OAAP,iDAAG,aAAaK,QAAb,kBACjBR,GAAG,CAACG,OADa,kDACjB,cAAaE,aAAb,CAA2BC,aADV,CAAlB;;AAIA,UAAK,iBAAAN,GAAG,CAACG,OAAJ,wDAAaM,WAAb,IAA4B,CAAEF,SAAnC,EAA+C;AAC9C;AACA,OAPuC,CASxC;AACA;AACA;AACA;;;AACA,UAAKL,gBAAgB,CAACC,OAAtB,EAAgC;AAC/BD,QAAAA,gBAAgB,CAACC,OAAjB;AACA,OAFD,MAEO;AAAA;;AACN;AAAkC,iCACjCF,kBAAkB,CAACE,OADc,gFAE/BO,KAF+B;AAGlC;AACD;AACD,GAhCM,EAgCJ,EAhCI,CAAP;AAiCA;;eAEcZ,c","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect, useCallback } from '@wordpress/element';\n\n/**\n * When opening modals/sidebars/dialogs, the focus\n * must move to the opened area and return to the\n * previously focused element when closed.\n * The current hook implements the returning behavior.\n *\n * @param {() => void} [onFocusReturn] Overrides the default return behavior.\n * @return {import('react').RefCallback<HTMLElement>} Element Ref.\n *\n * @example\n * ```js\n * import { useFocusReturn } from '@wordpress/compose';\n *\n * const WithFocusReturn = () => {\n * const ref = useFocusReturn()\n * return (\n * <div ref={ ref }>\n * <Button />\n * <Button />\n * </div>\n * );\n * }\n * ```\n */\nfunction useFocusReturn( onFocusReturn ) {\n\t/** @type {import('react').MutableRefObject<null | HTMLElement>} */\n\tconst ref = useRef( null );\n\t/** @type {import('react').MutableRefObject<null | Element>} */\n\tconst focusedBeforeMount = useRef( null );\n\tconst onFocusReturnRef = useRef( onFocusReturn );\n\tuseEffect( () => {\n\t\tonFocusReturnRef.current = onFocusReturn;\n\t}, [ onFocusReturn ] );\n\n\treturn useCallback( ( node ) => {\n\t\tif ( node ) {\n\t\t\t// Set ref to be used when unmounting.\n\t\t\tref.current = node;\n\n\t\t\t// Only set when the node mounts.\n\t\t\tif ( focusedBeforeMount.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfocusedBeforeMount.current = node.ownerDocument.activeElement;\n\t\t} else if ( focusedBeforeMount.current ) {\n\t\t\tconst isFocused = ref.current?.contains(\n\t\t\t\tref.current?.ownerDocument.activeElement\n\t\t\t);\n\n\t\t\tif ( ref.current?.isConnected && ! isFocused ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Defer to the component's own explicit focus return behavior, if\n\t\t\t// specified. This allows for support that the `onFocusReturn`\n\t\t\t// decides to allow the default behavior to occur under some\n\t\t\t// conditions.\n\t\t\tif ( onFocusReturnRef.current ) {\n\t\t\t\tonFocusReturnRef.current();\n\t\t\t} else {\n\t\t\t\t/** @type {null | HTMLElement} */ (\n\t\t\t\t\tfocusedBeforeMount.current\n\t\t\t\t)?.focus();\n\t\t\t}\n\t\t}\n\t}, [] );\n}\n\nexport default useFocusReturn;\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-keyboard-shortcut/index.js"],"names":["isAppleOS","_window","window","platform","navigator","indexOf","useKeyboardShortcut","shortcuts","callback","bindGlobal","eventName","isDisabled","target","currentCallback","current","mousetrap","Mousetrap","document","forEach","shortcut","keys","split","modifiers","Set","filter","value","length","hasAlt","has","hasShift","size","Error","bindFn","reset"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAT,GAAuC;AAAA,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AV,CAAe,OAAf,CAAjB,CAT+C,CAW/C;;AACA,UACC5B,SAAS,OACLsB,SAAS,CAACQ,IAAV,KAAmB,CAAnB,IAAwBH,MAA1B,IACCL,SAAS,CAACQ,IAAV,KAAmB,CAAnB,IAAwBH,MAAxB,IAAkCE,QAF5B,CADV,EAIE;AACD,cAAM,IAAIE,KAAJ,CACJ,eAAeZ,QAAU,iEADrB,CAAN;AAGA;;AAED,YAAMa,MAAM,GAAGvB,UAAU,GAAG,YAAH,GAAkB,MAA3C,CAtB+C,CAuB/C;;AACAM,MAAAA,SAAS,CAAEiB,MAAF,CAAT,CACCb,QADD,EAEC;AAAA;AAIC;AACAN,UAAAA,eAAe,CAACC,OAAhB,CAAyB,YAAzB;AALD;AAAA,OAFD,EAQCJ,SARD;AAUA,KAlCD;AAoCA,WAAO,MAAM;AACZK,MAAAA,SAAS,CAACkB,KAAV;AACA,KAFD;AAGA,GAnDD,EAmDG,CAAE1B,SAAF,EAAaE,UAAb,EAAyBC,SAAzB,EAAoCE,MAApC,EAA4CD,UAA5C,CAnDH;AAoDA;;eAEcL,mB","sourcesContent":["/**\n * External dependencies\n */\nimport Mousetrap from 'mousetrap';\nimport 'mousetrap/plugins/global-bind/mousetrap-global-bind';\nimport { includes, castArray } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * A block selection object.\n *\n * @typedef {Object} WPKeyboardShortcutConfig\n *\n * @property {boolean} [bindGlobal] Handle keyboard events anywhere including inside textarea/input fields.\n * @property {string} [eventName] Event name used to trigger the handler, defaults to keydown.\n * @property {boolean} [isDisabled] Disables the keyboard handler if the value is true.\n * @property {import('react').RefObject<HTMLElement>} [target] React reference to the DOM element used to catch the keyboard event.\n */\n\n/**\n * Return true if platform is MacOS.\n *\n * @param {Window} [_window] window object by default; used for DI testing.\n *\n * @return {boolean} True if MacOS; false otherwise.\n */\nfunction isAppleOS( _window = window ) {\n\tconst { platform } = _window.navigator;\n\n\treturn (\n\t\tplatform.indexOf( 'Mac' ) !== -1 ||\n\t\tincludes( [ 'iPad', 'iPhone' ], platform )\n\t);\n}\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Attach a keyboard shortcut handler.\n *\n * @see https://craig.is/killing/mice#api.bind for information about the `callback` parameter.\n *\n * @param {string[]|string} shortcuts Keyboard Shortcuts.\n * @param {(e: import('mousetrap').ExtendedKeyboardEvent, combo: string) => void} callback Shortcut callback.\n * @param {WPKeyboardShortcutConfig} options Shortcut options.\n */\nfunction useKeyboardShortcut(\n\t/* eslint-enable jsdoc/valid-types */\n\tshortcuts,\n\tcallback,\n\t{\n\t\tbindGlobal = false,\n\t\teventName = 'keydown',\n\t\tisDisabled = false, // This is important for performance considerations.\n\t\ttarget,\n\t} = {}\n) {\n\tconst currentCallback = useRef( callback );\n\tuseEffect( () => {\n\t\tcurrentCallback.current = callback;\n\t}, [ callback ] );\n\n\tuseEffect( () => {\n\t\tif ( isDisabled ) {\n\t\t\treturn;\n\t\t}\n\t\tconst mousetrap = new Mousetrap(\n\t\t\ttarget && target.current\n\t\t\t\t? target.current\n\t\t\t\t: // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`.\n\t\t\t\t // Not sure if this is a mistake but it was the behavior previous to the addition of types so we're just doing what's\n\t\t\t\t // necessary to maintain the existing behavior.\n\t\t\t\t /** @type {Element} */ (/** @type {unknown} */ ( document ))\n\t\t);\n\t\tcastArray( shortcuts ).forEach( ( shortcut ) => {\n\t\t\tconst keys = shortcut.split( '+' );\n\t\t\t// Determines whether a key is a modifier by the length of the string.\n\t\t\t// E.g. if I add a pass a shortcut Shift+Cmd+M, it'll determine that\n\t\t\t// the modifiers are Shift and Cmd because they're not a single character.\n\t\t\tconst modifiers = new Set(\n\t\t\t\tkeys.filter( ( value ) => value.length > 1 )\n\t\t\t);\n\t\t\tconst hasAlt = modifiers.has( 'alt' );\n\t\t\tconst hasShift = modifiers.has( 'shift' );\n\n\t\t\t// This should be better moved to the shortcut registration instead.\n\t\t\tif (\n\t\t\t\tisAppleOS() &&\n\t\t\t\t( ( modifiers.size === 1 && hasAlt ) ||\n\t\t\t\t\t( modifiers.size === 2 && hasAlt && hasShift ) )\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot bind ${ shortcut }. Alt and Shift+Alt modifiers are reserved for character input.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst bindFn = bindGlobal ? 'bindGlobal' : 'bind';\n\t\t\t// @ts-ignore `bindGlobal` is an undocumented property\n\t\t\tmousetrap[ bindFn ](\n\t\t\t\tshortcut,\n\t\t\t\t(\n\t\t\t\t\t/* eslint-disable jsdoc/valid-types */\n\t\t\t\t\t/** @type {[e: import('mousetrap').ExtendedKeyboardEvent, combo: string]} */ ...args\n\t\t\t\t) =>\n\t\t\t\t\t/* eslint-enable jsdoc/valid-types */\n\t\t\t\t\tcurrentCallback.current( ...args ),\n\t\t\t\teventName\n\t\t\t);\n\t\t} );\n\n\t\treturn () => {\n\t\t\tmousetrap.reset();\n\t\t};\n\t}, [ shortcuts, bindGlobal, eventName, target, isDisabled ] );\n}\n\nexport default useKeyboardShortcut;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-keyboard-shortcut/index.js"],"names":["isAppleOS","_window","window","platform","navigator","indexOf","useKeyboardShortcut","shortcuts","callback","bindGlobal","eventName","isDisabled","target","currentCallback","current","mousetrap","Mousetrap","document","forEach","shortcut","keys","split","modifiers","Set","filter","value","length","hasAlt","has","hasShift","size","Error","bindFn","reset"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAT,GAAuC;AAAA,MAAnBC,OAAmB,uEAATC,MAAS;;AACtC,QAAM;AAAEC,IAAAA;AAAF,MAAeF,OAAO,CAAC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AV,KAAmB,CAAnB,IAAwBH,MAA1B,IACCL,SAAS,CAACQ,IAAV,KAAmB,CAAnB,IAAwBH,MAAxB,IAAkCE,QAF5B,CADV,EAIE;AACD,cAAM,IAAIE,KAAJ,CACJ,eAAeZ,QAAU,iEADrB,CAAN;AAGA;;AAED,YAAMa,MAAM,GAAGvB,UAAU,GAAG,YAAH,GAAkB,MAA3C,CAtB+C,CAuB/C;;AACAM,MAAAA,SAAS,CAAEiB,MAAF,CAAT,CACCb,QADD,EAEC;AAAA;AAIC;AACAN,UAAAA,eAAe,CAACC,OAAhB,CAAyB,YAAzB;AALD;AAAA,OAFD,EAQCJ,SARD;AAUA,KAlCD;AAoCA,WAAO,MAAM;AACZK,MAAAA,SAAS,CAACkB,KAAV;AACA,KAFD;AAGA,GAnDD,EAmDG,CAAE1B,SAAF,EAAaE,UAAb,EAAyBC,SAAzB,EAAoCE,MAApC,EAA4CD,UAA5C,CAnDH;AAoDA;;eAEcL,mB","sourcesContent":["/**\n * External dependencies\n */\nimport Mousetrap from 'mousetrap';\nimport 'mousetrap/plugins/global-bind/mousetrap-global-bind';\nimport { includes, castArray } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * A block selection object.\n *\n * @typedef {Object} WPKeyboardShortcutConfig\n *\n * @property {boolean} [bindGlobal] Handle keyboard events anywhere including inside textarea/input fields.\n * @property {string} [eventName] Event name used to trigger the handler, defaults to keydown.\n * @property {boolean} [isDisabled] Disables the keyboard handler if the value is true.\n * @property {import('react').RefObject<HTMLElement>} [target] React reference to the DOM element used to catch the keyboard event.\n */\n\n/**\n * Return true if platform is MacOS.\n *\n * @param {Window} [_window] window object by default; used for DI testing.\n *\n * @return {boolean} True if MacOS; false otherwise.\n */\nfunction isAppleOS( _window = window ) {\n\tconst { platform } = _window.navigator;\n\n\treturn (\n\t\tplatform.indexOf( 'Mac' ) !== -1 ||\n\t\tincludes( [ 'iPad', 'iPhone' ], platform )\n\t);\n}\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Attach a keyboard shortcut handler.\n *\n * @see https://craig.is/killing/mice#api.bind for information about the `callback` parameter.\n *\n * @param {string[]|string} shortcuts Keyboard Shortcuts.\n * @param {(e: import('mousetrap').ExtendedKeyboardEvent, combo: string) => void} callback Shortcut callback.\n * @param {WPKeyboardShortcutConfig} options Shortcut options.\n */\nfunction useKeyboardShortcut(\n\t/* eslint-enable jsdoc/valid-types */\n\tshortcuts,\n\tcallback,\n\t{\n\t\tbindGlobal = false,\n\t\teventName = 'keydown',\n\t\tisDisabled = false, // This is important for performance considerations.\n\t\ttarget,\n\t} = {}\n) {\n\tconst currentCallback = useRef( callback );\n\tuseEffect( () => {\n\t\tcurrentCallback.current = callback;\n\t}, [ callback ] );\n\n\tuseEffect( () => {\n\t\tif ( isDisabled ) {\n\t\t\treturn;\n\t\t}\n\t\tconst mousetrap = new Mousetrap(\n\t\t\ttarget && target.current\n\t\t\t\t? target.current\n\t\t\t\t: // We were passing `document` here previously, so to successfully cast it to Element we must cast it first to `unknown`.\n\t\t\t\t // Not sure if this is a mistake but it was the behavior previous to the addition of types so we're just doing what's\n\t\t\t\t // necessary to maintain the existing behavior.\n\t\t\t\t /** @type {Element} */ ( /** @type {unknown} */ ( document ) )\n\t\t);\n\t\tcastArray( shortcuts ).forEach( ( shortcut ) => {\n\t\t\tconst keys = shortcut.split( '+' );\n\t\t\t// Determines whether a key is a modifier by the length of the string.\n\t\t\t// E.g. if I add a pass a shortcut Shift+Cmd+M, it'll determine that\n\t\t\t// the modifiers are Shift and Cmd because they're not a single character.\n\t\t\tconst modifiers = new Set(\n\t\t\t\tkeys.filter( ( value ) => value.length > 1 )\n\t\t\t);\n\t\t\tconst hasAlt = modifiers.has( 'alt' );\n\t\t\tconst hasShift = modifiers.has( 'shift' );\n\n\t\t\t// This should be better moved to the shortcut registration instead.\n\t\t\tif (\n\t\t\t\tisAppleOS() &&\n\t\t\t\t( ( modifiers.size === 1 && hasAlt ) ||\n\t\t\t\t\t( modifiers.size === 2 && hasAlt && hasShift ) )\n\t\t\t) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Cannot bind ${ shortcut }. Alt and Shift+Alt modifiers are reserved for character input.`\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst bindFn = bindGlobal ? 'bindGlobal' : 'bind';\n\t\t\t// @ts-ignore `bindGlobal` is an undocumented property\n\t\t\tmousetrap[ bindFn ](\n\t\t\t\tshortcut,\n\t\t\t\t(\n\t\t\t\t\t/* eslint-disable jsdoc/valid-types */\n\t\t\t\t\t/** @type {[e: import('mousetrap').ExtendedKeyboardEvent, combo: string]} */ ...args\n\t\t\t\t) =>\n\t\t\t\t\t/* eslint-enable jsdoc/valid-types */\n\t\t\t\t\tcurrentCallback.current( ...args ),\n\t\t\t\teventName\n\t\t\t);\n\t\t} );\n\n\t\treturn () => {\n\t\t\tmousetrap.reset();\n\t\t};\n\t}, [ shortcuts, bindGlobal, eventName, target, isDisabled ] );\n}\n\nexport default useKeyboardShortcut;\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-merge-refs/index.js"],"names":["assignRef","ref","value","hasOwnProperty","current","useMergeRefs","refs","element","didElementChange","previousRefs","currentRefs","forEach","index","previousRef","refsToAssign"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAT,CAAoBC,GAApB,EAAyBC,KAAzB,EAAiC;AAChC,MAAK,OAAOD,GAAP,KAAe,UAApB,EAAiC;AAChCA,IAAAA,GAAG,CAAEC,KAAF,CAAH;AACA,GAFD,MAEO,IAAKD,GAAG,IAAIA,GAAG,CAACE,cAAJ,CAAoB,SAApB,CAAZ,EAA8C;AACpD;;AACA;AAAqDF,IAAAA,GAAF,CAAQG,OAAR,GAAkBF,KAAlB;AACnD;AACA;AACD;AAED;AACA;AACA;AACA;AACA;AACA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jB,GAA2B,IAA3B,CALgC,CAOhC;AACA;;AACA,UAAMU,YAAY,GAAGZ,KAAK,GAAGQ,WAAW,CAACN,OAAf,GAAyBK,YAAY,CAACL,OAAhE,CATgC,CAWhC;;AACA,SAAM,MAAMH,GAAZ,IAAmBa,YAAnB,EAAkC;AACjCd,MAAAA,SAAS,CAAEC,GAAF,EAAOC,KAAP,CAAT;AACA;AACD,GAfM,EAeJ,EAfI,CAAP;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useCallback, useLayoutEffect } from '@wordpress/element';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @template T\n * @typedef {T extends import('react').Ref<infer R> ? R : never} TypeFromRef\n */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * @template T\n * @param {import('react').Ref<T>} ref\n * @param {T} value\n */\nfunction assignRef( ref, value ) {\n\tif ( typeof ref === 'function' ) {\n\t\tref( value );\n\t} else if ( ref && ref.hasOwnProperty( 'current' ) ) {\n\t\t/* eslint-disable jsdoc/no-undefined-types */\n\t\t/** @type {import('react').MutableRefObject<T>} */ ( ref ).current = value;\n\t\t/* eslint-enable jsdoc/no-undefined-types */\n\t}\n}\n\n/**\n * Merges refs into one ref callback.\n *\n * It also ensures that the merged ref callbacks are only called when they\n * change (as a result of a `useCallback` dependency update) OR when the ref\n * value changes, just as React does when passing a single ref callback to the\n * component.\n *\n * As expected, if you pass a new function on every render, the ref callback\n * will be called after every render.\n *\n * If you don't wish a ref callback to be called after every render, wrap it\n * with `useCallback( callback, dependencies )`. When a dependency changes, the\n * old ref callback will be called with `null` and the new ref callback will be\n * called with the same value.\n *\n * To make ref callbacks easier to use, you can also pass the result of\n * `useRefEffect`, which makes cleanup easier by allowing you to return a\n * cleanup function instead of handling `null`.\n *\n * It's also possible to _disable_ a ref (and its behaviour) by simply not\n * passing the ref.\n *\n * ```jsx\n * const ref = useRefEffect( ( node ) => {\n * node.addEventListener( ... );\n * return () => {\n * node.removeEventListener( ... );\n * };\n * }, [ ...dependencies ] );\n * const otherRef = useRef();\n * const mergedRefs useMergeRefs( [\n * enabled && ref,\n * otherRef,\n * ] );\n * return <div ref={ mergedRefs } />;\n * ```\n *\n * @template {import('react').Ref<any>} TRef\n * @param {Array<TRef>} refs The refs to be merged.\n *\n * @return {import('react').RefCallback<TypeFromRef<TRef>>} The merged ref callback.\n */\nexport default function useMergeRefs( refs ) {\n\tconst element = useRef();\n\tconst didElementChange = useRef( false );\n\t/* eslint-disable jsdoc/no-undefined-types */\n\t/** @type {import('react').MutableRefObject<TRef[]>} */\n\t/* eslint-enable jsdoc/no-undefined-types */\n\tconst previousRefs = useRef( [] );\n\tconst currentRefs = useRef( refs );\n\n\t// Update on render before the ref callback is called, so the ref callback\n\t// always has access to the current refs.\n\tcurrentRefs.current = refs;\n\n\t// If any of the refs change, call the previous ref with `null` and the new\n\t// ref with the node, except when the element changes in the same cycle, in\n\t// which case the ref callbacks will already have been called.\n\tuseLayoutEffect( () => {\n\t\tif ( didElementChange.current === false ) {\n\t\t\trefs.forEach( ( ref, index ) => {\n\t\t\t\tconst previousRef = previousRefs.current[ index ];\n\t\t\t\tif ( ref !== previousRef ) {\n\t\t\t\t\tassignRef( previousRef, null );\n\t\t\t\t\tassignRef( ref, element.current );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\tpreviousRefs.current = refs;\n\t}, refs );\n\n\t// No dependencies, must be reset after every render so ref callbacks are\n\t// correctly called after a ref change.\n\tuseLayoutEffect( () => {\n\t\tdidElementChange.current = false;\n\t} );\n\n\t// There should be no dependencies so that `callback` is only called when\n\t// the node changes.\n\treturn useCallback( ( value ) => {\n\t\t// Update the element so it can be used when calling ref callbacks on a\n\t\t// dependency change.\n\t\tassignRef( element, value );\n\n\t\tdidElementChange.current = true;\n\n\t\t// When an element changes, the current ref callback should be called\n\t\t// with the new element and the previous one with `null`.\n\t\tconst refsToAssign = value ? currentRefs.current : previousRefs.current;\n\n\t\t// Update the latest refs.\n\t\tfor ( const ref of refsToAssign ) {\n\t\t\tassignRef( ref, value );\n\t\t}\n\t}, [] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-merge-refs/index.js"],"names":["assignRef","ref","value","hasOwnProperty","current","useMergeRefs","refs","element","didElementChange","previousRefs","currentRefs","forEach","index","previousRef","refsToAssign"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAGA;;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,SAASA,SAAT,CAAoBC,GAApB,EAAyBC,KAAzB,EAAiC;AAChC,MAAK,OAAOD,GAAP,KAAe,UAApB,EAAiC;AAChCA,IAAAA,GAAG,CAAEC,KAAF,CAAH;AACA,GAFD,MAEO,IAAKD,GAAG,IAAIA,GAAG,CAACE,cAAJ,CAAoB,SAApB,CAAZ,EAA8C;AACpD;;AACA;AAAqDF,IAAAA,GAAF,CAAQG,OAAR,GAClDF,KADkD;AAEnD;AACA;AACD;AAED;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;AACA;AACA;AACA;AACA;;;AACe,SAASG,YAAT,CAAuBC,IAAvB,EAA8B;AAC5C,QAAMC,OAAO,GAAG,sBAAhB;AACA,QAAMC,gBAAgB,GAAG,qBAAQ,KAAR,CAAzB;AACA;;AACA;;AACA;;AACA,QAAMC,YAAY,GAAG,qBAAQ,EAAR,CAArB;AACA,QAAMC,WAAW,GAAG,qBAAQJ,IAAR,CAApB,CAP4C,CAS5C;AACA;;AACAI,EAAAA,WAAW,CAACN,OAAZ,GAAsBE,IAAtB,CAX4C,CAa5C;AACA;AACA;;AACA,gCAAiB,MAAM;AACtB,QAAKE,gBAAgB,CAACJ,OAAjB,KAA6B,KAAlC,EAA0C;AACzCE,MAAAA,IAAI,CAACK,OAAL,CAAc,CAAEV,GAAF,EAAOW,KAAP,KAAkB;AAC/B,cAAMC,WAAW,GAAGJ,YAAY,CAACL,OAAb,CAAsBQ,KAAtB,CAApB;;AACA,YAAKX,GAAG,KAAKY,WAAb,EAA2B;AAC1Bb,UAAAA,SAAS,CAAEa,WAAF,EAAe,IAAf,CAAT;AACAb,UAAAA,SAAS,CAAEC,GAAF,EAAOM,OAAO,CAACH,OAAf,CAAT;AACA;AACD,OAND;AAOA;;AAEDK,IAAAA,YAAY,CAACL,OAAb,GAAuBE,IAAvB;AACA,GAZD,EAYGA,IAZH,EAhB4C,CA8B5C;AACA;;AACA,gCAAiB,MAAM;AACtBE,IAAAA,gBAAgB,CAACJ,OAAjB,GAA2B,KAA3B;AACA,GAFD,EAhC4C,CAoC5C;AACA;;AACA,SAAO,0BAAeF,KAAF,IAAa;AAChC;AACA;AACAF,IAAAA,SAAS,CAAEO,OAAF,EAAWL,KAAX,CAAT;AAEAM,IAAAA,gBAAgB,CAACJ,OAAjB,GAA2B,IAA3B,CALgC,CAOhC;AACA;;AACA,UAAMU,YAAY,GAAGZ,KAAK,GAAGQ,WAAW,CAACN,OAAf,GAAyBK,YAAY,CAACL,OAAhE,CATgC,CAWhC;;AACA,SAAM,MAAMH,GAAZ,IAAmBa,YAAnB,EAAkC;AACjCd,MAAAA,SAAS,CAAEC,GAAF,EAAOC,KAAP,CAAT;AACA;AACD,GAfM,EAeJ,EAfI,CAAP;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useCallback, useLayoutEffect } from '@wordpress/element';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @template T\n * @typedef {T extends import('react').Ref<infer R> ? R : never} TypeFromRef\n */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * @template T\n * @param {import('react').Ref<T>} ref\n * @param {T} value\n */\nfunction assignRef( ref, value ) {\n\tif ( typeof ref === 'function' ) {\n\t\tref( value );\n\t} else if ( ref && ref.hasOwnProperty( 'current' ) ) {\n\t\t/* eslint-disable jsdoc/no-undefined-types */\n\t\t/** @type {import('react').MutableRefObject<T>} */ ( ref ).current =\n\t\t\tvalue;\n\t\t/* eslint-enable jsdoc/no-undefined-types */\n\t}\n}\n\n/**\n * Merges refs into one ref callback.\n *\n * It also ensures that the merged ref callbacks are only called when they\n * change (as a result of a `useCallback` dependency update) OR when the ref\n * value changes, just as React does when passing a single ref callback to the\n * component.\n *\n * As expected, if you pass a new function on every render, the ref callback\n * will be called after every render.\n *\n * If you don't wish a ref callback to be called after every render, wrap it\n * with `useCallback( callback, dependencies )`. When a dependency changes, the\n * old ref callback will be called with `null` and the new ref callback will be\n * called with the same value.\n *\n * To make ref callbacks easier to use, you can also pass the result of\n * `useRefEffect`, which makes cleanup easier by allowing you to return a\n * cleanup function instead of handling `null`.\n *\n * It's also possible to _disable_ a ref (and its behaviour) by simply not\n * passing the ref.\n *\n * ```jsx\n * const ref = useRefEffect( ( node ) => {\n * node.addEventListener( ... );\n * return () => {\n * node.removeEventListener( ... );\n * };\n * }, [ ...dependencies ] );\n * const otherRef = useRef();\n * const mergedRefs useMergeRefs( [\n * enabled && ref,\n * otherRef,\n * ] );\n * return <div ref={ mergedRefs } />;\n * ```\n *\n * @template {import('react').Ref<any>} TRef\n * @param {Array<TRef>} refs The refs to be merged.\n *\n * @return {import('react').RefCallback<TypeFromRef<TRef>>} The merged ref callback.\n */\nexport default function useMergeRefs( refs ) {\n\tconst element = useRef();\n\tconst didElementChange = useRef( false );\n\t/* eslint-disable jsdoc/no-undefined-types */\n\t/** @type {import('react').MutableRefObject<TRef[]>} */\n\t/* eslint-enable jsdoc/no-undefined-types */\n\tconst previousRefs = useRef( [] );\n\tconst currentRefs = useRef( refs );\n\n\t// Update on render before the ref callback is called, so the ref callback\n\t// always has access to the current refs.\n\tcurrentRefs.current = refs;\n\n\t// If any of the refs change, call the previous ref with `null` and the new\n\t// ref with the node, except when the element changes in the same cycle, in\n\t// which case the ref callbacks will already have been called.\n\tuseLayoutEffect( () => {\n\t\tif ( didElementChange.current === false ) {\n\t\t\trefs.forEach( ( ref, index ) => {\n\t\t\t\tconst previousRef = previousRefs.current[ index ];\n\t\t\t\tif ( ref !== previousRef ) {\n\t\t\t\t\tassignRef( previousRef, null );\n\t\t\t\t\tassignRef( ref, element.current );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\n\t\tpreviousRefs.current = refs;\n\t}, refs );\n\n\t// No dependencies, must be reset after every render so ref callbacks are\n\t// correctly called after a ref change.\n\tuseLayoutEffect( () => {\n\t\tdidElementChange.current = false;\n\t} );\n\n\t// There should be no dependencies so that `callback` is only called when\n\t// the node changes.\n\treturn useCallback( ( value ) => {\n\t\t// Update the element so it can be used when calling ref callbacks on a\n\t\t// dependency change.\n\t\tassignRef( element, value );\n\n\t\tdidElementChange.current = true;\n\n\t\t// When an element changes, the current ref callback should be called\n\t\t// with the new element and the previous one with `null`.\n\t\tconst refsToAssign = value ? currentRefs.current : previousRefs.current;\n\n\t\t// Update the latest refs.\n\t\tfor ( const ref of refsToAssign ) {\n\t\t\tassignRef( ref, value );\n\t\t}\n\t}, [] );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-throttle/index.js"],"names":["useThrottle","fn","wait","options","throttled","cancel"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,WAAT,CAAsBC,EAAtB,EAA0BC,IAA1B,EAAgCC,OAAhC,EAA0C;AACxD,QAAMC,SAAS,GAAG,4BAAY,MAAM,sBAAUH,EAAV,EAAcC,IAAd,EAAoBC,OAApB,CAAlB,EAAiD,CAClEF,EADkE,EAElEC,IAFkE,EAGlEC,OAHkE,CAAjD,CAAlB;AAKA,0BAAW,MAAM,MAAMC,SAAS,CAACC,MAAV,EAAvB,EAA2C,CAAED,SAAF,CAA3C;AACA,SAAOA,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { throttle } from 'lodash';\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Throttles a function with Lodash's `throttle`. A new throttled function will\n * be returned and any scheduled calls cancelled if any of the arguments change,\n * including the function to throttle, so please wrap functions created on\n * render in components in `useCallback`.\n *\n * @see https://docs-lodash.com/v4/throttle/\n *\n * @template {(...args: any[]) => void} TFunc\n *\n * @param {TFunc} fn The function to throttle.\n * @param {number} [wait] The number of milliseconds to throttle invocations to.\n * @param {import('lodash').ThrottleSettings} [options] The options object. See linked documentation for details.\n * @return {import('lodash').DebouncedFunc<TFunc>} Throttled function.\n */\nexport default function useThrottle( fn, wait, options ) {\n\tconst throttled = useMemoOne( () => throttle( fn, wait, options ), [\n\t\tfn,\n\t\twait,\n\t\toptions,\n\t] );\n\tuseEffect( () => () => throttled.cancel(), [ throttled ] );\n\treturn throttled;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-throttle/index.js"],"names":["useThrottle","fn","wait","options","throttled","cancel"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,WAAT,CAAsBC,EAAtB,EAA0BC,IAA1B,EAAgCC,OAAhC,EAA0C;AACxD,QAAMC,SAAS,GAAG,4BACjB,MAAM,sBAAUH,EAAV,EAAcC,IAAd,EAAoBC,OAApB,CADW,EAEjB,CAAEF,EAAF,EAAMC,IAAN,EAAYC,OAAZ,CAFiB,CAAlB;AAIA,0BAAW,MAAM,MAAMC,SAAS,CAACC,MAAV,EAAvB,EAA2C,CAAED,SAAF,CAA3C;AACA,SAAOA,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { throttle } from 'lodash';\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Throttles a function with Lodash's `throttle`. A new throttled function will\n * be returned and any scheduled calls cancelled if any of the arguments change,\n * including the function to throttle, so please wrap functions created on\n * render in components in `useCallback`.\n *\n * @see https://docs-lodash.com/v4/throttle/\n *\n * @template {(...args: any[]) => void} TFunc\n *\n * @param {TFunc} fn The function to throttle.\n * @param {number} [wait] The number of milliseconds to throttle invocations to.\n * @param {import('lodash').ThrottleSettings} [options] The options object. See linked documentation for details.\n * @return {import('lodash').DebouncedFunc<TFunc>} Throttled function.\n */\nexport default function useThrottle( fn, wait, options ) {\n\tconst throttled = useMemoOne(\n\t\t() => throttle( fn, wait, options ),\n\t\t[ fn, wait, options ]\n\t);\n\tuseEffect( () => () => throttled.cancel(), [ throttled ] );\n\treturn throttled;\n}\n"]}