@wordpress/compose 5.8.0 → 5.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +2 -2
  3. package/build/higher-order/if-condition/index.js +14 -10
  4. package/build/higher-order/if-condition/index.js.map +1 -1
  5. package/build/higher-order/pure/index.js +9 -5
  6. package/build/higher-order/pure/index.js.map +1 -1
  7. package/build/higher-order/with-global-events/index.js +2 -2
  8. package/build/higher-order/with-global-events/index.js.map +1 -1
  9. package/build/higher-order/with-instance-id/index.js +3 -3
  10. package/build/higher-order/with-instance-id/index.js.map +1 -1
  11. package/build/higher-order/with-preferred-color-scheme/index.native.js +2 -2
  12. package/build/higher-order/with-preferred-color-scheme/index.native.js.map +1 -1
  13. package/build/higher-order/with-safe-timeout/index.js +10 -7
  14. package/build/higher-order/with-safe-timeout/index.js.map +1 -1
  15. package/build/higher-order/with-state/index.js +2 -2
  16. package/build/higher-order/with-state/index.js.map +1 -1
  17. package/build/hooks/use-debounce/index.js.map +1 -1
  18. package/build/hooks/use-dialog/index.js +3 -3
  19. package/build/hooks/use-dialog/index.js.map +1 -1
  20. package/build/hooks/use-disabled/index.js.map +1 -1
  21. package/build/hooks/use-focus-return/index.js.map +1 -1
  22. package/build/hooks/use-keyboard-shortcut/index.js.map +1 -1
  23. package/build/hooks/use-merge-refs/index.js.map +1 -1
  24. package/build/hooks/use-throttle/index.js.map +1 -1
  25. package/build/index.js +48 -7
  26. package/build/index.js.map +1 -1
  27. package/build/index.native.js +40 -7
  28. package/build/index.native.js.map +1 -1
  29. package/build/utils/create-higher-order-component/index.js +19 -5
  30. package/build/utils/create-higher-order-component/index.js.map +1 -1
  31. package/build-module/higher-order/if-condition/index.js +13 -7
  32. package/build-module/higher-order/if-condition/index.js.map +1 -1
  33. package/build-module/higher-order/pure/index.js +10 -9
  34. package/build-module/higher-order/pure/index.js.map +1 -1
  35. package/build-module/higher-order/with-global-events/index.js +1 -1
  36. package/build-module/higher-order/with-global-events/index.js.map +1 -1
  37. package/build-module/higher-order/with-instance-id/index.js +3 -3
  38. package/build-module/higher-order/with-instance-id/index.js.map +1 -1
  39. package/build-module/higher-order/with-preferred-color-scheme/index.native.js +1 -1
  40. package/build-module/higher-order/with-preferred-color-scheme/index.native.js.map +1 -1
  41. package/build-module/higher-order/with-safe-timeout/index.js +9 -7
  42. package/build-module/higher-order/with-safe-timeout/index.js.map +1 -1
  43. package/build-module/higher-order/with-state/index.js +1 -1
  44. package/build-module/higher-order/with-state/index.js.map +1 -1
  45. package/build-module/hooks/use-debounce/index.js.map +1 -1
  46. package/build-module/hooks/use-dialog/index.js +3 -3
  47. package/build-module/hooks/use-dialog/index.js.map +1 -1
  48. package/build-module/hooks/use-disabled/index.js.map +1 -1
  49. package/build-module/hooks/use-focus-return/index.js.map +1 -1
  50. package/build-module/hooks/use-keyboard-shortcut/index.js.map +1 -1
  51. package/build-module/hooks/use-merge-refs/index.js.map +1 -1
  52. package/build-module/hooks/use-throttle/index.js.map +1 -1
  53. package/build-module/index.js +2 -2
  54. package/build-module/index.js.map +1 -1
  55. package/build-module/index.native.js +2 -2
  56. package/build-module/index.native.js.map +1 -1
  57. package/build-module/utils/create-higher-order-component/index.js +18 -4
  58. package/build-module/utils/create-higher-order-component/index.js.map +1 -1
  59. package/build-types/higher-order/if-condition/index.d.ts +5 -1
  60. package/build-types/higher-order/if-condition/index.d.ts.map +1 -1
  61. package/build-types/higher-order/pure/index.d.ts +1 -1
  62. package/build-types/higher-order/pure/index.d.ts.map +1 -1
  63. package/build-types/higher-order/with-global-events/index.d.ts.map +1 -1
  64. package/build-types/higher-order/with-instance-id/index.d.ts +8 -3
  65. package/build-types/higher-order/with-instance-id/index.d.ts.map +1 -1
  66. package/build-types/higher-order/with-safe-timeout/index.d.ts +37 -4
  67. package/build-types/higher-order/with-safe-timeout/index.d.ts.map +1 -1
  68. package/build-types/hooks/use-debounce/index.d.ts.map +1 -1
  69. package/build-types/hooks/use-dialog/index.d.ts +5 -1
  70. package/build-types/hooks/use-dialog/index.d.ts.map +1 -1
  71. package/build-types/hooks/use-disabled/index.d.ts.map +1 -1
  72. package/build-types/hooks/use-focus-return/index.d.ts.map +1 -1
  73. package/build-types/hooks/use-merge-refs/index.d.ts.map +1 -1
  74. package/build-types/hooks/use-throttle/index.d.ts.map +1 -1
  75. package/build-types/index.d.ts +1 -1
  76. package/build-types/utils/create-higher-order-component/index.d.ts +5 -12
  77. package/build-types/utils/create-higher-order-component/index.d.ts.map +1 -1
  78. package/package.json +8 -8
  79. package/src/higher-order/if-condition/index.tsx +11 -7
  80. package/src/higher-order/pure/index.tsx +29 -31
  81. package/src/higher-order/with-global-events/index.js +4 -2
  82. package/src/higher-order/with-global-events/test/index.js +2 -2
  83. package/src/higher-order/with-instance-id/index.tsx +19 -10
  84. package/src/higher-order/with-preferred-color-scheme/index.native.js +1 -1
  85. package/src/higher-order/with-safe-timeout/index.tsx +22 -19
  86. package/src/higher-order/with-state/index.js +1 -1
  87. package/src/hooks/use-debounce/index.js +4 -5
  88. package/src/hooks/use-dialog/index.js +16 -14
  89. package/src/hooks/use-disabled/index.js +8 -9
  90. package/src/hooks/use-focus-return/index.js +3 -1
  91. package/src/hooks/use-keyboard-shortcut/index.js +1 -1
  92. package/src/hooks/use-merge-refs/index.js +2 -1
  93. package/src/hooks/use-throttle/index.js +4 -5
  94. package/src/index.js +2 -2
  95. package/src/index.native.js +2 -2
  96. package/src/utils/create-higher-order-component/index.ts +30 -27
  97. package/src/utils/create-higher-order-component/test/index.js +1 -1
  98. package/tsconfig.tsbuildinfo +1 -1
