@wordpress/compose 5.0.7 → 5.1.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 (63) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +4 -16
  4. package/build/higher-order/if-condition/index.js.map +1 -1
  5. package/build/higher-order/pure/index.js +1 -1
  6. package/build/higher-order/pure/index.js.map +1 -1
  7. package/build/higher-order/with-global-events/index.js +2 -1
  8. package/build/higher-order/with-global-events/index.js.map +1 -1
  9. package/build/higher-order/with-instance-id/index.js +2 -6
  10. package/build/higher-order/with-instance-id/index.js.map +1 -1
  11. package/build/higher-order/with-safe-timeout/index.js.map +1 -1
  12. package/build/higher-order/with-state/index.js +1 -0
  13. package/build/higher-order/with-state/index.js.map +1 -1
  14. package/build/hooks/use-copy-on-click/index.js +1 -2
  15. package/build/hooks/use-copy-on-click/index.js.map +1 -1
  16. package/build/hooks/use-ref-effect/index.js +0 -1
  17. package/build/hooks/use-ref-effect/index.js.map +1 -1
  18. package/build/utils/create-higher-order-component/index.js +2 -2
  19. package/build/utils/create-higher-order-component/index.js.map +1 -1
  20. package/build-module/higher-order/if-condition/index.js +1 -1
  21. package/build-module/higher-order/if-condition/index.js.map +1 -1
  22. package/build-module/higher-order/pure/index.js +4 -1
  23. package/build-module/higher-order/pure/index.js.map +1 -1
  24. package/build-module/higher-order/with-global-events/index.js +2 -1
  25. package/build-module/higher-order/with-global-events/index.js.map +1 -1
  26. package/build-module/higher-order/with-instance-id/index.js +2 -6
  27. package/build-module/higher-order/with-instance-id/index.js.map +1 -1
  28. package/build-module/higher-order/with-safe-timeout/index.js +9 -1
  29. package/build-module/higher-order/with-safe-timeout/index.js.map +1 -1
  30. package/build-module/higher-order/with-state/index.js +1 -0
  31. package/build-module/higher-order/with-state/index.js.map +1 -1
  32. package/build-module/hooks/use-copy-on-click/index.js +1 -2
  33. package/build-module/hooks/use-copy-on-click/index.js.map +1 -1
  34. package/build-module/hooks/use-ref-effect/index.js +0 -1
  35. package/build-module/hooks/use-ref-effect/index.js.map +1 -1
  36. package/build-module/utils/create-higher-order-component/index.js +3 -3
  37. package/build-module/utils/create-higher-order-component/index.js.map +1 -1
  38. package/build-types/higher-order/if-condition/index.d.ts +2 -2
  39. package/build-types/higher-order/if-condition/index.d.ts.map +1 -1
  40. package/build-types/higher-order/pure/index.d.ts +6 -3
  41. package/build-types/higher-order/pure/index.d.ts.map +1 -1
  42. package/build-types/higher-order/with-global-events/index.d.ts.map +1 -1
  43. package/build-types/higher-order/with-instance-id/index.d.ts +3 -3
  44. package/build-types/higher-order/with-instance-id/index.d.ts.map +1 -1
  45. package/build-types/higher-order/with-safe-timeout/index.d.ts +2 -2
  46. package/build-types/higher-order/with-safe-timeout/index.d.ts.map +1 -1
  47. package/build-types/higher-order/with-state/index.d.ts.map +1 -1
  48. package/build-types/hooks/use-copy-on-click/index.d.ts.map +1 -1
  49. package/build-types/hooks/use-ref-effect/index.d.ts.map +1 -1
  50. package/build-types/utils/create-higher-order-component/index.d.ts +4 -6
  51. package/build-types/utils/create-higher-order-component/index.d.ts.map +1 -1
  52. package/package.json +11 -8
  53. package/src/higher-order/if-condition/index.tsx +5 -6
  54. package/src/higher-order/pure/index.tsx +5 -5
  55. package/src/higher-order/with-global-events/index.js +1 -0
  56. package/src/higher-order/with-instance-id/index.tsx +8 -24
  57. package/src/higher-order/with-safe-timeout/index.tsx +5 -6
  58. package/src/higher-order/with-state/index.js +1 -0
  59. package/src/hooks/use-copy-on-click/index.js +1 -2
  60. package/src/hooks/use-disabled/test/index.js +2 -0
  61. package/src/hooks/use-ref-effect/index.ts +0 -1
  62. package/src/utils/create-higher-order-component/index.ts +15 -21
  63. package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 5.1.0 (2022-01-27)
6
+
5
7
  ## 5.0.0 (2021-07-29)
6
8
 
7
9
  ### Breaking Change
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Gutenberg
2
2
 
3
- Copyright 2016-2021 by the contributors
3
+ Copyright 2016-2022 by the contributors
4
4
 
5
5
  **License for Contributions (on and after April 15, 2021)**
6
6
 
package/README.md CHANGED
@@ -79,12 +79,12 @@ name, returns the enhanced component augmented with a generated displayName.
79
79
 
80
80
  _Parameters_
81
81
 
82
- - _mapComponentToEnhancedComponent_ `HigherOrderComponent< TInnerProps, TOuterProps >`: Function mapping component to enhanced component.
82
+ - _mapComponent_ `HigherOrderComponent< HOCProps >`: Function mapping component to enhanced component.
83
83
  - _modifierName_ `string`: Seed name from which to generated display name.
84
84
 
85
85
  _Returns_
86
86
 
87
- - `HigherOrderComponent< TInnerProps, TOuterProps >`: Component class with generated display name assigned.
87
+ - Component class with generated display name assigned.
88
88
 
89
89
  ### ifCondition
90
90
 
@@ -109,16 +109,12 @@ _Parameters_
109
109
 
110
110
  _Returns_
111
111
 
112
- - `HigherOrderComponent< TProps, TProps >`: Higher-order component.
112
+ - Higher-order component.
113
113
 
114
114
  ### pure
115
115
 
116
116
  Given a component returns the enhanced component augmented with a component
117
- only rerendering when its props/state change
118
-
119
- _Type_
120
-
121
- - `SimpleHigherOrderComponent`
117
+ only re-rendering when its props/state change
122
118
 
123
119
  ### useAsyncList
124
120
 
@@ -528,19 +524,11 @@ _Returns_
528
524
  A Higher Order Component used to be provide a unique instance ID by
529
525
  component.
530
526
 
531
- _Type_
532
-
533
- - `PropInjectingHigherOrderComponent< { instanceId: string | number; } >`
534
-
535
527
  ### withSafeTimeout
536
528
 
537
529
  A higher-order component used to provide and manage delayed function calls
538
530
  that ought to be bound to a component's lifecycle.
539
531
 
540
- _Type_
541
-
542
- - `PropInjectingHigherOrderComponent< TimeoutProps >`
543
-
544
532
  ### withState
545
533
 
546
534
  > **Deprecated** Use `useState` instead.