package/build/index.js CHANGED
@@ -5,6 +5,41 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ var _exportNames = {
9
+ compose: true,
10
+ ifCondition: true,
11
+ pure: true,
12
+ withGlobalEvents: true,
13
+ withInstanceId: true,
14
+ withSafeTimeout: true,
15
+ withState: true,
16
+ useConstrainedTabbing: true,
17
+ useCopyOnClick: true,
18
+ useCopyToClipboard: true,
19
+ __experimentalUseDialog: true,
20
+ useDisabled: true,
21
+ __experimentalUseDragging: true,
22
+ useFocusOnMount: true,
23
+ __experimentalUseFocusOutside: true,
24
+ useFocusReturn: true,
25
+ useInstanceId: true,
26
+ useIsomorphicLayoutEffect: true,
27
+ useKeyboardShortcut: true,
28
+ useMediaQuery: true,
29
+ usePrevious: true,
30
+ useReducedMotion: true,
31
+ useViewportMatch: true,
32
+ useResizeObserver: true,
33
+ useAsyncList: true,
34
+ useWarnOnChange: true,
35
+ useDebounce: true,
36
+ useThrottle: true,
37
+ useMergeRefs: true,
38
+ useRefEffect: true,
39
+ __experimentalUseDropZone: true,
40
+ useFocusableIframe: true,
41
+ __experimentalUseFixedWindowList: true
42
+ };
8
43
  Object.defineProperty(exports, "__experimentalUseDialog", {
9
44
  enumerable: true,
10
45
  get: function () {
@@ -41,12 +76,6 @@ Object.defineProperty(exports, "compose", {
41
76
  return _compose.default;
42
77
  }
43
78
  });
44
- Object.defineProperty(exports, "createHigherOrderComponent", {
45
- enumerable: true,
46
- get: function () {
47
- return _createHigherOrderComponent.default;
48
- }
49
- });
50
79
  Object.defineProperty(exports, "ifCondition", {
51
80
  enumerable: true,
52
81
  get: function () {
@@ -210,7 +239,19 @@ Object.defineProperty(exports, "withState", {
210
239
  }
211
240
  });
212
241
 
213
- var _createHigherOrderComponent = _interopRequireDefault(require("./utils/create-higher-order-component"));
242
+ var _createHigherOrderComponent = require("./utils/create-higher-order-component");
243
+
244
+ Object.keys(_createHigherOrderComponent).forEach(function (key) {
245
+ if (key === "default" || key === "__esModule") return;
246
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
247
+ if (key in exports && exports[key] === _createHigherOrderComponent[key]) return;
248
+ Object.defineProperty(exports, key, {
249
+ enumerable: true,
250
+ get: function () {
251
+ return _createHigherOrderComponent[key];
252
+ }
253
+ });
254
+ });
214
255
 
215
256
  var _compose = _interopRequireDefault(require("./higher-order/compose"));
216
257
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAGA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["// Utils.\nexport { default as createHigherOrderComponent } from './utils/create-higher-order-component';\n\n// Compose helper (aliased flowRight from Lodash)\nexport { default as compose } from './higher-order/compose';\n\n// Higher-order components.\nexport { default as ifCondition } from './higher-order/if-condition';\nexport { default as pure } from './higher-order/pure';\nexport { default as withGlobalEvents } from './higher-order/with-global-events';\nexport { default as withInstanceId } from './higher-order/with-instance-id';\nexport { default as withSafeTimeout } from './higher-order/with-safe-timeout';\nexport { default as withState } from './higher-order/with-state';\n\n// Hooks.\nexport { default as useConstrainedTabbing } from './hooks/use-constrained-tabbing';\nexport { default as useCopyOnClick } from './hooks/use-copy-on-click';\nexport { default as useCopyToClipboard } from './hooks/use-copy-to-clipboard';\nexport { default as __experimentalUseDialog } from './hooks/use-dialog';\nexport { default as useDisabled } from './hooks/use-disabled';\nexport { default as __experimentalUseDragging } from './hooks/use-dragging';\nexport { default as useFocusOnMount } from './hooks/use-focus-on-mount';\nexport { default as __experimentalUseFocusOutside } from './hooks/use-focus-outside';\nexport { default as useFocusReturn } from './hooks/use-focus-return';\nexport { default as useInstanceId } from './hooks/use-instance-id';\nexport { default as useIsomorphicLayoutEffect } from './hooks/use-isomorphic-layout-effect';\nexport { default as useKeyboardShortcut } from './hooks/use-keyboard-shortcut';\nexport { default as useMediaQuery } from './hooks/use-media-query';\nexport { default as usePrevious } from './hooks/use-previous';\nexport { default as useReducedMotion } from './hooks/use-reduced-motion';\nexport { default as useViewportMatch } from './hooks/use-viewport-match';\nexport { default as useResizeObserver } from './hooks/use-resize-observer';\nexport { default as useAsyncList } from './hooks/use-async-list';\nexport { default as useWarnOnChange } from './hooks/use-warn-on-change';\nexport { default as useDebounce } from './hooks/use-debounce';\nexport { default as useThrottle } from './hooks/use-throttle';\nexport { default as useMergeRefs } from './hooks/use-merge-refs';\nexport { default as useRefEffect } from './hooks/use-ref-effect';\nexport { default as __experimentalUseDropZone } from './hooks/use-drop-zone';\nexport { default as useFocusableIframe } from './hooks/use-focusable-iframe';\nexport { default as __experimentalUseFixedWindowList } from './hooks/use-fixed-window-list';\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/index.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["// The `createHigherOrderComponent` helper and helper types.\nexport * from './utils/create-higher-order-component';\n\n// Compose helper (aliased flowRight from Lodash)\nexport { default as compose } from './higher-order/compose';\n\n// Higher-order components.\nexport { default as ifCondition } from './higher-order/if-condition';\nexport { default as pure } from './higher-order/pure';\nexport { default as withGlobalEvents } from './higher-order/with-global-events';\nexport { default as withInstanceId } from './higher-order/with-instance-id';\nexport { default as withSafeTimeout } from './higher-order/with-safe-timeout';\nexport { default as withState } from './higher-order/with-state';\n\n// Hooks.\nexport { default as useConstrainedTabbing } from './hooks/use-constrained-tabbing';\nexport { default as useCopyOnClick } from './hooks/use-copy-on-click';\nexport { default as useCopyToClipboard } from './hooks/use-copy-to-clipboard';\nexport { default as __experimentalUseDialog } from './hooks/use-dialog';\nexport { default as useDisabled } from './hooks/use-disabled';\nexport { default as __experimentalUseDragging } from './hooks/use-dragging';\nexport { default as useFocusOnMount } from './hooks/use-focus-on-mount';\nexport { default as __experimentalUseFocusOutside } from './hooks/use-focus-outside';\nexport { default as useFocusReturn } from './hooks/use-focus-return';\nexport { default as useInstanceId } from './hooks/use-instance-id';\nexport { default as useIsomorphicLayoutEffect } from './hooks/use-isomorphic-layout-effect';\nexport { default as useKeyboardShortcut } from './hooks/use-keyboard-shortcut';\nexport { default as useMediaQuery } from './hooks/use-media-query';\nexport { default as usePrevious } from './hooks/use-previous';\nexport { default as useReducedMotion } from './hooks/use-reduced-motion';\nexport { default as useViewportMatch } from './hooks/use-viewport-match';\nexport { default as useResizeObserver } from './hooks/use-resize-observer';\nexport { default as useAsyncList } from './hooks/use-async-list';\nexport { default as useWarnOnChange } from './hooks/use-warn-on-change';\nexport { default as useDebounce } from './hooks/use-debounce';\nexport { default as useThrottle } from './hooks/use-throttle';\nexport { default as useMergeRefs } from './hooks/use-merge-refs';\nexport { default as useRefEffect } from './hooks/use-ref-effect';\nexport { default as __experimentalUseDropZone } from './hooks/use-drop-zone';\nexport { default as useFocusableIframe } from './hooks/use-focusable-iframe';\nexport { default as __experimentalUseFixedWindowList } from './hooks/use-fixed-window-list';\n"]}
@@ -5,6 +5,33 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
+ var _exportNames = {
9
+ compose: true,
10
+ ifCondition: true,
11
+ pure: true,
12
+ withGlobalEvents: true,
13
+ withInstanceId: true,
14
+ withSafeTimeout: true,
15
+ withState: true,
16
+ withPreferredColorScheme: true,
17
+ useConstrainedTabbing: true,
18
+ __experimentalUseDragging: true,
19
+ __experimentalUseFocusOutside: true,
20
+ useInstanceId: true,
21
+ useIsomorphicLayoutEffect: true,
22
+ useKeyboardShortcut: true,
23
+ useMediaQuery: true,
24
+ usePrevious: true,
25
+ useReducedMotion: true,
26
+ useViewportMatch: true,
27
+ useAsyncList: true,
28
+ usePreferredColorScheme: true,
29
+ usePreferredColorSchemeStyle: true,
30
+ useResizeObserver: true,
31
+ useDebounce: true,
32
+ useThrottle: true,
33
+ useMergeRefs: true
34
+ };
8
35
  Object.defineProperty(exports, "__experimentalUseDragging", {
9
36
  enumerable: true,
10
37
  get: function () {
@@ -23,12 +50,6 @@ Object.defineProperty(exports, "compose", {
23
50
  return _compose.default;
24
51
  }
25
52
  });
26
- Object.defineProperty(exports, "createHigherOrderComponent", {
27
- enumerable: true,
28
- get: function () {
29
- return _createHigherOrderComponent.default;
30
- }
31
- });
32
53
  Object.defineProperty(exports, "ifCondition", {
33
54
  enumerable: true,
34
55
  get: function () {
@@ -162,7 +183,19 @@ Object.defineProperty(exports, "withState", {
162
183
  }
163
184
  });
164
185
 
165
- var _createHigherOrderComponent = _interopRequireDefault(require("./utils/create-higher-order-component"));
186
+ var _createHigherOrderComponent = require("./utils/create-higher-order-component");
187
+
188
+ Object.keys(_createHigherOrderComponent).forEach(function (key) {
189
+ if (key === "default" || key === "__esModule") return;
190
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
191
+ if (key in exports && exports[key] === _createHigherOrderComponent[key]) return;
192
+ Object.defineProperty(exports, key, {
193
+ enumerable: true,
194
+ get: function () {
195
+ return _createHigherOrderComponent[key];
196
+ }
197
+ });
198
+ });
166
199
 
167
200
  var _compose = _interopRequireDefault(require("./higher-order/compose"));
168
201
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/index.native.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAGA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["// Utils.\nexport { default as createHigherOrderComponent } from './utils/create-higher-order-component';\n\n// Compose helper (aliased flowRight from Lodash)\nexport { default as compose } from './higher-order/compose';\n\n// Higher-order components.\nexport { default as ifCondition } from './higher-order/if-condition';\nexport { default as pure } from './higher-order/pure';\nexport { default as withGlobalEvents } from './higher-order/with-global-events';\nexport { default as withInstanceId } from './higher-order/with-instance-id';\nexport { default as withSafeTimeout } from './higher-order/with-safe-timeout';\nexport { default as withState } from './higher-order/with-state';\nexport { default as withPreferredColorScheme } from './higher-order/with-preferred-color-scheme';\n\n// Hooks.\nexport { default as useConstrainedTabbing } from './hooks/use-constrained-tabbing';\nexport { default as __experimentalUseDragging } from './hooks/use-dragging';\nexport { default as __experimentalUseFocusOutside } from './hooks/use-focus-outside';\nexport { default as useInstanceId } from './hooks/use-instance-id';\nexport { default as useIsomorphicLayoutEffect } from './hooks/use-isomorphic-layout-effect';\nexport { default as useKeyboardShortcut } from './hooks/use-keyboard-shortcut';\nexport { default as useMediaQuery } from './hooks/use-media-query';\nexport { default as usePrevious } from './hooks/use-previous';\nexport { default as useReducedMotion } from './hooks/use-reduced-motion';\nexport { default as useViewportMatch } from './hooks/use-viewport-match';\nexport { default as useAsyncList } from './hooks/use-async-list';\nexport { default as usePreferredColorScheme } from './hooks/use-preferred-color-scheme';\nexport { default as usePreferredColorSchemeStyle } from './hooks/use-preferred-color-scheme-style';\nexport { default as useResizeObserver } from './hooks/use-resize-observer';\nexport { default as useDebounce } from './hooks/use-debounce';\nexport { default as useThrottle } from './hooks/use-throttle';\nexport { default as useMergeRefs } from './hooks/use-merge-refs';\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/index.native.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAGA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA","sourcesContent":["// The `createHigherOrderComponent` helper and helper types.\nexport * from './utils/create-higher-order-component';\n\n// Compose helper (aliased flowRight from Lodash)\nexport { default as compose } from './higher-order/compose';\n\n// Higher-order components.\nexport { default as ifCondition } from './higher-order/if-condition';\nexport { default as pure } from './higher-order/pure';\nexport { default as withGlobalEvents } from './higher-order/with-global-events';\nexport { default as withInstanceId } from './higher-order/with-instance-id';\nexport { default as withSafeTimeout } from './higher-order/with-safe-timeout';\nexport { default as withState } from './higher-order/with-state';\nexport { default as withPreferredColorScheme } from './higher-order/with-preferred-color-scheme';\n\n// Hooks.\nexport { default as useConstrainedTabbing } from './hooks/use-constrained-tabbing';\nexport { default as __experimentalUseDragging } from './hooks/use-dragging';\nexport { default as __experimentalUseFocusOutside } from './hooks/use-focus-outside';\nexport { default as useInstanceId } from './hooks/use-instance-id';\nexport { default as useIsomorphicLayoutEffect } from './hooks/use-isomorphic-layout-effect';\nexport { default as useKeyboardShortcut } from './hooks/use-keyboard-shortcut';\nexport { default as useMediaQuery } from './hooks/use-media-query';\nexport { default as usePrevious } from './hooks/use-previous';\nexport { default as useReducedMotion } from './hooks/use-reduced-motion';\nexport { default as useViewportMatch } from './hooks/use-viewport-match';\nexport { default as useAsyncList } from './hooks/use-async-list';\nexport { default as usePreferredColorScheme } from './hooks/use-preferred-color-scheme';\nexport { default as usePreferredColorSchemeStyle } from './hooks/use-preferred-color-scheme-style';\nexport { default as useResizeObserver } from './hooks/use-resize-observer';\nexport { default as useDebounce } from './hooks/use-debounce';\nexport { default as useThrottle } from './hooks/use-throttle';\nexport { default as useMergeRefs } from './hooks/use-merge-refs';\n"]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.createHigherOrderComponent = createHigherOrderComponent;
7
7
 
8
8
  var _lodash = require("lodash");
9
9
 
@@ -23,12 +23,26 @@ var _lodash = require("lodash");
23
23
  function createHigherOrderComponent(mapComponent, modifierName) {
24
24
  return Inner => {
25
25
  const Outer = mapComponent(Inner);
26
- const displayName = Inner.displayName || Inner.name || 'Component';
27
- Outer.displayName = `${(0, _lodash.upperFirst)((0, _lodash.camelCase)(modifierName))}(${displayName})`;
26
+ Outer.displayName = hocName(modifierName, Inner);
28
27
  return Outer;
29
28
  };
30
29
  }
30
+ /**
31
+ * Returns a displayName for a higher-order component, given a wrapper name.
32
+ *
33
+ * @example
34
+ * hocName( 'MyMemo', Widget ) === 'MyMemo(Widget)';
35
+ * hocName( 'MyMemo', <div /> ) === 'MyMemo(Component)';
36
+ *
37
+ * @param name Name assigned to higher-order component's wrapper component.
38
+ * @param Inner Wrapped component inside higher-order component.
39
+ * @return Wrapped name of higher-order component.
40
+ */
41
+
31
42
 
32
- var _default = createHigherOrderComponent;
33
- exports.default = _default;
43
+ const hocName = (name, Inner) => {
44
+ const inner = Inner.displayName || Inner.name || 'Component';
45
+ const outer = (0, _lodash.upperFirst)((0, _lodash.camelCase)(name));
46
+ return `${outer}(${inner})`;
47
+ };
34
48
  //# sourceMappingURL=index.js.map
@@ -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;;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"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/utils/create-higher-order-component/index.ts"],"names":["createHigherOrderComponent","mapComponent","modifierName","Inner","Outer","displayName","hocName","name","inner","outer"],"mappings":";;;;;;;AAGA;;AAHA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,0BAAT,CAGJC,YAHI,EAGuCC,YAHvC,EAG8D;AACpE,SAASC,KAAF,IAAqB;AAC3B,UAAMC,KAAK,GAAGH,YAAY,CAAEE,KAAF,CAA1B;AACAC,IAAAA,KAAK,CAACC,WAAN,GAAoBC,OAAO,CAAEJ,YAAF,EAAgBC,KAAhB,CAA3B;AACA,WAAOC,KAAP;AACA,GAJD;AAKA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAME,OAAO,GAAG,CAAEC,IAAF,EAAgBJ,KAAhB,KAAiD;AAChE,QAAMK,KAAK,GAAGL,KAAK,CAACE,WAAN,IAAqBF,KAAK,CAACI,IAA3B,IAAmC,WAAjD;AACA,QAAME,KAAK,GAAG,wBAAY,uBAAWF,IAAX,CAAZ,CAAd;AAEA,SAAQ,GAAGE,KAAO,IAAID,KAAO,GAA7B;AACA,CALD","sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase, upperFirst } from 'lodash';\nimport type { ComponentType } from 'react';\n\ntype GetProps< C > = C extends ComponentType< infer P > ? P : never;\n\nexport type WithoutInjectedProps< C, I > = Omit< GetProps< C >, keyof I >;\n\nexport type WithInjectedProps< C, I > = ComponentType<\n\tWithoutInjectedProps< C, I > & I\n>;\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 */\nexport function createHigherOrderComponent<\n\tTInner extends ComponentType< any >,\n\tTOuter extends ComponentType< any >\n>( mapComponent: ( Inner: TInner ) => TOuter, modifierName: string ) {\n\treturn ( Inner: TInner ) => {\n\t\tconst Outer = mapComponent( Inner );\n\t\tOuter.displayName = hocName( modifierName, Inner );\n\t\treturn Outer;\n\t};\n}\n\n/**\n * Returns a displayName for a higher-order component, given a wrapper name.\n *\n * @example\n * hocName( 'MyMemo', Widget ) === 'MyMemo(Widget)';\n * hocName( 'MyMemo', <div /> ) === 'MyMemo(Component)';\n *\n * @param name Name assigned to higher-order component's wrapper component.\n * @param Inner Wrapped component inside higher-order component.\n * @return Wrapped name of higher-order component.\n */\nconst hocName = ( name: string, Inner: ComponentType< any > ) => {\n\tconst inner = Inner.displayName || Inner.name || 'Component';\n\tconst outer = upperFirst( camelCase( name ) );\n\n\treturn `${ outer }(${ inner })`;\n};\n"]}
@@ -1,9 +1,13 @@
1
1
  import { createElement } from "@wordpress/element";
2
2
 
3
+ /**
4
+ * External dependencies
5
+ */
6
+
3
7
  /**
4
8
  * Internal dependencies
5
9
  */
6
- import createHigherOrderComponent from '../../utils/create-higher-order-component';
10
+ import { createHigherOrderComponent } from '../../utils/create-higher-order-component';
7
11
  /**
8
12
  * Higher-order component creator, creating a new component which renders if
9
13
  * the given condition is satisfied or with the given optional prop name.
@@ -22,13 +26,15 @@ import createHigherOrderComponent from '../../utils/create-higher-order-componen
22
26
  * @return Higher-order component.
23
27
  */
24
28
 
25
- const ifCondition = predicate => createHigherOrderComponent(WrappedComponent => props => {
26
- if (!predicate(props)) {
27
- return null;
28
- }
29
+ function ifCondition(predicate) {
30
+ return createHigherOrderComponent(WrappedComponent => props => {
31
+ if (!predicate(props)) {
32
+ return null;
33
+ }
29
34
 
30
- return createElement(WrappedComponent, props);
31
- }, 'ifCondition');
35
+ return createElement(WrappedComponent, props);
36
+ }, 'ifCondition');
37
+ }
32
38
 
33
39
  export default ifCondition;
34
40
  //# sourceMappingURL=index.js.map
@@ -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;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"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/if-condition/index.tsx"],"names":["createHigherOrderComponent","ifCondition","predicate","WrappedComponent","props"],"mappings":";;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,SAASA,0BAAT,QAA2C,2CAA3C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,WAAT,CAA+BC,SAA/B,EAAwE;AACvE,SAAOF,0BAA0B,CAC9BG,gBAAF,IAAkDC,KAAF,IAAoB;AACnE,QAAK,CAAEF,SAAS,CAAEE,KAAF,CAAhB,EAA4B;AAC3B,aAAO,IAAP;AACA;;AAED,WAAO,cAAC,gBAAD,EAAuBA,KAAvB,CAAP;AACA,GAP+B,EAQhC,aARgC,CAAjC;AAUA;;AAED,eAAeH,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ComponentType } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * Higher-order component creator, creating a new component which renders if\n * the given condition is satisfied or with the given optional prop name.\n *\n * @example\n * ```ts\n * type Props = { foo: string };\n * const Component = ( props: Props ) => <div>{ props.foo }</div>;\n * const ConditionalComponent = ifCondition( ( props: Props ) => props.foo.length !== 0 )( Component );\n * <ConditionalComponent foo=\"\" />; // => null\n * <ConditionalComponent foo=\"bar\" />; // => <div>bar</div>;\n * ```\n *\n * @param predicate Function to test condition.\n *\n * @return Higher-order component.\n */\nfunction ifCondition< Props >( predicate: ( props: Props ) => boolean ) {\n\treturn createHigherOrderComponent(\n\t\t( WrappedComponent: ComponentType< Props > ) => ( props: Props ) => {\n\t\t\tif ( ! predicate( props ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\treturn <WrappedComponent { ...props } />;\n\t\t},\n\t\t'ifCondition'\n\t);\n}\n\nexport default ifCondition;\n"]}
@@ -1,5 +1,9 @@
1
1
  import { createElement } from "@wordpress/element";
2
2
 
3
+ /**
4
+ * External dependencies
5
+ */
6
+
3
7
  /**
4
8
  * WordPress dependencies
5
9
  */
@@ -9,18 +13,15 @@ import { Component } from '@wordpress/element';
9
13
  * Internal dependencies
10
14
  */
11
15
 
12
- import createHigherOrderComponent from '../../utils/create-higher-order-component';
13
- /**
14
- * External dependencies
15
- */
16
-
16
+ import { createHigherOrderComponent } from '../../utils/create-higher-order-component';
17
17
  /**
18
18
  * Given a component returns the enhanced component augmented with a component
19
19
  * only re-rendering when its props/state change
20
20
  */
21
- const pure = createHigherOrderComponent(Wrapped => {
22
- if (Wrapped.prototype instanceof Component) {
23
- return class extends Wrapped {
21
+
22
+ const pure = createHigherOrderComponent(function (WrappedComponent) {
23
+ if (WrappedComponent.prototype instanceof Component) {
24
+ return class extends WrappedComponent {
24
25
  shouldComponentUpdate(nextProps, nextState) {
25
26
  return !isShallowEqual(nextProps, this.props) || !isShallowEqual(nextState, this.state);
26
27
  }
@@ -34,7 +35,7 @@ const pure = createHigherOrderComponent(Wrapped => {
34
35
  }
35
36
 
36
37
  render() {
37
- return createElement(Wrapped, this.props);
38
+ return createElement(WrappedComponent, this.props);
38
39
  }
39
40
 
40
41
  };
@@ -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;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"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/pure/index.tsx"],"names":["isShallowEqual","Component","createHigherOrderComponent","pure","WrappedComponent","prototype","shouldComponentUpdate","nextProps","nextState","props","state","render"],"mappings":";;AAAA;AACA;AACA;;AAGA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,6BAA3B;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,SAASC,0BAAT,QAA2C,2CAA3C;AAEA;AACA;AACA;AACA;;AACA,MAAMC,IAAI,GAAGD,0BAA0B,CAAE,UACxCE,gBADwC,EAEf;AACzB,MAAKA,gBAAgB,CAACC,SAAjB,YAAsCJ,SAA3C,EAAuD;AACtD,WAAO,cAAgBG,gBAAhB,CAA8D;AACpEE,MAAAA,qBAAqB,CAAEC,SAAF,EAAoBC,SAApB,EAAqC;AACzD,eACC,CAAER,cAAc,CAAEO,SAAF,EAAa,KAAKE,KAAlB,CAAhB,IACA,CAAET,cAAc,CAAEQ,SAAF,EAAa,KAAKE,KAAlB,CAFjB;AAIA;;AANmE,KAArE;AAQA;;AAED,SAAO,cAAcT,SAAd,CAAiC;AACvCK,IAAAA,qBAAqB,CAAEC,SAAF,EAAqB;AACzC,aAAO,CAAEP,cAAc,CAAEO,SAAF,EAAa,KAAKE,KAAlB,CAAvB;AACA;;AAEDE,IAAAA,MAAM,GAAG;AACR,aAAO,cAAC,gBAAD,EAAuB,KAAKF,KAA5B,CAAP;AACA;;AAPsC,GAAxC;AASA,CAvBsC,EAwBvC,MAxBuC,CAAvC;AA0BA,eAAeN,IAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { ComponentType, ComponentClass } from 'react';\n\n/**\n * WordPress dependencies\n */\nimport isShallowEqual from '@wordpress/is-shallow-equal';\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\n\n/**\n * Given a component returns the enhanced component augmented with a component\n * only re-rendering when its props/state change\n */\nconst pure = createHigherOrderComponent( function < Props >(\n\tWrappedComponent: ComponentType< Props >\n): ComponentType< Props > {\n\tif ( WrappedComponent.prototype instanceof Component ) {\n\t\treturn class extends ( WrappedComponent as ComponentClass< Props > ) {\n\t\t\tshouldComponentUpdate( nextProps: Props, nextState: any ) {\n\t\t\t\treturn (\n\t\t\t\t\t! isShallowEqual( nextProps, this.props ) ||\n\t\t\t\t\t! isShallowEqual( nextState, this.state )\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t}\n\n\treturn class extends Component< Props > {\n\t\tshouldComponentUpdate( nextProps: Props ) {\n\t\t\treturn ! isShallowEqual( nextProps, this.props );\n\t\t}\n\n\t\trender() {\n\t\t\treturn <WrappedComponent { ...this.props } />;\n\t\t}\n\t};\n},\n'pure' );\n\nexport default pure;\n"]}
@@ -15,7 +15,7 @@ import deprecated from '@wordpress/deprecated';
15
15
  * Internal dependencies
16
16
  */
17
17
 
18
- import createHigherOrderComponent from '../../utils/create-higher-order-component';
18
+ import { createHigherOrderComponent } from '../../utils/create-higher-order-component';
19
19
  import Listener from './listener';
20
20
  /**
21
21
  * Listener instance responsible for managing document event handling.
@@ -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,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
+ {"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,SAASC,0BAAT,QAA2C,2CAA3C;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;AACCgB,QAAAA,KAAK,CAACE;AAEP;AAJmB,SADrB;;AAOA,YAAK,OAAO,KAAKC,UAAL,CAAiBF,OAAjB,CAAP,KAAsC,UAA3C,EAAwD;AACvD,eAAKE,UAAL,CAAiBF,OAAjB,EAA4BD,KAA5B;AACA;AACD;;AAEDP,MAAAA,SAAS;AAAE;AAAmBW,MAAAA,EAArB,EAA0B;AAClC,aAAKD,UAAL,GAAkBC,EAAlB,CADkC,CAElC;AACA;AACA;;AACA,YAAK,KAAKd,KAAL,CAAWe,YAAhB,EAA+B;AAC9B,eAAKf,KAAL,CAAWe,YAAX,CAAyBD,EAAzB;AACA;AACD;;AAEDE,MAAAA,MAAM,GAAG;AACR,eACC,cAAC,gBAAD,eACM,KAAKhB,KAAL,CAAWiB,QADjB;AAEC,UAAA,GAAG,EAAG,KAAKd;AAFZ,WADD;AAMA;;AAlD8B;;AAqDhC,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,GAzDgC,EAyD9B,kBAzD8B,CAAjC;AA0DA","sourcesContent":["/**\n * External dependencies\n */\nimport { forEach } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Component, forwardRef } from '@wordpress/element';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\nimport Listener from './listener';\n\n/**\n * Listener instance responsible for managing document event handling.\n */\nconst listener = new Listener();\n\n/* eslint-disable jsdoc/no-undefined-types */\n/**\n * Higher-order component creator which, given an object of DOM event types and\n * values corresponding to a callback function name on the component, will\n * create or update a window event handler to invoke the callback when an event\n * occurs. On behalf of the consuming developer, the higher-order component\n * manages unbinding when the component unmounts, and binding at most a single\n * event handler for the entire application.\n *\n * @deprecated\n *\n * @param {Record<keyof GlobalEventHandlersEventMap, string>} eventTypesToHandlers Object with keys of DOM\n * event type, the value a\n * name of the function on\n * the original component's\n * instance which handles\n * the event.\n *\n * @return {any} Higher-order component.\n */\nexport default function withGlobalEvents( eventTypesToHandlers ) {\n\tdeprecated( 'wp.compose.withGlobalEvents', {\n\t\tsince: '5.7',\n\t\talternative: 'useEffect',\n\t} );\n\n\t// @ts-ignore We don't need to fix the type-related issues because this is deprecated.\n\treturn createHigherOrderComponent( ( WrappedComponent ) => {\n\t\tclass Wrapper extends Component {\n\t\t\tconstructor( /** @type {any} */ props ) {\n\t\t\t\tsuper( props );\n\n\t\t\t\tthis.handleEvent = this.handleEvent.bind( this );\n\t\t\t\tthis.handleRef = this.handleRef.bind( this );\n\t\t\t}\n\n\t\t\tcomponentDidMount() {\n\t\t\t\tforEach( eventTypesToHandlers, ( _, eventType ) => {\n\t\t\t\t\tlistener.add( eventType, this );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcomponentWillUnmount() {\n\t\t\t\tforEach( eventTypesToHandlers, ( _, eventType ) => {\n\t\t\t\t\tlistener.remove( eventType, this );\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\thandleEvent( /** @type {any} */ event ) {\n\t\t\t\tconst handler =\n\t\t\t\t\teventTypesToHandlers[\n\t\t\t\t\t\t/** @type {keyof GlobalEventHandlersEventMap} */ (\n\t\t\t\t\t\t\tevent.type\n\t\t\t\t\t\t)\n\t\t\t\t\t\t/* eslint-enable jsdoc/no-undefined-types */\n\t\t\t\t\t];\n\t\t\t\tif ( typeof this.wrappedRef[ handler ] === 'function' ) {\n\t\t\t\t\tthis.wrappedRef[ handler ]( event );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\thandleRef( /** @type {any} */ el ) {\n\t\t\t\tthis.wrappedRef = el;\n\t\t\t\t// Any component using `withGlobalEvents` that is not setting a `ref`\n\t\t\t\t// will cause `this.props.forwardedRef` to be `null`, so we need this\n\t\t\t\t// check.\n\t\t\t\tif ( this.props.forwardedRef ) {\n\t\t\t\t\tthis.props.forwardedRef( el );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\treturn (\n\t\t\t\t\t<WrappedComponent\n\t\t\t\t\t\t{ ...this.props.ownProps }\n\t\t\t\t\t\tref={ this.handleRef }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn forwardRef( ( props, ref ) => {\n\t\t\treturn <Wrapper ownProps={ props } forwardedRef={ ref } />;\n\t\t} );\n\t}, 'withGlobalEvents' );\n}\n"]}
@@ -4,13 +4,13 @@ import { createElement } from "@wordpress/element";
4
4
  /**
5
5
  * Internal dependencies
6
6
  */
7
- import createHigherOrderComponent from '../../utils/create-higher-order-component';
7
+ import { createHigherOrderComponent } from '../../utils/create-higher-order-component';
8
8
  import useInstanceId from '../../hooks/use-instance-id';
9
+
9
10
  /**
10
11
  * A Higher Order Component used to be provide a unique instance ID by
11
12
  * component.
12
13
  */
13
-
14
14
  const withInstanceId = createHigherOrderComponent(WrappedComponent => {
15
15
  return props => {
16
16
  const instanceId = useInstanceId(WrappedComponent); // @ts-ignore
@@ -19,6 +19,6 @@ const withInstanceId = createHigherOrderComponent(WrappedComponent => {
19
19
  instanceId: instanceId
20
20
  }));
21
21
  };
22
- }, 'withInstanceId');
22
+ }, 'instanceId');
23
23
  export default withInstanceId;
24
24
  //# sourceMappingURL=index.js.map
@@ -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,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"]}
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,SACCA,0BADD,QAIO,2CAJP;AAKA,OAAOC,aAAP,MAA0B,6BAA1B;;AAIA;AACA;AACA;AACA;AACA,MAAMC,cAAc,GAAGF,0BAA0B,CAE/CG,gBADD,IAEK;AACJ,SAASC,KAAF,IAAyD;AAC/D,UAAMC,UAAU,GAAGJ,aAAa,CAAEE,gBAAF,CAAhC,CAD+D,CAE/D;;AACA,WAAO,cAAC,gBAAD,eAAuBC,KAAvB;AAA+B,MAAA,UAAU,EAAGC;AAA5C,OAAP;AACA,GAJD;AAKA,CAT+C,EAUhD,YAVgD,CAAjD;AAaA,eAAeH,cAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateHigherOrderComponent,\n\tWithInjectedProps,\n\tWithoutInjectedProps,\n} from '../../utils/create-higher-order-component';\nimport useInstanceId from '../../hooks/use-instance-id';\n\ntype InstanceIdProps = { instanceId: string | number };\n\n/**\n * A Higher Order Component used to be provide a unique instance ID by\n * component.\n */\nconst withInstanceId = createHigherOrderComponent(\n\t< C extends WithInjectedProps< C, InstanceIdProps > >(\n\t\tWrappedComponent: C\n\t) => {\n\t\treturn ( props: WithoutInjectedProps< C, InstanceIdProps > ) => {\n\t\t\tconst instanceId = useInstanceId( WrappedComponent );\n\t\t\t// @ts-ignore\n\t\t\treturn <WrappedComponent { ...props } instanceId={ instanceId } />;\n\t\t};\n\t},\n\t'instanceId'\n);\n\nexport default withInstanceId;\n"]}
@@ -4,7 +4,7 @@ import { createElement } from "@wordpress/element";
4
4
  /**
5
5
  * Internal dependencies
6
6
  */
7
- import createHigherOrderComponent from '../../utils/create-higher-order-component';
7
+ import { createHigherOrderComponent } from '../../utils/create-higher-order-component';
8
8
  import usePreferredColorScheme from '../../hooks/use-preferred-color-scheme';
9
9
  /**
10
10
  * WordPress dependencies
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/with-preferred-color-scheme/index.native.js"],"names":["createHigherOrderComponent","usePreferredColorScheme","useCallback","withPreferredColorScheme","WrappedComponent","props","colorScheme","isDarkMode","getStyles","lightStyles","darkStyles","finalDarkStyles"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,0BAAP,MAAuC,2CAAvC;AACA,OAAOC,uBAAP,MAAoC,wCAApC;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA,MAAMC,wBAAwB,GAAGH,0BAA0B,CACxDI,gBAAF,IAA0BC,KAAF,IAAa;AACpC,QAAMC,WAAW,GAAGL,uBAAuB,EAA3C;AACA,QAAMM,UAAU,GAAGD,WAAW,KAAK,MAAnC;AAEA,QAAME,SAAS,GAAGN,WAAW,CAC5B,CAAEO,WAAF,EAAeC,UAAf,KAA+B;AAC9B,UAAMC,eAAe,GAAG,EACvB,GAAGF,WADoB;AAEvB,SAAGC;AAFoB,KAAxB;AAKA,WAAOH,UAAU,GAAGI,eAAH,GAAqBF,WAAtC;AACA,GAR2B,EAS5B,CAAEF,UAAF,CAT4B,CAA7B;AAYA,SACC,cAAC,gBAAD;AACC,IAAA,oBAAoB,EAAGD,WADxB;AAEC,IAAA,wBAAwB,EAAGE;AAF5B,KAGMH,KAHN,EADD;AAOA,CAxByD,EAyB1D,0BAzB0D,CAA3D;AA4BA,eAAeF,wBAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport createHigherOrderComponent from '../../utils/create-higher-order-component';\nimport usePreferredColorScheme from '../../hooks/use-preferred-color-scheme';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\n\nconst withPreferredColorScheme = createHigherOrderComponent(\n\t( WrappedComponent ) => ( props ) => {\n\t\tconst colorScheme = usePreferredColorScheme();\n\t\tconst isDarkMode = colorScheme === 'dark';\n\n\t\tconst getStyles = useCallback(\n\t\t\t( lightStyles, darkStyles ) => {\n\t\t\t\tconst finalDarkStyles = {\n\t\t\t\t\t...lightStyles,\n\t\t\t\t\t...darkStyles,\n\t\t\t\t};\n\n\t\t\t\treturn isDarkMode ? finalDarkStyles : lightStyles;\n\t\t\t},\n\t\t\t[ isDarkMode ]\n\t\t);\n\n\t\treturn (\n\t\t\t<WrappedComponent\n\t\t\t\tpreferredColorScheme={ colorScheme }\n\t\t\t\tgetStylesFromColorScheme={ getStyles }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t);\n\t},\n\t'withPreferredColorScheme'\n);\n\nexport default withPreferredColorScheme;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/with-preferred-color-scheme/index.native.js"],"names":["createHigherOrderComponent","usePreferredColorScheme","useCallback","withPreferredColorScheme","WrappedComponent","props","colorScheme","isDarkMode","getStyles","lightStyles","darkStyles","finalDarkStyles"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,0BAAT,QAA2C,2CAA3C;AACA,OAAOC,uBAAP,MAAoC,wCAApC;AAEA;AACA;AACA;;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA,MAAMC,wBAAwB,GAAGH,0BAA0B,CACxDI,gBAAF,IAA0BC,KAAF,IAAa;AACpC,QAAMC,WAAW,GAAGL,uBAAuB,EAA3C;AACA,QAAMM,UAAU,GAAGD,WAAW,KAAK,MAAnC;AAEA,QAAME,SAAS,GAAGN,WAAW,CAC5B,CAAEO,WAAF,EAAeC,UAAf,KAA+B;AAC9B,UAAMC,eAAe,GAAG,EACvB,GAAGF,WADoB;AAEvB,SAAGC;AAFoB,KAAxB;AAKA,WAAOH,UAAU,GAAGI,eAAH,GAAqBF,WAAtC;AACA,GAR2B,EAS5B,CAAEF,UAAF,CAT4B,CAA7B;AAYA,SACC,cAAC,gBAAD;AACC,IAAA,oBAAoB,EAAGD,WADxB;AAEC,IAAA,wBAAwB,EAAGE;AAF5B,KAGMH,KAHN,EADD;AAOA,CAxByD,EAyB1D,0BAzB0D,CAA3D;AA4BA,eAAeF,wBAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport { createHigherOrderComponent } from '../../utils/create-higher-order-component';\nimport usePreferredColorScheme from '../../hooks/use-preferred-color-scheme';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\n\nconst withPreferredColorScheme = createHigherOrderComponent(\n\t( WrappedComponent ) => ( props ) => {\n\t\tconst colorScheme = usePreferredColorScheme();\n\t\tconst isDarkMode = colorScheme === 'dark';\n\n\t\tconst getStyles = useCallback(\n\t\t\t( lightStyles, darkStyles ) => {\n\t\t\t\tconst finalDarkStyles = {\n\t\t\t\t\t...lightStyles,\n\t\t\t\t\t...darkStyles,\n\t\t\t\t};\n\n\t\t\t\treturn isDarkMode ? finalDarkStyles : lightStyles;\n\t\t\t},\n\t\t\t[ isDarkMode ]\n\t\t);\n\n\t\treturn (\n\t\t\t<WrappedComponent\n\t\t\t\tpreferredColorScheme={ colorScheme }\n\t\t\t\tgetStylesFromColorScheme={ getStyles }\n\t\t\t\t{ ...props }\n\t\t\t/>\n\t\t);\n\t},\n\t'withPreferredColorScheme'\n);\n\nexport default withPreferredColorScheme;\n"]}
@@ -1,19 +1,20 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import { createElement } from "@wordpress/element";
2
3
 
3
4
  /**
4
5
  * External dependencies
5
6
  */
6
7
  import { without } from 'lodash';
7
-
8
8
  /**
9
9
  * WordPress dependencies
10
10
  */
11
+
11
12
  import { Component } from '@wordpress/element';
12
13
  /**
13
14
  * Internal dependencies
14
15
  */
15
16
 
16
- import createHigherOrderComponent from '../../utils/create-higher-order-component';
17
+ import { createHigherOrderComponent } from '../../utils/create-higher-order-component';
17
18
  /**
18
19
  * We cannot use the `Window['setTimeout']` and `Window['clearTimeout']`
19
20
  * types here because those functions include functionality that is not handled
@@ -55,11 +56,12 @@ const withSafeTimeout = createHigherOrderComponent(OriginalComponent => {
55
56
  }
56
57
 
57
58
  render() {
58
- const props = { ...this.props,
59
- setTimeout: this.setTimeout,
60
- clearTimeout: this.clearTimeout
61
- };
62
- return createElement(OriginalComponent, props);
59
+ return (// @ts-ignore
60
+ createElement(OriginalComponent, _extends({}, this.props, {
61
+ setTimeout: this.setTimeout,
62
+ clearTimeout: this.clearTimeout
63
+ }))
64
+ );
63
65
  }
64
66
 
65
67
  };
@@ -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;;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"]}
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;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;AACA;AACA;;AACA,SACCC,0BADD,QAIO,2CAJP;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA,MAAMC,eAAe,GAAGD,0BAA0B,CAEhDE,iBADD,IAEK;AAEJ,SAAO,MAAMC,gBAAN,SAA+BJ,SAA/B,CAAyD;AAG/DK,IAAAA,WAAW,CAAEC,KAAF,EAAwB;AAClC,YAAOA,KAAP;AACA,WAAKC,QAAL,GAAgB,EAAhB;AACA,WAAKC,UAAL,GAAkB,KAAKA,UAAL,CAAgBC,IAAhB,CAAsB,IAAtB,CAAlB;AACA,WAAKC,YAAL,GAAoB,KAAKA,YAAL,CAAkBD,IAAlB,CAAwB,IAAxB,CAApB;AACA;;AAEDE,IAAAA,oBAAoB,GAAG;AACtB,WAAKJ,QAAL,CAAcK,OAAd,CAAuBF,YAAvB;AACA;;AAEDF,IAAAA,UAAU,CAAEK,EAAF,EAAkBC,KAAlB,EAAkC;AAC3C,YAAMC,EAAE,GAAGP,UAAU,CAAE,MAAM;AAC5BK,QAAAA,EAAE;AACF,aAAKH,YAAL,CAAmBK,EAAnB;AACA,OAHoB,EAGlBD,KAHkB,CAArB;AAIA,WAAKP,QAAL,CAAcS,IAAd,CAAoBD,EAApB;AACA,aAAOA,EAAP;AACA;;AAEDL,IAAAA,YAAY,CAAEK,EAAF,EAAe;AAC1BL,MAAAA,YAAY,CAAEK,EAAF,CAAZ;AACA,WAAKR,QAAL,GAAgBR,OAAO,CAAE,KAAKQ,QAAP,EAAiBQ,EAAjB,CAAvB;AACA;;AAEDE,IAAAA,MAAM,GAAG;AACR,aACC;AACA,sBAAC,iBAAD,eACM,KAAKX,KADX;AAEC,UAAA,UAAU,EAAG,KAAKE,UAFnB;AAGC,UAAA,YAAY,EAAG,KAAKE;AAHrB;AAFD;AAQA;;AArC8D,GAAhE;AAuCA,CA5CgD,EA6CjD,iBA7CiD,CAAlD;AAgDA,eAAeR,eAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tcreateHigherOrderComponent,\n\tWithInjectedProps,\n\tWithoutInjectedProps,\n} from '../../utils/create-higher-order-component';\n\n/**\n * We cannot use the `Window['setTimeout']` and `Window['clearTimeout']`\n * types here because those functions include functionality that is not handled\n * by this component, like the ability to pass extra arguments.\n *\n * In the case of this component, we only handle the simplest case where\n * `setTimeout` only accepts a function (not a string) and an optional delay.\n */\ninterface TimeoutProps {\n\tsetTimeout: ( fn: () => void, delay: number ) => number;\n\tclearTimeout: ( id: number ) => void;\n}\n\n/**\n * A higher-order component used to provide and manage delayed function calls\n * that ought to be bound to a component's lifecycle.\n */\nconst withSafeTimeout = createHigherOrderComponent(\n\t< C extends WithInjectedProps< C, TimeoutProps > >(\n\t\tOriginalComponent: C\n\t) => {\n\t\ttype WrappedProps = WithoutInjectedProps< C, TimeoutProps >;\n\t\treturn class WrappedComponent extends Component< WrappedProps > {\n\t\t\ttimeouts: number[];\n\n\t\t\tconstructor( props: WrappedProps ) {\n\t\t\t\tsuper( props );\n\t\t\t\tthis.timeouts = [];\n\t\t\t\tthis.setTimeout = this.setTimeout.bind( this );\n\t\t\t\tthis.clearTimeout = this.clearTimeout.bind( this );\n\t\t\t}\n\n\t\t\tcomponentWillUnmount() {\n\t\t\t\tthis.timeouts.forEach( clearTimeout );\n\t\t\t}\n\n\t\t\tsetTimeout( fn: () => void, delay: number ) {\n\t\t\t\tconst id = setTimeout( () => {\n\t\t\t\t\tfn();\n\t\t\t\t\tthis.clearTimeout( id );\n\t\t\t\t}, delay );\n\t\t\t\tthis.timeouts.push( id );\n\t\t\t\treturn id;\n\t\t\t}\n\n\t\t\tclearTimeout( id: number ) {\n\t\t\t\tclearTimeout( id );\n\t\t\t\tthis.timeouts = without( this.timeouts, id );\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\treturn (\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t<OriginalComponent\n\t\t\t\t\t\t{ ...this.props }\n\t\t\t\t\t\tsetTimeout={ this.setTimeout }\n\t\t\t\t\t\tclearTimeout={ this.clearTimeout }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t},\n\t'withSafeTimeout'\n);\n\nexport default withSafeTimeout;\n"]}
@@ -10,7 +10,7 @@ import deprecated from '@wordpress/deprecated';
10
10
  * Internal dependencies
11
11
  */
12
12
 
13
- import createHigherOrderComponent from '../../utils/create-higher-order-component';
13
+ import { createHigherOrderComponent } from '../../utils/create-higher-order-component';
14
14
  /**
15
15
  * A Higher Order Component used to provide and manage internal component state
16
16
  * via props.
@@ -1 +1 @@
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"]}
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,SAASC,0BAAT,QAA2C,2CAA3C;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"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-debounce/index.js"],"names":["debounce","useMemoOne","useEffect","useDebounce","fn","wait","options","debounced","cancel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,QAAzB;AACA,SAASC,UAAT,QAA2B,cAA3B;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,WAAT,CAAsBC,EAAtB,EAA0BC,IAA1B,EAAgCC,OAAhC,EAA0C;AACxD;AACA,QAAMC,SAAS,GAAGN,UAAU,CAAE,MAAMD,QAAQ,CAAEI,EAAF,EAAMC,IAAN,EAAYC,OAAZ,CAAhB,EAAuC,CAClEF,EADkE,EAElEC,IAFkE,EAGlEC,OAHkE,CAAvC,CAA5B;AAKAJ,EAAAA,SAAS,CAAE,MAAM,MAAMK,SAAS,CAACC,MAAV,EAAd,EAAkC,CAAED,SAAF,CAAlC,CAAT;AACA,SAAOA,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Debounces a function with Lodash's `debounce`. A new debounced function will\n * be returned and any scheduled calls cancelled if any of the arguments change,\n * including the function to debounce, so please wrap functions created on\n * render in components in `useCallback`.\n *\n * @see https://docs-lodash.com/v4/debounce/\n *\n * @template {(...args: any[]) => void} TFunc\n *\n * @param {TFunc} fn The function to debounce.\n * @param {number} [wait] The number of milliseconds to delay.\n * @param {import('lodash').DebounceSettings} [options] The options object.\n * @return {import('lodash').DebouncedFunc<TFunc>} Debounced function.\n */\nexport default function useDebounce( fn, wait, options ) {\n\t/* eslint-enable jsdoc/valid-types */\n\tconst debounced = useMemoOne( () => debounce( fn, wait, options ), [\n\t\tfn,\n\t\twait,\n\t\toptions,\n\t] );\n\tuseEffect( () => () => debounced.cancel(), [ debounced ] );\n\treturn debounced;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-debounce/index.js"],"names":["debounce","useMemoOne","useEffect","useDebounce","fn","wait","options","debounced","cancel"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,QAAzB;AACA,SAASC,UAAT,QAA2B,cAA3B;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,oBAA1B;AAEA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,WAAT,CAAsBC,EAAtB,EAA0BC,IAA1B,EAAgCC,OAAhC,EAA0C;AACxD;AACA,QAAMC,SAAS,GAAGN,UAAU,CAC3B,MAAMD,QAAQ,CAAEI,EAAF,EAAMC,IAAN,EAAYC,OAAZ,CADa,EAE3B,CAAEF,EAAF,EAAMC,IAAN,EAAYC,OAAZ,CAF2B,CAA5B;AAIAJ,EAAAA,SAAS,CAAE,MAAM,MAAMK,SAAS,CAACC,MAAV,EAAd,EAAkC,CAAED,SAAF,CAAlC,CAAT;AACA,SAAOA,SAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\nimport { useMemoOne } from 'use-memo-one';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Debounces a function with Lodash's `debounce`. A new debounced function will\n * be returned and any scheduled calls cancelled if any of the arguments change,\n * including the function to debounce, so please wrap functions created on\n * render in components in `useCallback`.\n *\n * @see https://docs-lodash.com/v4/debounce/\n *\n * @template {(...args: any[]) => void} TFunc\n *\n * @param {TFunc} fn The function to debounce.\n * @param {number} [wait] The number of milliseconds to delay.\n * @param {import('lodash').DebounceSettings} [options] The options object.\n * @return {import('lodash').DebouncedFunc<TFunc>} Debounced function.\n */\nexport default function useDebounce( fn, wait, options ) {\n\t/* eslint-enable jsdoc/valid-types */\n\tconst debounced = useMemoOne(\n\t\t() => debounce( fn, wait, options ),\n\t\t[ fn, wait, options ]\n\t);\n\tuseEffect( () => () => debounced.cancel(), [ debounced ] );\n\treturn debounced;\n}\n"]}
@@ -12,7 +12,9 @@ import useFocusOnMount from '../use-focus-on-mount';
12
12
  import useFocusReturn from '../use-focus-return';
13
13
  import useFocusOutside from '../use-focus-outside';
14
14
  import useMergeRefs from '../use-merge-refs';
15
- /* eslint-disable jsdoc/valid-types */
15
+ /**
16
+ * @typedef {import('../use-focus-on-mount').default} useFocusOnMount
17
+ */
16
18
 
17
19
  /**
18
20
  * @typedef DialogOptions
@@ -20,8 +22,6 @@ import useMergeRefs from '../use-merge-refs';
20
22
  * @property {() => void} onClose Function to call when the dialog is closed.
21
23
  */
22
24
 
23
- /* eslint-enable jsdoc/valid-types */
24
-
25
25
  /**
26
26
  * Returns a ref and props to apply to a dialog wrapper to enable the following behaviors:
27
27
  * - constrained tabbing.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-dialog/index.js"],"names":["useRef","useEffect","useCallback","ESCAPE","useConstrainedTabbing","useFocusOnMount","useFocusReturn","useFocusOutside","useMergeRefs","useDialog","options","currentOptions","current","Object","values","constrainedTabbingRef","focusOnMountRef","focusOnMount","focusReturnRef","focusOutsideProps","event","__unstableOnClose","onClose","closeOnEscapeRef","node","addEventListener","keyCode","defaultPrevented","preventDefault","tabIndex"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,SAAjB,EAA4BC,WAA5B,QAA+C,oBAA/C;AACA,SAASC,MAAT,QAAuB,qBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,eAAP,MAA4B,uBAA5B;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA,OAAOC,eAAP,MAA4B,sBAA5B;AACA,OAAOC,YAAP,MAAyB,mBAAzB;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,SAAT,CAAoBC,OAApB,EAA8B;AAC7B;AACD;AACA;AACC,QAAMC,cAAc,GAAGX,MAAM,EAA7B;AACAC,EAAAA,SAAS,CAAE,MAAM;AAChBU,IAAAA,cAAc,CAACC,OAAf,GAAyBF,OAAzB;AACA,GAFQ,EAENG,MAAM,CAACC,MAAP,CAAeJ,OAAf,CAFM,CAAT;AAGA,QAAMK,qBAAqB,GAAGX,qBAAqB,EAAnD;AACA,QAAMY,eAAe,GAAGX,eAAe,CAAEK,OAAO,CAACO,YAAV,CAAvC;AACA,QAAMC,cAAc,GAAGZ,cAAc,EAArC;AACA,QAAMa,iBAAiB,GAAGZ,eAAe,CAAIa,KAAF,IAAa;AAAA;;AACvD;AACA;AACA;AACA,iCAAKT,cAAc,CAACC,OAApB,kDAAK,sBAAwBS,iBAA7B,EAAiD;AAChD;AACAV,MAAAA,cAAc,CAACC,OAAf,CAAuBS,iBAAvB,CAA0C,eAA1C,EAA2DD,KAA3D;AACA,KAHD,MAGO,8BAAKT,cAAc,CAACC,OAApB,mDAAK,uBAAwBU,OAA7B,EAAuC;AAC7CX,MAAAA,cAAc,CAACC,OAAf,CAAuBU,OAAvB;AACA;AACD,GAVwC,CAAzC;AAWA,QAAMC,gBAAgB,GAAGrB,WAAW,CAAIsB,IAAF,IAAY;AACjD,QAAK,CAAEA,IAAP,EAAc;AACb;AACA;;AAEDA,IAAAA,IAAI,CAACC,gBAAL,CAAuB,SAAvB,EAAkC;AACjC;AAA6BL,IAAAA,KADI,KAE7B;AAAA;;AACJ;AACA,UACCA,KAAK,CAACM,OAAN,KAAkBvB,MAAlB,IACA,CAAEiB,KAAK,CAACO,gBADR,8BAEAhB,cAAc,CAACC,OAFf,mDAEA,uBAAwBU,OAHzB,EAIE;AACDF,QAAAA,KAAK,CAACQ,cAAN;AACAjB,QAAAA,cAAc,CAACC,OAAf,CAAuBU,OAAvB;AACA;AACD,KAZD;AAaA,GAlBmC,EAkBjC,EAlBiC,CAApC;AAoBA,SAAO,CACNd,YAAY,CAAE,CACbE,OAAO,CAACO,YAAR,KAAyB,KAAzB,GAAiCF,qBAAjC,GAAyD,IAD5C,EAEbL,OAAO,CAACO,YAAR,KAAyB,KAAzB,GAAiCC,cAAjC,GAAkD,IAFrC,EAGbR,OAAO,CAACO,YAAR,KAAyB,KAAzB,GAAiCD,eAAjC,GAAmD,IAHtC,EAIbO,gBAJa,CAAF,CADN,EAON,EACC,GAAGJ,iBADJ;AAECU,IAAAA,QAAQ,EAAE;AAFX,GAPM,CAAP;AAYA;;AAED,eAAepB,SAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect, useCallback } from '@wordpress/element';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport useConstrainedTabbing from '../use-constrained-tabbing';\nimport useFocusOnMount from '../use-focus-on-mount';\nimport useFocusReturn from '../use-focus-return';\nimport useFocusOutside from '../use-focus-outside';\nimport useMergeRefs from '../use-merge-refs';\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * @typedef DialogOptions\n * @property {Parameters<useFocusOnMount>[0]} focusOnMount Focus on mount arguments.\n * @property {() => void} onClose Function to call when the dialog is closed.\n */\n/* eslint-enable jsdoc/valid-types */\n\n/**\n * Returns a ref and props to apply to a dialog wrapper to enable the following behaviors:\n * - constrained tabbing.\n * - focus on mount.\n * - return focus on unmount.\n * - focus outside.\n *\n * @param {DialogOptions} options Dialog Options.\n */\nfunction useDialog( options ) {\n\t/**\n\t * @type {import('react').MutableRefObject<DialogOptions | undefined>}\n\t */\n\tconst currentOptions = useRef();\n\tuseEffect( () => {\n\t\tcurrentOptions.current = options;\n\t}, Object.values( options ) );\n\tconst constrainedTabbingRef = useConstrainedTabbing();\n\tconst focusOnMountRef = useFocusOnMount( options.focusOnMount );\n\tconst focusReturnRef = useFocusReturn();\n\tconst focusOutsideProps = useFocusOutside( ( event ) => {\n\t\t// This unstable prop is here only to manage backward compatibility\n\t\t// for the Popover component otherwise, the onClose should be enough.\n\t\t// @ts-ignore unstable property\n\t\tif ( currentOptions.current?.__unstableOnClose ) {\n\t\t\t// @ts-ignore unstable property\n\t\t\tcurrentOptions.current.__unstableOnClose( 'focus-outside', event );\n\t\t} else if ( currentOptions.current?.onClose ) {\n\t\t\tcurrentOptions.current.onClose();\n\t\t}\n\t} );\n\tconst closeOnEscapeRef = useCallback( ( node ) => {\n\t\tif ( ! node ) {\n\t\t\treturn;\n\t\t}\n\n\t\tnode.addEventListener( 'keydown', (\n\t\t\t/** @type {KeyboardEvent} */ event\n\t\t) => {\n\t\t\t// Close on escape.\n\t\t\tif (\n\t\t\t\tevent.keyCode === ESCAPE &&\n\t\t\t\t! event.defaultPrevented &&\n\t\t\t\tcurrentOptions.current?.onClose\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tcurrentOptions.current.onClose();\n\t\t\t}\n\t\t} );\n\t}, [] );\n\n\treturn [\n\t\tuseMergeRefs( [\n\t\t\toptions.focusOnMount !== false ? constrainedTabbingRef : null,\n\t\t\toptions.focusOnMount !== false ? focusReturnRef : null,\n\t\t\toptions.focusOnMount !== false ? focusOnMountRef : null,\n\t\t\tcloseOnEscapeRef,\n\t\t] ),\n\t\t{\n\t\t\t...focusOutsideProps,\n\t\t\ttabIndex: '-1',\n\t\t},\n\t];\n}\n\nexport default useDialog;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-dialog/index.js"],"names":["useRef","useEffect","useCallback","ESCAPE","useConstrainedTabbing","useFocusOnMount","useFocusReturn","useFocusOutside","useMergeRefs","useDialog","options","currentOptions","current","Object","values","constrainedTabbingRef","focusOnMountRef","focusOnMount","focusReturnRef","focusOutsideProps","event","__unstableOnClose","onClose","closeOnEscapeRef","node","addEventListener","keyCode","defaultPrevented","preventDefault","tabIndex"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,SAAjB,EAA4BC,WAA5B,QAA+C,oBAA/C;AACA,SAASC,MAAT,QAAuB,qBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,eAAP,MAA4B,uBAA5B;AACA,OAAOC,cAAP,MAA2B,qBAA3B;AACA,OAAOC,eAAP,MAA4B,sBAA5B;AACA,OAAOC,YAAP,MAAyB,mBAAzB;AAEA;AACA;AACA;;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,SAAT,CAAoBC,OAApB,EAA8B;AAC7B;AACD;AACA;AACC,QAAMC,cAAc,GAAGX,MAAM,EAA7B;AACAC,EAAAA,SAAS,CAAE,MAAM;AAChBU,IAAAA,cAAc,CAACC,OAAf,GAAyBF,OAAzB;AACA,GAFQ,EAENG,MAAM,CAACC,MAAP,CAAeJ,OAAf,CAFM,CAAT;AAGA,QAAMK,qBAAqB,GAAGX,qBAAqB,EAAnD;AACA,QAAMY,eAAe,GAAGX,eAAe,CAAEK,OAAO,CAACO,YAAV,CAAvC;AACA,QAAMC,cAAc,GAAGZ,cAAc,EAArC;AACA,QAAMa,iBAAiB,GAAGZ,eAAe,CAAIa,KAAF,IAAa;AAAA;;AACvD;AACA;AACA;AACA,iCAAKT,cAAc,CAACC,OAApB,kDAAK,sBAAwBS,iBAA7B,EAAiD;AAChD;AACAV,MAAAA,cAAc,CAACC,OAAf,CAAuBS,iBAAvB,CAA0C,eAA1C,EAA2DD,KAA3D;AACA,KAHD,MAGO,8BAAKT,cAAc,CAACC,OAApB,mDAAK,uBAAwBU,OAA7B,EAAuC;AAC7CX,MAAAA,cAAc,CAACC,OAAf,CAAuBU,OAAvB;AACA;AACD,GAVwC,CAAzC;AAWA,QAAMC,gBAAgB,GAAGrB,WAAW,CAAIsB,IAAF,IAAY;AACjD,QAAK,CAAEA,IAAP,EAAc;AACb;AACA;;AAEDA,IAAAA,IAAI,CAACC,gBAAL,CACC,SADD,EAEC;AAAE;AAA6BL,IAAAA,KAA/B,KAA0C;AAAA;;AACzC;AACA,UACCA,KAAK,CAACM,OAAN,KAAkBvB,MAAlB,IACA,CAAEiB,KAAK,CAACO,gBADR,8BAEAhB,cAAc,CAACC,OAFf,mDAEA,uBAAwBU,OAHzB,EAIE;AACDF,QAAAA,KAAK,CAACQ,cAAN;AACAjB,QAAAA,cAAc,CAACC,OAAf,CAAuBU,OAAvB;AACA;AACD,KAZF;AAcA,GAnBmC,EAmBjC,EAnBiC,CAApC;AAqBA,SAAO,CACNd,YAAY,CAAE,CACbE,OAAO,CAACO,YAAR,KAAyB,KAAzB,GAAiCF,qBAAjC,GAAyD,IAD5C,EAEbL,OAAO,CAACO,YAAR,KAAyB,KAAzB,GAAiCC,cAAjC,GAAkD,IAFrC,EAGbR,OAAO,CAACO,YAAR,KAAyB,KAAzB,GAAiCD,eAAjC,GAAmD,IAHtC,EAIbO,gBAJa,CAAF,CADN,EAON,EACC,GAAGJ,iBADJ;AAECU,IAAAA,QAAQ,EAAE;AAFX,GAPM,CAAP;AAYA;;AAED,eAAepB,SAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef, useEffect, useCallback } from '@wordpress/element';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport useConstrainedTabbing from '../use-constrained-tabbing';\nimport useFocusOnMount from '../use-focus-on-mount';\nimport useFocusReturn from '../use-focus-return';\nimport useFocusOutside from '../use-focus-outside';\nimport useMergeRefs from '../use-merge-refs';\n\n/**\n * @typedef {import('../use-focus-on-mount').default} useFocusOnMount\n */\n/**\n * @typedef DialogOptions\n * @property {Parameters<useFocusOnMount>[0]} focusOnMount Focus on mount arguments.\n * @property {() => void} onClose Function to call when the dialog is closed.\n */\n\n/**\n * Returns a ref and props to apply to a dialog wrapper to enable the following behaviors:\n * - constrained tabbing.\n * - focus on mount.\n * - return focus on unmount.\n * - focus outside.\n *\n * @param {DialogOptions} options Dialog Options.\n */\nfunction useDialog( options ) {\n\t/**\n\t * @type {import('react').MutableRefObject<DialogOptions | undefined>}\n\t */\n\tconst currentOptions = useRef();\n\tuseEffect( () => {\n\t\tcurrentOptions.current = options;\n\t}, Object.values( options ) );\n\tconst constrainedTabbingRef = useConstrainedTabbing();\n\tconst focusOnMountRef = useFocusOnMount( options.focusOnMount );\n\tconst focusReturnRef = useFocusReturn();\n\tconst focusOutsideProps = useFocusOutside( ( event ) => {\n\t\t// This unstable prop is here only to manage backward compatibility\n\t\t// for the Popover component otherwise, the onClose should be enough.\n\t\t// @ts-ignore unstable property\n\t\tif ( currentOptions.current?.__unstableOnClose ) {\n\t\t\t// @ts-ignore unstable property\n\t\t\tcurrentOptions.current.__unstableOnClose( 'focus-outside', event );\n\t\t} else if ( currentOptions.current?.onClose ) {\n\t\t\tcurrentOptions.current.onClose();\n\t\t}\n\t} );\n\tconst closeOnEscapeRef = useCallback( ( node ) => {\n\t\tif ( ! node ) {\n\t\t\treturn;\n\t\t}\n\n\t\tnode.addEventListener(\n\t\t\t'keydown',\n\t\t\t( /** @type {KeyboardEvent} */ event ) => {\n\t\t\t\t// Close on escape.\n\t\t\t\tif (\n\t\t\t\t\tevent.keyCode === ESCAPE &&\n\t\t\t\t\t! event.defaultPrevented &&\n\t\t\t\t\tcurrentOptions.current?.onClose\n\t\t\t\t) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tcurrentOptions.current.onClose();\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\t}, [] );\n\n\treturn [\n\t\tuseMergeRefs( [\n\t\t\toptions.focusOnMount !== false ? constrainedTabbingRef : null,\n\t\t\toptions.focusOnMount !== false ? focusReturnRef : null,\n\t\t\toptions.focusOnMount !== false ? focusOnMountRef : null,\n\t\t\tcloseOnEscapeRef,\n\t\t] ),\n\t\t{\n\t\t\t...focusOutsideProps,\n\t\t\ttabIndex: '-1',\n\t\t},\n\t];\n}\n\nexport default useDialog;\n"]}