@@ -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;;AAIA;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,IAAqB;AAC5C,MAAK,CAAEF,SAAS,CAAEE,KAAF,CAAhB,EAA4B;AAC3B,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';\nimport type { HigherOrderComponent } 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, >(\n\tpredicate: ( props: TProps ) => boolean\n): HigherOrderComponent< TProps, TProps > =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( props: TProps ) => {\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\nexport default ifCondition;\n"]}
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"]}
@@ -23,7 +23,7 @@ var _createHigherOrderComponent = _interopRequireDefault(require("../../utils/cr
23
23
 
24
24
  /**
25
25
  * Given a component returns the enhanced component augmented with a component
26
- * only rerendering when its props/state change
26
+ * only re-rendering when its props/state change
27
27
  */
28
28
  const pure = (0, _createHigherOrderComponent.default)(Wrapped => {
29
29
  if (Wrapped.prototype instanceof _element.Component) {
@@ -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;;AAUA;AACA;AACA;AACA;AACA,MAAMA,IAAgC,GAAG,yCAC3BC,OAAb,IAAmD;AAClD,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,CAtBuC,EAuBxC,MAvBwC,CAAzC;eA0BeP,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';\nimport type { SimpleHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { ComponentType, ComponentClass } from 'react';\n\n/**\n * Given a component returns the enhanced component augmented with a component\n * only rerendering when its props/state change\n */\nconst pure: SimpleHigherOrderComponent = createHigherOrderComponent(\n\t< TProps, >( Wrapped: ComponentType< TProps > ) => {\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","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"]}
@@ -61,7 +61,8 @@ function withGlobalEvents(eventTypesToHandlers) {
61
61
  (0, _deprecated.default)('wp.compose.withGlobalEvents', {
62
62
  since: '5.7',
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
67
  class Wrapper extends _element.Component {
67
68
  constructor(
@@ -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,EAAkD;AAChE,2BAAY,6BAAZ,EAA2C;AAC1CC,IAAAA,KAAK,EAAE,KADmC;AAE1CC,IAAAA,WAAW,EAAE;AAF6B,GAA3C;AAKA,SAAO,yCAA8BC,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;AAAmDiB,QAAAA,KAAK,CAACE;AACzD;AAFmB,SADrB;;AAKA,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;;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\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,yCAA8BC,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;AAAmDiB,QAAAA,KAAK,CAACE;AACzD;AAFmB,SADrB;;AAKA,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;;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"]}
@@ -15,11 +15,6 @@ var _createHigherOrderComponent = _interopRequireDefault(require("../../utils/cr
15
15
 
16
16
  var _useInstanceId = _interopRequireDefault(require("../../hooks/use-instance-id"));
17
17
 
18
- /**
19
- * External dependencies
20
- */
21
- // eslint-disable-next-line no-restricted-imports
22
-
23
18
  /**
24
19
  * Internal dependencies
25
20
  */
@@ -30,7 +25,8 @@ var _useInstanceId = _interopRequireDefault(require("../../hooks/use-instance-id
30
25
  */
31
26
  const withInstanceId = (0, _createHigherOrderComponent.default)(WrappedComponent => {
32
27
  return props => {
33
- const instanceId = (0, _useInstanceId.default)(WrappedComponent);
28
+ const instanceId = (0, _useInstanceId.default)(WrappedComponent); // @ts-ignore
29
+
34
30
  return (0, _element.createElement)(WrappedComponent, (0, _extends2.default)({}, props, {
35
31
  instanceId: instanceId
36
32
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/with-instance-id/index.tsx"],"names":["withInstanceId","WrappedComponent","props","instanceId"],"mappings":";;;;;;;;;;;;;AASA;;AAEA;;AAXA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA,MAAMA,cAEH,GAAG,yCAEJC,gBADD,IAEK;AACJ,SAASC,KAAF,IAA2C;AACjD,UAAMC,UAAU,GAAG,4BAAeF,gBAAf,CAAnB;AACA,WACC,4BAAC,gBAAD,6BACQC,KADR;AAEC,MAAA,UAAU,EAAGC;AAFd,OADD;AAMA,GARD;AASA,CAbI,EAcL,gBAdK,CAFN;eAmBeH,c","sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { ComponentType } from 'react';\n\n/**\n * Internal dependencies\n */\nimport createHigherOrderComponent from '../../utils/create-higher-order-component';\nimport type { PropInjectingHigherOrderComponent } 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: PropInjectingHigherOrderComponent< {\n\tinstanceId: string | number;\n} > = createHigherOrderComponent(\n\t< TProps extends { instanceId: string | number } >(\n\t\tWrappedComponent: ComponentType< TProps >\n\t) => {\n\t\treturn ( props: Omit< TProps, 'instanceId' > ) => {\n\t\t\tconst instanceId = useInstanceId( WrappedComponent );\n\t\t\treturn (\n\t\t\t\t<WrappedComponent\n\t\t\t\t\t{ ...( props as TProps ) }\n\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t/>\n\t\t\t);\n\t\t};\n\t},\n\t'withInstanceId'\n);\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;;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 +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":";;;;;;;;;AAUA;;AAPA;;AAYA;;AAfA;AACA;AACA;;AAKA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA,MAAMA,eAAkE,GAAG,yCAEzEC,iBADD,IAEK;AACJ,SAAO,MAAMC,gBAAN,SAA+BC,kBAA/B,CAEL;AAGDC,IAAAA,WAAW,CAAEC,KAAF,EAAe;AACzB,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;AAKA,aAAO,4BAAC,iBAAD,EAA0BJ,KAA1B,CAAP;AACA;;AAnCA,GAFF;AAuCA,CA3CyE,EA4C1E,iBA5C0E,CAA3E;eA+CeL,e","sourcesContent":["/**\n * External dependencies\n */\nimport { without } from 'lodash';\n// eslint-disable-next-line no-restricted-imports\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';\nimport type { PropInjectingHigherOrderComponent } 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: PropInjectingHigherOrderComponent< TimeoutProps > = createHigherOrderComponent(\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: any ) {\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};\n\t\t\t\treturn <OriginalComponent { ...( props as TProps ) } />;\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":";;;;;;;;;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"]}
@@ -36,6 +36,7 @@ var _createHigherOrderComponent = _interopRequireDefault(require("../../utils/cr
36
36
  function withState() {
37
37
  let initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
38
38
  (0, _deprecated.default)('wp.compose.withState', {
39
+ since: '5.8',
39
40
  alternative: 'wp.element.useState'
40
41
  });
41
42
  return (0, _createHigherOrderComponent.default)(OriginalComponent => {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/with-state/index.js"],"names":["withState","initialState","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,WAAW,EAAE;AADsB,GAApC;AAIA,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,GAAaT,YAAb;AACA;;AAEDU,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\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,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"]}
@@ -41,8 +41,7 @@ function useCopyOnClick(ref, text) {
41
41
 
42
42
  /* eslint-enable jsdoc/no-undefined-types */
43
43
  (0, _deprecated.default)('wp.compose.useCopyOnClick', {
44
- since: '10.3',
45
- plugin: 'Gutenberg',
44
+ since: '5.8',
46
45
  alternative: 'wp.compose.useCopyToClipboard'
47
46
  });
48
47
  /** @type {import('react').MutableRefObject<Clipboard | undefined>} */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-copy-on-click/index.js"],"names":["useCopyOnClick","ref","text","timeout","since","plugin","alternative","clipboard","hasCopied","setHasCopied","timeoutId","current","Clipboard","on","clearSelection","trigger","focus","clearTimeout","setTimeout","destroy"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAT,CAAyBC,GAAzB,EAA8BC,IAA9B,EAAqD;AAAA,MAAjBC,OAAiB,uEAAP,IAAO;;AACnE;AACA,2BAAY,2BAAZ,EAAyC;AACxCC,IAAAA,KAAK,EAAE,MADiC;AAExCC,IAAAA,MAAM,EAAE,WAFgC;AAGxCC,IAAAA,WAAW,EAAE;AAH2B,GAAzC;AAMA;;AACA,QAAMC,SAAS,GAAG,sBAAlB;AACA,QAAM,CAAEC,SAAF,EAAaC,YAAb,IAA8B,uBAAU,KAAV,CAApC;AAEA,0BAAW,MAAM;AAChB;AACA,QAAIC,SAAJ;;AAEA,QAAK,CAAET,GAAG,CAACU,OAAX,EAAqB;AACpB;AACA,KANe,CAQhB;;;AACAJ,IAAAA,SAAS,CAACI,OAAV,GAAoB,IAAIC,kBAAJ,CAAeX,GAAG,CAACU,OAAnB,EAA4B;AAC/CT,MAAAA,IAAI,EAAE,MAAQ,OAAOA,IAAP,KAAgB,UAAhB,GAA6BA,IAAI,EAAjC,GAAsCA;AADL,KAA5B,CAApB;AAIAK,IAAAA,SAAS,CAACI,OAAV,CAAkBE,EAAlB,CAAsB,SAAtB,EAAiC,QAAmC;AAAA,UAAjC;AAAEC,QAAAA,cAAF;AAAkBC,QAAAA;AAAlB,OAAiC;AACnE;AACA;AACA;AACAD,MAAAA,cAAc,GAJqD,CAMnE;;AACA,UAAKC,OAAL,EAAe;AACd;AAA6BA,QAAAA,OAAF,CAAYC,KAAZ;AAC3B;;AAED,UAAKb,OAAL,EAAe;AACdM,QAAAA,YAAY,CAAE,IAAF,CAAZ;AACAQ,QAAAA,YAAY,CAAEP,SAAF,CAAZ;AACAA,QAAAA,SAAS,GAAGQ,UAAU,CAAE,MAAMT,YAAY,CAAE,KAAF,CAApB,EAA+BN,OAA/B,CAAtB;AACA;AACD,KAhBD;AAkBA,WAAO,MAAM;AACZ,UAAKI,SAAS,CAACI,OAAf,EAAyB;AACxBJ,QAAAA,SAAS,CAACI,OAAV,CAAkBQ,OAAlB;AACA;;AACDF,MAAAA,YAAY,CAAEP,SAAF,CAAZ;AACA,KALD;AAMA,GArCD,EAqCG,CAAER,IAAF,EAAQC,OAAR,EAAiBM,YAAjB,CArCH;AAuCA,SAAOD,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport Clipboard from 'clipboard';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/* eslint-disable jsdoc/no-undefined-types */\n/**\n * Copies the text to the clipboard when the element is clicked.\n *\n * @deprecated\n *\n * @param {import('react').RefObject<string | Element | NodeListOf<Element>>} ref Reference with the element.\n * @param {string|Function} text The text to copy.\n * @param {number} [timeout] Optional timeout to reset the returned\n * state. 4 seconds by default.\n *\n * @return {boolean} Whether or not the text has been copied. Resets after the\n * timeout.\n */\nexport default function useCopyOnClick( ref, text, timeout = 4000 ) {\n\t/* eslint-enable jsdoc/no-undefined-types */\n\tdeprecated( 'wp.compose.useCopyOnClick', {\n\t\tsince: '10.3',\n\t\tplugin: 'Gutenberg',\n\t\talternative: 'wp.compose.useCopyToClipboard',\n\t} );\n\n\t/** @type {import('react').MutableRefObject<Clipboard | undefined>} */\n\tconst clipboard = useRef();\n\tconst [ hasCopied, setHasCopied ] = useState( false );\n\n\tuseEffect( () => {\n\t\t/** @type {number | undefined} */\n\t\tlet timeoutId;\n\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Clipboard listens to click events.\n\t\tclipboard.current = new Clipboard( ref.current, {\n\t\t\ttext: () => ( typeof text === 'function' ? text() : text ),\n\t\t} );\n\n\t\tclipboard.current.on( 'success', ( { clearSelection, trigger } ) => {\n\t\t\t// Clearing selection will move focus back to the triggering button,\n\t\t\t// ensuring that it is not reset to the body, and further that it is\n\t\t\t// kept within the rendered node.\n\t\t\tclearSelection();\n\n\t\t\t// Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680\n\t\t\tif ( trigger ) {\n\t\t\t\t/** @type {HTMLElement} */ ( trigger ).focus();\n\t\t\t}\n\n\t\t\tif ( timeout ) {\n\t\t\t\tsetHasCopied( true );\n\t\t\t\tclearTimeout( timeoutId );\n\t\t\t\ttimeoutId = setTimeout( () => setHasCopied( false ), timeout );\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tif ( clipboard.current ) {\n\t\t\t\tclipboard.current.destroy();\n\t\t\t}\n\t\t\tclearTimeout( timeoutId );\n\t\t};\n\t}, [ text, timeout, setHasCopied ] );\n\n\treturn hasCopied;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-copy-on-click/index.js"],"names":["useCopyOnClick","ref","text","timeout","since","alternative","clipboard","hasCopied","setHasCopied","timeoutId","current","Clipboard","on","clearSelection","trigger","focus","clearTimeout","setTimeout","destroy"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAT,CAAyBC,GAAzB,EAA8BC,IAA9B,EAAqD;AAAA,MAAjBC,OAAiB,uEAAP,IAAO;;AACnE;AACA,2BAAY,2BAAZ,EAAyC;AACxCC,IAAAA,KAAK,EAAE,KADiC;AAExCC,IAAAA,WAAW,EAAE;AAF2B,GAAzC;AAKA;;AACA,QAAMC,SAAS,GAAG,sBAAlB;AACA,QAAM,CAAEC,SAAF,EAAaC,YAAb,IAA8B,uBAAU,KAAV,CAApC;AAEA,0BAAW,MAAM;AAChB;AACA,QAAIC,SAAJ;;AAEA,QAAK,CAAER,GAAG,CAACS,OAAX,EAAqB;AACpB;AACA,KANe,CAQhB;;;AACAJ,IAAAA,SAAS,CAACI,OAAV,GAAoB,IAAIC,kBAAJ,CAAeV,GAAG,CAACS,OAAnB,EAA4B;AAC/CR,MAAAA,IAAI,EAAE,MAAQ,OAAOA,IAAP,KAAgB,UAAhB,GAA6BA,IAAI,EAAjC,GAAsCA;AADL,KAA5B,CAApB;AAIAI,IAAAA,SAAS,CAACI,OAAV,CAAkBE,EAAlB,CAAsB,SAAtB,EAAiC,QAAmC;AAAA,UAAjC;AAAEC,QAAAA,cAAF;AAAkBC,QAAAA;AAAlB,OAAiC;AACnE;AACA;AACA;AACAD,MAAAA,cAAc,GAJqD,CAMnE;;AACA,UAAKC,OAAL,EAAe;AACd;AAA6BA,QAAAA,OAAF,CAAYC,KAAZ;AAC3B;;AAED,UAAKZ,OAAL,EAAe;AACdK,QAAAA,YAAY,CAAE,IAAF,CAAZ;AACAQ,QAAAA,YAAY,CAAEP,SAAF,CAAZ;AACAA,QAAAA,SAAS,GAAGQ,UAAU,CAAE,MAAMT,YAAY,CAAE,KAAF,CAApB,EAA+BL,OAA/B,CAAtB;AACA;AACD,KAhBD;AAkBA,WAAO,MAAM;AACZ,UAAKG,SAAS,CAACI,OAAf,EAAyB;AACxBJ,QAAAA,SAAS,CAACI,OAAV,CAAkBQ,OAAlB;AACA;;AACDF,MAAAA,YAAY,CAAEP,SAAF,CAAZ;AACA,KALD;AAMA,GArCD,EAqCG,CAAEP,IAAF,EAAQC,OAAR,EAAiBK,YAAjB,CArCH;AAuCA,SAAOD,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport Clipboard from 'clipboard';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/* eslint-disable jsdoc/no-undefined-types */\n/**\n * Copies the text to the clipboard when the element is clicked.\n *\n * @deprecated\n *\n * @param {import('react').RefObject<string | Element | NodeListOf<Element>>} ref Reference with the element.\n * @param {string|Function} text The text to copy.\n * @param {number} [timeout] Optional timeout to reset the returned\n * state. 4 seconds by default.\n *\n * @return {boolean} Whether or not the text has been copied. Resets after the\n * timeout.\n */\nexport default function useCopyOnClick( ref, text, timeout = 4000 ) {\n\t/* eslint-enable jsdoc/no-undefined-types */\n\tdeprecated( 'wp.compose.useCopyOnClick', {\n\t\tsince: '5.8',\n\t\talternative: 'wp.compose.useCopyToClipboard',\n\t} );\n\n\t/** @type {import('react').MutableRefObject<Clipboard | undefined>} */\n\tconst clipboard = useRef();\n\tconst [ hasCopied, setHasCopied ] = useState( false );\n\n\tuseEffect( () => {\n\t\t/** @type {number | undefined} */\n\t\tlet timeoutId;\n\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Clipboard listens to click events.\n\t\tclipboard.current = new Clipboard( ref.current, {\n\t\t\ttext: () => ( typeof text === 'function' ? text() : text ),\n\t\t} );\n\n\t\tclipboard.current.on( 'success', ( { clearSelection, trigger } ) => {\n\t\t\t// Clearing selection will move focus back to the triggering button,\n\t\t\t// ensuring that it is not reset to the body, and further that it is\n\t\t\t// kept within the rendered node.\n\t\t\tclearSelection();\n\n\t\t\t// Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680\n\t\t\tif ( trigger ) {\n\t\t\t\t/** @type {HTMLElement} */ ( trigger ).focus();\n\t\t\t}\n\n\t\t\tif ( timeout ) {\n\t\t\t\tsetHasCopied( true );\n\t\t\t\tclearTimeout( timeoutId );\n\t\t\t\ttimeoutId = setTimeout( () => setHasCopied( false ), timeout );\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tif ( clipboard.current ) {\n\t\t\t\tclipboard.current.destroy();\n\t\t\t}\n\t\t\tclearTimeout( timeoutId );\n\t\t};\n\t}, [ text, timeout, setHasCopied ] );\n\n\treturn hasCopied;\n}\n"]}
@@ -10,7 +10,6 @@ var _element = require("@wordpress/element");
10
10
  /**
11
11
  * External dependencies
12
12
  */
13
- // eslint-disable-next-line no-restricted-imports
14
13
 
15
14
  /**
16
15
  * WordPress dependencies
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-ref-effect/index.ts"],"names":["useRefEffect","callback","dependencies","cleanup","node","current"],"mappings":";;;;;;;AASA;;AATA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,YAAT,CACdC,QADc,EAEdC,YAFc,EAGmB;AACjC,QAAMC,OAAO,GAAG,sBAAhB;AACA,SAAO,0BAAeC,IAAF,IAA6B;AAChD,QAAKA,IAAL,EAAY;AACXD,MAAAA,OAAO,CAACE,OAAR,GAAkBJ,QAAQ,CAAEG,IAAF,CAA1B;AACA,KAFD,MAEO,IAAKD,OAAO,CAACE,OAAb,EAAuB;AAC7BF,MAAAA,OAAO,CAACE,OAAR;AACA;AACD,GANM,EAMJH,YANI,CAAP;AAOA","sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { DependencyList, RefCallback } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useRef } from '@wordpress/element';\n\n/**\n * Effect-like ref callback. Just like with `useEffect`, this allows you to\n * return a cleanup function to be run if the ref changes or one of the\n * dependencies changes. The ref is provided as an argument to the callback\n * functions. The main difference between this and `useEffect` is that\n * the `useEffect` callback is not called when the ref changes, but this is.\n * Pass the returned ref callback as the component's ref and merge multiple refs\n * with `useMergeRefs`.\n *\n * It's worth noting that if the dependencies array is empty, there's not\n * strictly a need to clean up event handlers for example, because the node is\n * to be removed. It *is* necessary if you add dependencies because the ref\n * callback will be called multiple times for the same node.\n *\n * @param callback Callback with ref as argument.\n * @param dependencies Dependencies of the callback.\n *\n * @return Ref callback.\n */\nexport default function useRefEffect< TElement = Node >(\n\tcallback: ( node: TElement ) => ( () => void ) | undefined,\n\tdependencies: DependencyList\n): RefCallback< TElement | null > {\n\tconst cleanup = useRef< ( () => void ) | undefined >();\n\treturn useCallback( ( node: TElement | null ) => {\n\t\tif ( node ) {\n\t\t\tcleanup.current = callback( node );\n\t\t} else if ( cleanup.current ) {\n\t\t\tcleanup.current();\n\t\t}\n\t}, dependencies );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-ref-effect/index.ts"],"names":["useRefEffect","callback","dependencies","cleanup","node","current"],"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;AACA;AACe,SAASA,YAAT,CACdC,QADc,EAEdC,YAFc,EAGmB;AACjC,QAAMC,OAAO,GAAG,sBAAhB;AACA,SAAO,0BAAeC,IAAF,IAA6B;AAChD,QAAKA,IAAL,EAAY;AACXD,MAAAA,OAAO,CAACE,OAAR,GAAkBJ,QAAQ,CAAEG,IAAF,CAA1B;AACA,KAFD,MAEO,IAAKD,OAAO,CAACE,OAAb,EAAuB;AAC7BF,MAAAA,OAAO,CAACE,OAAR;AACA;AACD,GANM,EAMJH,YANI,CAAP;AAOA","sourcesContent":["/**\n * External dependencies\n */\nimport type { DependencyList, RefCallback } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useRef } from '@wordpress/element';\n\n/**\n * Effect-like ref callback. Just like with `useEffect`, this allows you to\n * return a cleanup function to be run if the ref changes or one of the\n * dependencies changes. The ref is provided as an argument to the callback\n * functions. The main difference between this and `useEffect` is that\n * the `useEffect` callback is not called when the ref changes, but this is.\n * Pass the returned ref callback as the component's ref and merge multiple refs\n * with `useMergeRefs`.\n *\n * It's worth noting that if the dependencies array is empty, there's not\n * strictly a need to clean up event handlers for example, because the node is\n * to be removed. It *is* necessary if you add dependencies because the ref\n * callback will be called multiple times for the same node.\n *\n * @param callback Callback with ref as argument.\n * @param dependencies Dependencies of the callback.\n *\n * @return Ref callback.\n */\nexport default function useRefEffect< TElement = Node >(\n\tcallback: ( node: TElement ) => ( () => void ) | undefined,\n\tdependencies: DependencyList\n): RefCallback< TElement | null > {\n\tconst cleanup = useRef< ( () => void ) | undefined >();\n\treturn useCallback( ( node: TElement | null ) => {\n\t\tif ( node ) {\n\t\t\tcleanup.current = callback( node );\n\t\t} else if ( cleanup.current ) {\n\t\t\tcleanup.current();\n\t\t}\n\t}, dependencies );\n}\n"]}
@@ -15,8 +15,8 @@ var _lodash = require("lodash");
15
15
  * Given a function mapping a component to an enhanced component and modifier
16
16
  * name, returns the enhanced component augmented with a generated displayName.
17
17
  *
18
- * @param mapComponentToEnhancedComponent Function mapping component to enhanced component.
19
- * @param modifierName Seed name from which to generated display name.
18
+ * @param mapComponent Function mapping component to enhanced component.
19
+ * @param modifierName Seed name from which to generated display name.
20
20
  *
21
21
  * @return Component class with generated display name assigned.
22
22
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/utils/create-higher-order-component/index.ts"],"names":["createHigherOrderComponent","mapComponent","modifierName","Inner","Outer","displayName","name"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AA4BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA,SAASA,0BAAT,CACCC,YADD,EAECC,YAFD,EAGoD;AACnD,SAASC,KAAF,IAAa;AACnB,UAAMC,KAAK,GAAGH,YAAY,CAAEE,KAAF,CAA1B;AACA,UAAME,WAAW,GAAGF,KAAK,CAACE,WAAN,IAAqBF,KAAK,CAACG,IAA3B,IAAmC,WAAvD;AACAF,IAAAA,KAAK,CAACC,WAAN,GAAqB,GAAG,wBACvB,uBAAWH,YAAX,CADuB,CAErB,IAAIG,WAAa,GAFpB;AAGA,WAAOD,KAAP;AACA,GAPD;AAQA;;eACcJ,0B","sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase, upperFirst } from 'lodash';\n// eslint-disable-next-line no-restricted-imports\nimport type { ComponentType } from 'react';\n\n/**\n * Higher order components can cause props to be obviated. For example a HOC that\n * injects i18n props will obviate the need for the i18n props to be passed to the component.\n *\n * If a HOC does not obviate the need for any specific props then we default to `{}` which\n * essentially subtracts 0 from the original props of the passed in component. An example\n * of this is the `pure` HOC which does not change the API surface of the component but\n * simply modifies the internals.\n */\nexport type HigherOrderComponent< TInnerProps, TOuterProps > = (\n\tInner: ComponentType< TInnerProps >\n) => ComponentType< TOuterProps >;\n\nexport type SimpleHigherOrderComponent = < TProps >(\n\tInner: ComponentType< TProps >\n) => ComponentType< TProps >;\n\nexport type PropInjectingHigherOrderComponent< TRemovedProps > = <\n\tTProps extends TRemovedProps\n>(\n\tInner: ComponentType< TProps >\n) => ComponentType< Omit< TProps, keyof TRemovedProps > >;\n\n/**\n * Given a function mapping a component to an enhanced component and modifier\n * name, returns the enhanced component augmented with a generated displayName.\n *\n * @param mapComponentToEnhancedComponent Function mapping component to enhanced component.\n * @param modifierName Seed name from which to generated display name.\n *\n * @return Component class with generated display name assigned.\n */\n\nfunction createHigherOrderComponent< TInnerProps, TOuterProps >(\n\tmapComponent: HigherOrderComponent< TInnerProps, TOuterProps >,\n\tmodifierName: string\n): HigherOrderComponent< TInnerProps, TOuterProps > {\n\treturn ( Inner ) => {\n\t\tconst Outer = mapComponent( Inner );\n\t\tconst displayName = Inner.displayName || Inner.name || 'Component';\n\t\tOuter.displayName = `${ upperFirst(\n\t\t\tcamelCase( modifierName )\n\t\t) }(${ displayName })`;\n\t\treturn Outer;\n\t};\n}\nexport default createHigherOrderComponent;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/utils/create-higher-order-component/index.ts"],"names":["createHigherOrderComponent","mapComponent","modifierName","Inner","Outer","displayName","name"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,0BAAT,CAEGC,YAFH,EAEmDC,YAFnD,EAE0E;AACzE,SACCC,KADM,IAEF;AACJ,UAAMC,KAAK,GAAGH,YAAY,CAAEE,KAAF,CAA1B;AACA,UAAME,WAAW,GAAGF,KAAK,CAACE,WAAN,IAAqBF,KAAK,CAACG,IAA3B,IAAmC,WAAvD;AACAF,IAAAA,KAAK,CAACC,WAAN,GAAqB,GAAG,wBACvB,uBAAWH,YAAX,CADuB,CAErB,IAAIG,WAAa,GAFpB;AAGA,WAAOD,KAAP;AACA,GATD;AAUA;;eAEcJ,0B","sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase, upperFirst } from 'lodash';\nimport type { ComponentType } from 'react';\n\n/**\n * Higher order components can cause props to be obviated. For example a HOC that\n * injects i18n props will obviate the need for the i18n props to be passed to the component.\n *\n * If a HOC does not obviate the need for any specific props then we default to `{}` which\n * essentially subtracts 0 from the original props of the passed in component. An example\n * of this is the `pure` HOC which does not change the API surface of the component but\n * simply modifies the internals.\n */\nexport type HigherOrderComponent< HOCProps extends Record< string, any > > = <\n\tInnerProps extends HOCProps\n>(\n\tInner: ComponentType< InnerProps >\n) => {} extends HOCProps\n\t? ComponentType< InnerProps >\n\t: ComponentType< Omit< InnerProps, keyof HOCProps > >;\n\n/**\n * Given a function mapping a component to an enhanced component and modifier\n * name, returns the enhanced component augmented with a generated displayName.\n *\n * @param mapComponent Function mapping component to enhanced component.\n * @param modifierName Seed name from which to generated display name.\n *\n * @return Component class with generated display name assigned.\n */\nfunction createHigherOrderComponent<\n\tHOCProps extends Record< string, any > = {}\n>( mapComponent: HigherOrderComponent< HOCProps >, modifierName: string ) {\n\treturn < InnerProps extends HOCProps >(\n\t\tInner: ComponentType< InnerProps >\n\t) => {\n\t\tconst Outer = mapComponent( Inner );\n\t\tconst displayName = Inner.displayName || Inner.name || 'Component';\n\t\tOuter.displayName = `${ upperFirst(\n\t\t\tcamelCase( modifierName )\n\t\t) }(${ displayName })`;\n\t\treturn Outer;\n\t};\n}\n\nexport default createHigherOrderComponent;\n"]}
@@ -4,7 +4,6 @@ import { createElement } from "@wordpress/element";
4
4
  * Internal dependencies
5
5
  */
6
6
  import createHigherOrderComponent from '../../utils/create-higher-order-component';
7
-
8
7
  /**
9
8
  * Higher-order component creator, creating a new component which renders if
10
9
  * the given condition is satisfied or with the given optional prop name.
@@ -22,6 +21,7 @@ import createHigherOrderComponent from '../../utils/create-higher-order-componen
22
21
  *
23
22
  * @return Higher-order component.
24
23
  */
24
+
25
25
  const ifCondition = predicate => createHigherOrderComponent(WrappedComponent => props => {
26
26
  if (!predicate(props)) {
27
27
  return null;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/if-condition/index.tsx"],"names":["createHigherOrderComponent","ifCondition","predicate","WrappedComponent","props"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,0BAAP,MAAuC,2CAAvC;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,WAAW,GAChBC,SADmB,IAGnBF,0BAA0B,CACvBG,gBAAF,IAA0BC,KAAF,IAAqB;AAC5C,MAAK,CAAEF,SAAS,CAAEE,KAAF,CAAhB,EAA4B;AAC3B,WAAO,IAAP;AACA;;AAED,SAAO,cAAC,gBAAD,EAAuBA,KAAvB,CAAP;AACA,CAPwB,EAQzB,aARyB,CAH3B;;AAcA,eAAeH,WAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport createHigherOrderComponent from '../../utils/create-higher-order-component';\nimport type { HigherOrderComponent } 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, >(\n\tpredicate: ( props: TProps ) => boolean\n): HigherOrderComponent< TProps, TProps > =>\n\tcreateHigherOrderComponent(\n\t\t( WrappedComponent ) => ( props: TProps ) => {\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\nexport default ifCondition;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/if-condition/index.tsx"],"names":["createHigherOrderComponent","ifCondition","predicate","WrappedComponent","props"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,0BAAP,MAAuC,2CAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,WAAW,GAChBC,SADmB,IAGnBF,0BAA0B,CACvBG,gBAAF,IAA0BC,KAAF,IAAa;AACpC,MAAK,CAAEF,SAAS,CAAEE,KAAF,CAAhB,EAAsC;AACrC,WAAO,IAAP;AACA;;AAED,SAAO,cAAC,gBAAD,EAAuBA,KAAvB,CAAP;AACA,CAPwB,EAQzB,aARyB,CAH3B;;AAcA,eAAeH,WAAf","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"]}
@@ -10,10 +10,13 @@ import { Component } from '@wordpress/element';
10
10
  */
11
11
 
12
12
  import createHigherOrderComponent from '../../utils/create-higher-order-component';
13
+ /**
14
+ * External dependencies
15
+ */
13
16
 
14
17
  /**
15
18
  * Given a component returns the enhanced component augmented with a component
16
- * only rerendering when its props/state change
19
+ * only re-rendering when its props/state change
17
20
  */
18
21
  const pure = createHigherOrderComponent(Wrapped => {
19
22
  if (Wrapped.prototype instanceof Component) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/pure/index.tsx"],"names":["isShallowEqual","Component","createHigherOrderComponent","pure","Wrapped","prototype","shouldComponentUpdate","nextProps","nextState","props","state","render"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,6BAA3B;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,0BAAP,MAAuC,2CAAvC;;AASA;AACA;AACA;AACA;AACA,MAAMC,IAAgC,GAAGD,0BAA0B,CACrDE,OAAb,IAAmD;AAClD,MAAKA,OAAO,CAACC,SAAR,YAA6BJ,SAAlC,EAA8C;AAC7C,WAAO,cAAgBG,OAAhB,CAAsD;AAC5DE,MAAAA,qBAAqB,CAAEC,SAAF,EAAqBC,SAArB,EAAsC;AAC1D,eACC,CAAER,cAAc,CAAEO,SAAF,EAAa,KAAKE,KAAlB,CAAhB,IACA,CAAET,cAAc,CAAEQ,SAAF,EAAa,KAAKE,KAAlB,CAFjB;AAIA;;AAN2D,KAA7D;AAQA;;AAED,SAAO,cAAcT,SAAd,CAAkC;AACxCK,IAAAA,qBAAqB,CAAEC,SAAF,EAAsB;AAC1C,aAAO,CAAEP,cAAc,CAAEO,SAAF,EAAa,KAAKE,KAAlB,CAAvB;AACA;;AAEDE,IAAAA,MAAM,GAAG;AACR,aAAO,cAAC,OAAD,EAAc,KAAKF,KAAnB,CAAP;AACA;;AAPuC,GAAzC;AASA,CAtBiE,EAuBlE,MAvBkE,CAAnE;AA0BA,eAAeN,IAAf","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';\nimport type { SimpleHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { ComponentType, ComponentClass } from 'react';\n\n/**\n * Given a component returns the enhanced component augmented with a component\n * only rerendering when its props/state change\n */\nconst pure: SimpleHigherOrderComponent = createHigherOrderComponent(\n\t< TProps, >( Wrapped: ComponentType< TProps > ) => {\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":["isShallowEqual","Component","createHigherOrderComponent","pure","Wrapped","prototype","shouldComponentUpdate","nextProps","nextState","props","state","render"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,6BAA3B;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,0BAAP,MAAuC,2CAAvC;AAEA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA,MAAMC,IAAI,GAAGD,0BAA0B,CAErCE,OADD,IAEK;AACJ,MAAKA,OAAO,CAACC,SAAR,YAA6BJ,SAAlC,EAA8C;AAC7C,WAAO,cAAgBG,OAAhB,CAAsD;AAC5DE,MAAAA,qBAAqB,CAAEC,SAAF,EAAqBC,SAArB,EAAsC;AAC1D,eACC,CAAER,cAAc,CAAEO,SAAF,EAAa,KAAKE,KAAlB,CAAhB,IACA,CAAET,cAAc,CAAEQ,SAAF,EAAa,KAAKE,KAAlB,CAFjB;AAIA;;AAN2D,KAA7D;AAQA;;AAED,SAAO,cAAcT,SAAd,CAAkC;AACxCK,IAAAA,qBAAqB,CAAEC,SAAF,EAAsB;AAC1C,aAAO,CAAEP,cAAc,CAAEO,SAAF,EAAa,KAAKE,KAAlB,CAAvB;AACA;;AAEDE,IAAAA,MAAM,GAAG;AACR,aAAO,cAAC,OAAD,EAAc,KAAKF,KAAnB,CAAP;AACA;;AAPuC,GAAzC;AASA,CAxBqC,EAyBtC,MAzBsC,CAAvC;AA4BA,eAAeN,IAAf","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"]}
@@ -48,7 +48,8 @@ export default function withGlobalEvents(eventTypesToHandlers) {
48
48
  deprecated('wp.compose.withGlobalEvents', {
49
49
  since: '5.7',
50
50
  alternative: 'useEffect'
51
- });
51
+ }); // @ts-ignore We don't need to fix the type-related issues because this is deprecated.
52
+
52
53
  return createHigherOrderComponent(WrappedComponent => {
53
54
  class Wrapper extends Component {
54
55
  constructor(
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/with-global-events/index.js"],"names":["forEach","Component","forwardRef","deprecated","createHigherOrderComponent","Listener","listener","withGlobalEvents","eventTypesToHandlers","since","alternative","WrappedComponent","Wrapper","constructor","props","handleEvent","bind","handleRef","componentDidMount","_","eventType","add","componentWillUnmount","remove","event","handler","type","wrappedRef","el","forwardedRef","render","ownProps","ref"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,UAApB,QAAsC,oBAAtC;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,0BAAP,MAAuC,2CAAvC;AACA,OAAOC,QAAP,MAAqB,YAArB;AAEA;AACA;AACA;;AACA,MAAMC,QAAQ,GAAG,IAAID,QAAJ,EAAjB;AAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASE,gBAAT,CAA2BC,oBAA3B,EAAkD;AAChEL,EAAAA,UAAU,CAAE,6BAAF,EAAiC;AAC1CM,IAAAA,KAAK,EAAE,KADmC;AAE1CC,IAAAA,WAAW,EAAE;AAF6B,GAAjC,CAAV;AAKA,SAAON,0BAA0B,CAAIO,gBAAF,IAAwB;AAC1D,UAAMC,OAAN,SAAsBX,SAAtB,CAAgC;AAC/BY,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;AACnBlB,QAAAA,OAAO,CAAEQ,oBAAF,EAAwB,CAAEW,CAAF,EAAKC,SAAL,KAAoB;AAClDd,UAAAA,QAAQ,CAACe,GAAT,CAAcD,SAAd,EAAyB,IAAzB;AACA,SAFM,CAAP;AAGA;;AAEDE,MAAAA,oBAAoB,GAAG;AACtBtB,QAAAA,OAAO,CAAEQ,oBAAF,EAAwB,CAAEW,CAAF,EAAKC,SAAL,KAAoB;AAClDd,UAAAA,QAAQ,CAACiB,MAAT,CAAiBH,SAAjB,EAA4B,IAA5B;AACA,SAFM,CAAP;AAGA;;AAEDL,MAAAA,WAAW;AAAE;AAAmBS,MAAAA,KAArB,EAA6B;AACvC,cAAMC,OAAO,GACZjB,oBAAoB;AACnB;AAAmDgB,QAAAA,KAAK,CAACE;AACzD;AAFmB,SADrB;;AAKA,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,cAAC,gBAAD,eACM,KAAKhB,KAAL,CAAWiB,QADjB;AAEC,UAAA,GAAG,EAAG,KAAKd;AAFZ,WADD;AAMA;;AAhD8B;;AAmDhC,WAAOf,UAAU,CAAE,CAAEY,KAAF,EAASkB,GAAT,KAAkB;AACpC,aAAO,cAAC,OAAD;AAAS,QAAA,QAAQ,EAAGlB,KAApB;AAA4B,QAAA,YAAY,EAAGkB;AAA3C,QAAP;AACA,KAFgB,CAAjB;AAGA,GAvDgC,EAuD9B,kBAvD8B,CAAjC;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\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":["forEach","Component","forwardRef","deprecated","createHigherOrderComponent","Listener","listener","withGlobalEvents","eventTypesToHandlers","since","alternative","WrappedComponent","Wrapper","constructor","props","handleEvent","bind","handleRef","componentDidMount","_","eventType","add","componentWillUnmount","remove","event","handler","type","wrappedRef","el","forwardedRef","render","ownProps","ref"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,UAApB,QAAsC,oBAAtC;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,0BAAP,MAAuC,2CAAvC;AACA,OAAOC,QAAP,MAAqB,YAArB;AAEA;AACA;AACA;;AACA,MAAMC,QAAQ,GAAG,IAAID,QAAJ,EAAjB;AAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASE,gBAAT,CAA2BC,oBAA3B,EAAkD;AAChEL,EAAAA,UAAU,CAAE,6BAAF,EAAiC;AAC1CM,IAAAA,KAAK,EAAE,KADmC;AAE1CC,IAAAA,WAAW,EAAE;AAF6B,GAAjC,CAAV,CADgE,CAMhE;;AACA,SAAON,0BAA0B,CAAIO,gBAAF,IAAwB;AAC1D,UAAMC,OAAN,SAAsBX,SAAtB,CAAgC;AAC/BY,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;AACnBlB,QAAAA,OAAO,CAAEQ,oBAAF,EAAwB,CAAEW,CAAF,EAAKC,SAAL,KAAoB;AAClDd,UAAAA,QAAQ,CAACe,GAAT,CAAcD,SAAd,EAAyB,IAAzB;AACA,SAFM,CAAP;AAGA;;AAEDE,MAAAA,oBAAoB,GAAG;AACtBtB,QAAAA,OAAO,CAAEQ,oBAAF,EAAwB,CAAEW,CAAF,EAAKC,SAAL,KAAoB;AAClDd,UAAAA,QAAQ,CAACiB,MAAT,CAAiBH,SAAjB,EAA4B,IAA5B;AACA,SAFM,CAAP;AAGA;;AAEDL,MAAAA,WAAW;AAAE;AAAmBS,MAAAA,KAArB,EAA6B;AACvC,cAAMC,OAAO,GACZjB,oBAAoB;AACnB;AAAmDgB,QAAAA,KAAK,CAACE;AACzD;AAFmB,SADrB;;AAKA,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,cAAC,gBAAD,eACM,KAAKhB,KAAL,CAAWiB,QADjB;AAEC,UAAA,GAAG,EAAG,KAAKd;AAFZ,WADD;AAMA;;AAhD8B;;AAmDhC,WAAOf,UAAU,CAAE,CAAEY,KAAF,EAASkB,GAAT,KAAkB;AACpC,aAAO,cAAC,OAAD;AAAS,QAAA,QAAQ,EAAGlB,KAApB;AAA4B,QAAA,YAAY,EAAGkB;AAA3C,QAAP;AACA,KAFgB,CAAjB;AAGA,GAvDgC,EAuD9B,kBAvD8B,CAAjC;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,11 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { createElement } from "@wordpress/element";
3
3
 
4
- /**
5
- * External dependencies
6
- */
7
- // eslint-disable-next-line no-restricted-imports
8
-
9
4
  /**
10
5
  * Internal dependencies
11
6
  */
@@ -18,7 +13,8 @@ import useInstanceId from '../../hooks/use-instance-id';
18
13
 
19
14
  const withInstanceId = createHigherOrderComponent(WrappedComponent => {
20
15
  return props => {
21
- const instanceId = useInstanceId(WrappedComponent);
16
+ const instanceId = useInstanceId(WrappedComponent); // @ts-ignore
17
+
22
18
  return createElement(WrappedComponent, _extends({}, props, {
23
19
  instanceId: instanceId
24
20
  }));
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/with-instance-id/index.tsx"],"names":["createHigherOrderComponent","useInstanceId","withInstanceId","WrappedComponent","props","instanceId"],"mappings":";;;AAAA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAOA,0BAAP,MAAuC,2CAAvC;AAEA,OAAOC,aAAP,MAA0B,6BAA1B;AAEA;AACA;AACA;AACA;;AACA,MAAMC,cAEH,GAAGF,0BAA0B,CAE9BG,gBADD,IAEK;AACJ,SAASC,KAAF,IAA2C;AACjD,UAAMC,UAAU,GAAGJ,aAAa,CAAEE,gBAAF,CAAhC;AACA,WACC,cAAC,gBAAD,eACQC,KADR;AAEC,MAAA,UAAU,EAAGC;AAFd,OADD;AAMA,GARD;AASA,CAb8B,EAc/B,gBAd+B,CAFhC;AAmBA,eAAeH,cAAf","sourcesContent":["/**\n * External dependencies\n */\n// eslint-disable-next-line no-restricted-imports\nimport type { ComponentType } from 'react';\n\n/**\n * Internal dependencies\n */\nimport createHigherOrderComponent from '../../utils/create-higher-order-component';\nimport type { PropInjectingHigherOrderComponent } 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: PropInjectingHigherOrderComponent< {\n\tinstanceId: string | number;\n} > = createHigherOrderComponent(\n\t< TProps extends { instanceId: string | number } >(\n\t\tWrappedComponent: ComponentType< TProps >\n\t) => {\n\t\treturn ( props: Omit< TProps, 'instanceId' > ) => {\n\t\t\tconst instanceId = useInstanceId( WrappedComponent );\n\t\t\treturn (\n\t\t\t\t<WrappedComponent\n\t\t\t\t\t{ ...( props as TProps ) }\n\t\t\t\t\tinstanceId={ instanceId }\n\t\t\t\t/>\n\t\t\t);\n\t\t};\n\t},\n\t'withInstanceId'\n);\n\nexport default withInstanceId;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/with-instance-id/index.tsx"],"names":["createHigherOrderComponent","useInstanceId","withInstanceId","WrappedComponent","props","instanceId"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,0BAAP,MAAuC,2CAAvC;AACA,OAAOC,aAAP,MAA0B,6BAA1B;AAEA;AACA;AACA;AACA;;AACA,MAAMC,cAAc,GAAGF,0BAA0B,CAE1CG,gBAAF,IAAwB;AAC5B,SAASC,KAAF,IAAa;AACnB,UAAMC,UAAU,GAAGJ,aAAa,CAAEE,gBAAF,CAAhC,CADmB,CAEnB;;AACA,WAAO,cAAC,gBAAD,eAAuBC,KAAvB;AAA+B,MAAA,UAAU,EAAGC;AAA5C,OAAP;AACA,GAJD;AAKA,CARgD,EAQ9C,gBAR8C,CAAjD;AAUA,eAAeH,cAAf","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"]}
@@ -3,7 +3,7 @@ import { createElement } from "@wordpress/element";
3
3
  /**
4
4
  * External dependencies
5
5
  */
6
- import { without } from 'lodash'; // eslint-disable-next-line no-restricted-imports
6
+ import { without } from 'lodash';
7
7
 
8
8
  /**
9
9
  * WordPress dependencies
@@ -14,6 +14,14 @@ import { Component } from '@wordpress/element';
14
14
  */
15
15
 
16
16
  import createHigherOrderComponent from '../../utils/create-higher-order-component';
17
+ /**
18
+ * We cannot use the `Window['setTimeout']` and `Window['clearTimeout']`
19
+ * types here because those functions include functionality that is not handled
20
+ * by this component, like the ability to pass extra arguments.
21
+ *
22
+ * In the case of this component, we only handle the simplest case where
23
+ * `setTimeout` only accepts a function (not a string) and an optional delay.
24
+ */
17
25
 
18
26
  /**
19
27
  * A higher-order component used to provide and manage delayed function calls
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/with-safe-timeout/index.tsx"],"names":["without","Component","createHigherOrderComponent","withSafeTimeout","OriginalComponent","WrappedComponent","constructor","props","timeouts","setTimeout","bind","clearTimeout","componentWillUnmount","forEach","fn","delay","id","push","render"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB,C,CACA;;AAGA;AACA;AACA;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,0BAAP,MAAuC,2CAAvC;;AAgBA;AACA;AACA;AACA;AACA,MAAMC,eAAkE,GAAGD,0BAA0B,CAEnGE,iBADD,IAEK;AACJ,SAAO,MAAMC,gBAAN,SAA+BJ,SAA/B,CAEL;AAGDK,IAAAA,WAAW,CAAEC,KAAF,EAAe;AACzB,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,GAAgBR,OAAO,CAAE,KAAKQ,QAAP,EAAiBQ,EAAjB,CAAvB;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;AAKA,aAAO,cAAC,iBAAD,EAA0BJ,KAA1B,CAAP;AACA;;AAnCA,GAFF;AAuCA,CA3CmG,EA4CpG,iBA5CoG,CAArG;AA+CA,eAAeJ,eAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { without } from 'lodash';\n// eslint-disable-next-line no-restricted-imports\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';\nimport type { PropInjectingHigherOrderComponent } 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: PropInjectingHigherOrderComponent< TimeoutProps > = createHigherOrderComponent(\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: any ) {\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};\n\t\t\t\treturn <OriginalComponent { ...( props as TProps ) } />;\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":["without","Component","createHigherOrderComponent","withSafeTimeout","OriginalComponent","WrappedComponent","constructor","props","timeouts","setTimeout","bind","clearTimeout","componentWillUnmount","forEach","fn","delay","id","push","render"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;;AAGA;AACA;AACA;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,0BAAP,MAAuC,2CAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAGD,0BAA0B,CAEhDE,iBADD,IAEK;AACJ,SAAO,MAAMC,gBAAN,SAA+BJ,SAA/B,CAEL;AAGDK,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,GAAgBR,OAAO,CAAE,KAAKQ,QAAP,EAAiBQ,EAAjB,CAAvB;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,cAAC,iBAAD,EAAwBJ,KAAxB,CAAP;AACA;;AApCA,GAFF;AAwCA,CA5CgD,EA6CjD,iBA7CiD,CAAlD;AAgDA,eAAeJ,eAAf","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"]}
@@ -25,6 +25,7 @@ import createHigherOrderComponent from '../../utils/create-higher-order-componen
25
25
  export default function withState() {
26
26
  let initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
27
27
  deprecated('wp.compose.withState', {
28
+ since: '5.8',
28
29
  alternative: 'wp.element.useState'
29
30
  });
30
31
  return createHigherOrderComponent(OriginalComponent => {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/with-state/index.js"],"names":["Component","deprecated","createHigherOrderComponent","withState","initialState","alternative","OriginalComponent","WrappedComponent","constructor","props","setState","bind","state","render"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,0BAAP,MAAuC,2CAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,SAAT,GAAwC;AAAA,MAApBC,YAAoB,uEAAL,EAAK;AACtDH,EAAAA,UAAU,CAAE,sBAAF,EAA0B;AACnCI,IAAAA,WAAW,EAAE;AADsB,GAA1B,CAAV;AAIA,SAAOH,0BAA0B,CAAII,iBAAF,IAAyB;AAC3D,WAAO,MAAMC,gBAAN,SAA+BP,SAA/B,CAAyC;AAC/CQ,MAAAA,WAAW;AAAE;AAAmBC,MAAAA,KAArB,EAA6B;AACvC,cAAOA,KAAP;AAEA,aAAKC,QAAL,GAAgB,KAAKA,QAAL,CAAcC,IAAd,CAAoB,IAApB,CAAhB;AAEA,aAAKC,KAAL,GAAaR,YAAb;AACA;;AAEDS,MAAAA,MAAM,GAAG;AACR,eACC,cAAC,iBAAD,eACM,KAAKJ,KADX,EAEM,KAAKG,KAFX;AAGC,UAAA,QAAQ,EAAG,KAAKF;AAHjB,WADD;AAOA;;AAjB8C,KAAhD;AAmBA,GApBgC,EAoB9B,WApB8B,CAAjC;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\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":["Component","deprecated","createHigherOrderComponent","withState","initialState","since","alternative","OriginalComponent","WrappedComponent","constructor","props","setState","bind","state","render"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,0BAAP,MAAuC,2CAAvC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,SAAT,GAAwC;AAAA,MAApBC,YAAoB,uEAAL,EAAK;AACtDH,EAAAA,UAAU,CAAE,sBAAF,EAA0B;AACnCI,IAAAA,KAAK,EAAE,KAD4B;AAEnCC,IAAAA,WAAW,EAAE;AAFsB,GAA1B,CAAV;AAKA,SAAOJ,0BAA0B,CAAIK,iBAAF,IAAyB;AAC3D,WAAO,MAAMC,gBAAN,SAA+BR,SAA/B,CAAyC;AAC/CS,MAAAA,WAAW;AAAE;AAAmBC,MAAAA,KAArB,EAA6B;AACvC,cAAOA,KAAP;AAEA,aAAKC,QAAL,GAAgB,KAAKA,QAAL,CAAcC,IAAd,CAAoB,IAApB,CAAhB;AAEA,aAAKC,KAAL,GAAaT,YAAb;AACA;;AAEDU,MAAAA,MAAM,GAAG;AACR,eACC,cAAC,iBAAD,eACM,KAAKJ,KADX,EAEM,KAAKG,KAFX;AAGC,UAAA,QAAQ,EAAG,KAAKF;AAHjB,WADD;AAOA;;AAjB8C,KAAhD;AAmBA,GApBgC,EAoB9B,WApB8B,CAAjC;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"]}
@@ -29,8 +29,7 @@ export default function useCopyOnClick(ref, text) {
29
29
 
30
30
  /* eslint-enable jsdoc/no-undefined-types */
31
31
  deprecated('wp.compose.useCopyOnClick', {
32
- since: '10.3',
33
- plugin: 'Gutenberg',
32
+ since: '5.8',
34
33
  alternative: 'wp.compose.useCopyToClipboard'
35
34
  });
36
35
  /** @type {import('react').MutableRefObject<Clipboard | undefined>} */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-copy-on-click/index.js"],"names":["Clipboard","useRef","useEffect","useState","deprecated","useCopyOnClick","ref","text","timeout","since","plugin","alternative","clipboard","hasCopied","setHasCopied","timeoutId","current","on","clearSelection","trigger","focus","clearTimeout","setTimeout","destroy"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAP,MAAsB,WAAtB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,SAAjB,EAA4BC,QAA5B,QAA4C,oBAA5C;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,cAAT,CAAyBC,GAAzB,EAA8BC,IAA9B,EAAqD;AAAA,MAAjBC,OAAiB,uEAAP,IAAO;;AACnE;AACAJ,EAAAA,UAAU,CAAE,2BAAF,EAA+B;AACxCK,IAAAA,KAAK,EAAE,MADiC;AAExCC,IAAAA,MAAM,EAAE,WAFgC;AAGxCC,IAAAA,WAAW,EAAE;AAH2B,GAA/B,CAAV;AAMA;;AACA,QAAMC,SAAS,GAAGX,MAAM,EAAxB;AACA,QAAM,CAAEY,SAAF,EAAaC,YAAb,IAA8BX,QAAQ,CAAE,KAAF,CAA5C;AAEAD,EAAAA,SAAS,CAAE,MAAM;AAChB;AACA,QAAIa,SAAJ;;AAEA,QAAK,CAAET,GAAG,CAACU,OAAX,EAAqB;AACpB;AACA,KANe,CAQhB;;;AACAJ,IAAAA,SAAS,CAACI,OAAV,GAAoB,IAAIhB,SAAJ,CAAeM,GAAG,CAACU,OAAnB,EAA4B;AAC/CT,MAAAA,IAAI,EAAE,MAAQ,OAAOA,IAAP,KAAgB,UAAhB,GAA6BA,IAAI,EAAjC,GAAsCA;AADL,KAA5B,CAApB;AAIAK,IAAAA,SAAS,CAACI,OAAV,CAAkBC,EAAlB,CAAsB,SAAtB,EAAiC,QAAmC;AAAA,UAAjC;AAAEC,QAAAA,cAAF;AAAkBC,QAAAA;AAAlB,OAAiC;AACnE;AACA;AACA;AACAD,MAAAA,cAAc,GAJqD,CAMnE;;AACA,UAAKC,OAAL,EAAe;AACd;AAA6BA,QAAAA,OAAF,CAAYC,KAAZ;AAC3B;;AAED,UAAKZ,OAAL,EAAe;AACdM,QAAAA,YAAY,CAAE,IAAF,CAAZ;AACAO,QAAAA,YAAY,CAAEN,SAAF,CAAZ;AACAA,QAAAA,SAAS,GAAGO,UAAU,CAAE,MAAMR,YAAY,CAAE,KAAF,CAApB,EAA+BN,OAA/B,CAAtB;AACA;AACD,KAhBD;AAkBA,WAAO,MAAM;AACZ,UAAKI,SAAS,CAACI,OAAf,EAAyB;AACxBJ,QAAAA,SAAS,CAACI,OAAV,CAAkBO,OAAlB;AACA;;AACDF,MAAAA,YAAY,CAAEN,SAAF,CAAZ;AACA,KALD;AAMA,GArCQ,EAqCN,CAAER,IAAF,EAAQC,OAAR,EAAiBM,YAAjB,CArCM,CAAT;AAuCA,SAAOD,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport Clipboard from 'clipboard';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/* eslint-disable jsdoc/no-undefined-types */\n/**\n * Copies the text to the clipboard when the element is clicked.\n *\n * @deprecated\n *\n * @param {import('react').RefObject<string | Element | NodeListOf<Element>>} ref Reference with the element.\n * @param {string|Function} text The text to copy.\n * @param {number} [timeout] Optional timeout to reset the returned\n * state. 4 seconds by default.\n *\n * @return {boolean} Whether or not the text has been copied. Resets after the\n * timeout.\n */\nexport default function useCopyOnClick( ref, text, timeout = 4000 ) {\n\t/* eslint-enable jsdoc/no-undefined-types */\n\tdeprecated( 'wp.compose.useCopyOnClick', {\n\t\tsince: '10.3',\n\t\tplugin: 'Gutenberg',\n\t\talternative: 'wp.compose.useCopyToClipboard',\n\t} );\n\n\t/** @type {import('react').MutableRefObject<Clipboard | undefined>} */\n\tconst clipboard = useRef();\n\tconst [ hasCopied, setHasCopied ] = useState( false );\n\n\tuseEffect( () => {\n\t\t/** @type {number | undefined} */\n\t\tlet timeoutId;\n\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Clipboard listens to click events.\n\t\tclipboard.current = new Clipboard( ref.current, {\n\t\t\ttext: () => ( typeof text === 'function' ? text() : text ),\n\t\t} );\n\n\t\tclipboard.current.on( 'success', ( { clearSelection, trigger } ) => {\n\t\t\t// Clearing selection will move focus back to the triggering button,\n\t\t\t// ensuring that it is not reset to the body, and further that it is\n\t\t\t// kept within the rendered node.\n\t\t\tclearSelection();\n\n\t\t\t// Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680\n\t\t\tif ( trigger ) {\n\t\t\t\t/** @type {HTMLElement} */ ( trigger ).focus();\n\t\t\t}\n\n\t\t\tif ( timeout ) {\n\t\t\t\tsetHasCopied( true );\n\t\t\t\tclearTimeout( timeoutId );\n\t\t\t\ttimeoutId = setTimeout( () => setHasCopied( false ), timeout );\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tif ( clipboard.current ) {\n\t\t\t\tclipboard.current.destroy();\n\t\t\t}\n\t\t\tclearTimeout( timeoutId );\n\t\t};\n\t}, [ text, timeout, setHasCopied ] );\n\n\treturn hasCopied;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-copy-on-click/index.js"],"names":["Clipboard","useRef","useEffect","useState","deprecated","useCopyOnClick","ref","text","timeout","since","alternative","clipboard","hasCopied","setHasCopied","timeoutId","current","on","clearSelection","trigger","focus","clearTimeout","setTimeout","destroy"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAP,MAAsB,WAAtB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,SAAjB,EAA4BC,QAA5B,QAA4C,oBAA5C;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,cAAT,CAAyBC,GAAzB,EAA8BC,IAA9B,EAAqD;AAAA,MAAjBC,OAAiB,uEAAP,IAAO;;AACnE;AACAJ,EAAAA,UAAU,CAAE,2BAAF,EAA+B;AACxCK,IAAAA,KAAK,EAAE,KADiC;AAExCC,IAAAA,WAAW,EAAE;AAF2B,GAA/B,CAAV;AAKA;;AACA,QAAMC,SAAS,GAAGV,MAAM,EAAxB;AACA,QAAM,CAAEW,SAAF,EAAaC,YAAb,IAA8BV,QAAQ,CAAE,KAAF,CAA5C;AAEAD,EAAAA,SAAS,CAAE,MAAM;AAChB;AACA,QAAIY,SAAJ;;AAEA,QAAK,CAAER,GAAG,CAACS,OAAX,EAAqB;AACpB;AACA,KANe,CAQhB;;;AACAJ,IAAAA,SAAS,CAACI,OAAV,GAAoB,IAAIf,SAAJ,CAAeM,GAAG,CAACS,OAAnB,EAA4B;AAC/CR,MAAAA,IAAI,EAAE,MAAQ,OAAOA,IAAP,KAAgB,UAAhB,GAA6BA,IAAI,EAAjC,GAAsCA;AADL,KAA5B,CAApB;AAIAI,IAAAA,SAAS,CAACI,OAAV,CAAkBC,EAAlB,CAAsB,SAAtB,EAAiC,QAAmC;AAAA,UAAjC;AAAEC,QAAAA,cAAF;AAAkBC,QAAAA;AAAlB,OAAiC;AACnE;AACA;AACA;AACAD,MAAAA,cAAc,GAJqD,CAMnE;;AACA,UAAKC,OAAL,EAAe;AACd;AAA6BA,QAAAA,OAAF,CAAYC,KAAZ;AAC3B;;AAED,UAAKX,OAAL,EAAe;AACdK,QAAAA,YAAY,CAAE,IAAF,CAAZ;AACAO,QAAAA,YAAY,CAAEN,SAAF,CAAZ;AACAA,QAAAA,SAAS,GAAGO,UAAU,CAAE,MAAMR,YAAY,CAAE,KAAF,CAApB,EAA+BL,OAA/B,CAAtB;AACA;AACD,KAhBD;AAkBA,WAAO,MAAM;AACZ,UAAKG,SAAS,CAACI,OAAf,EAAyB;AACxBJ,QAAAA,SAAS,CAACI,OAAV,CAAkBO,OAAlB;AACA;;AACDF,MAAAA,YAAY,CAAEN,SAAF,CAAZ;AACA,KALD;AAMA,GArCQ,EAqCN,CAAEP,IAAF,EAAQC,OAAR,EAAiBK,YAAjB,CArCM,CAAT;AAuCA,SAAOD,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport Clipboard from 'clipboard';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect, useState } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/* eslint-disable jsdoc/no-undefined-types */\n/**\n * Copies the text to the clipboard when the element is clicked.\n *\n * @deprecated\n *\n * @param {import('react').RefObject<string | Element | NodeListOf<Element>>} ref Reference with the element.\n * @param {string|Function} text The text to copy.\n * @param {number} [timeout] Optional timeout to reset the returned\n * state. 4 seconds by default.\n *\n * @return {boolean} Whether or not the text has been copied. Resets after the\n * timeout.\n */\nexport default function useCopyOnClick( ref, text, timeout = 4000 ) {\n\t/* eslint-enable jsdoc/no-undefined-types */\n\tdeprecated( 'wp.compose.useCopyOnClick', {\n\t\tsince: '5.8',\n\t\talternative: 'wp.compose.useCopyToClipboard',\n\t} );\n\n\t/** @type {import('react').MutableRefObject<Clipboard | undefined>} */\n\tconst clipboard = useRef();\n\tconst [ hasCopied, setHasCopied ] = useState( false );\n\n\tuseEffect( () => {\n\t\t/** @type {number | undefined} */\n\t\tlet timeoutId;\n\n\t\tif ( ! ref.current ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Clipboard listens to click events.\n\t\tclipboard.current = new Clipboard( ref.current, {\n\t\t\ttext: () => ( typeof text === 'function' ? text() : text ),\n\t\t} );\n\n\t\tclipboard.current.on( 'success', ( { clearSelection, trigger } ) => {\n\t\t\t// Clearing selection will move focus back to the triggering button,\n\t\t\t// ensuring that it is not reset to the body, and further that it is\n\t\t\t// kept within the rendered node.\n\t\t\tclearSelection();\n\n\t\t\t// Handle ClipboardJS focus bug, see https://github.com/zenorocha/clipboard.js/issues/680\n\t\t\tif ( trigger ) {\n\t\t\t\t/** @type {HTMLElement} */ ( trigger ).focus();\n\t\t\t}\n\n\t\t\tif ( timeout ) {\n\t\t\t\tsetHasCopied( true );\n\t\t\t\tclearTimeout( timeoutId );\n\t\t\t\ttimeoutId = setTimeout( () => setHasCopied( false ), timeout );\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tif ( clipboard.current ) {\n\t\t\t\tclipboard.current.destroy();\n\t\t\t}\n\t\t\tclearTimeout( timeoutId );\n\t\t};\n\t}, [ text, timeout, setHasCopied ] );\n\n\treturn hasCopied;\n}\n"]}
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- // eslint-disable-next-line no-restricted-imports
5
4
 
6
5
  /**
7
6
  * WordPress dependencies