@wordpress/compose 6.10.0 → 6.12.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 (100) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/higher-order/pipe.js +6 -19
  3. package/build/higher-order/pipe.js.map +1 -1
  4. package/build/higher-order/with-global-events/listener.js +1 -3
  5. package/build/higher-order/with-global-events/listener.js.map +1 -1
  6. package/build/higher-order/with-state/index.js +1 -2
  7. package/build/higher-order/with-state/index.js.map +1 -1
  8. package/build/hooks/use-async-list/index.js +3 -4
  9. package/build/hooks/use-async-list/index.js.map +1 -1
  10. package/build/hooks/use-constrained-tabbing/index.js +1 -1
  11. package/build/hooks/use-constrained-tabbing/index.js.map +1 -1
  12. package/build/hooks/use-copy-on-click/index.js +5 -8
  13. package/build/hooks/use-copy-on-click/index.js.map +1 -1
  14. package/build/hooks/use-copy-to-clipboard/index.js +3 -4
  15. package/build/hooks/use-copy-to-clipboard/index.js.map +1 -1
  16. package/build/hooks/use-dialog/index.js +3 -7
  17. package/build/hooks/use-dialog/index.js.map +1 -1
  18. package/build/hooks/use-disabled/index.js +4 -7
  19. package/build/hooks/use-disabled/index.js.map +1 -1
  20. package/build/hooks/use-dragging/index.js +5 -6
  21. package/build/hooks/use-dragging/index.js.map +1 -1
  22. package/build/hooks/use-drop-zone/index.js +27 -21
  23. package/build/hooks/use-drop-zone/index.js.map +1 -1
  24. package/build/hooks/use-fixed-window-list/index.js +14 -22
  25. package/build/hooks/use-fixed-window-list/index.js.map +1 -1
  26. package/build/hooks/use-focus-on-mount/index.js +3 -4
  27. package/build/hooks/use-focus-on-mount/index.js.map +1 -1
  28. package/build/hooks/use-focus-outside/index.js +1 -3
  29. package/build/hooks/use-focus-outside/index.js.map +1 -1
  30. package/build/hooks/use-focus-return/index.js +3 -7
  31. package/build/hooks/use-focus-return/index.js.map +1 -1
  32. package/build/hooks/use-keyboard-shortcut/index.js +14 -14
  33. package/build/hooks/use-keyboard-shortcut/index.js.map +1 -1
  34. package/build/hooks/use-media-query/index.js +1 -1
  35. package/build/hooks/use-media-query/index.js.map +1 -1
  36. package/build/hooks/use-preferred-color-scheme/index.android.js +3 -4
  37. package/build/hooks/use-preferred-color-scheme/index.android.js.map +1 -1
  38. package/build/hooks/use-resize-observer/index.js +1 -2
  39. package/build/hooks/use-resize-observer/index.js.map +1 -1
  40. package/build/hooks/use-resize-observer/index.native.js +3 -4
  41. package/build/hooks/use-resize-observer/index.native.js.map +1 -1
  42. package/build/hooks/use-viewport-match/index.js +1 -2
  43. package/build/hooks/use-viewport-match/index.js.map +1 -1
  44. package/build/hooks/use-warn-on-change/index.js +2 -5
  45. package/build/hooks/use-warn-on-change/index.js.map +1 -1
  46. package/build/utils/debounce/index.js +1 -6
  47. package/build/utils/debounce/index.js.map +1 -1
  48. package/build-module/higher-order/pipe.js +6 -19
  49. package/build-module/higher-order/pipe.js.map +1 -1
  50. package/build-module/higher-order/with-global-events/listener.js +1 -3
  51. package/build-module/higher-order/with-global-events/listener.js.map +1 -1
  52. package/build-module/higher-order/with-state/index.js +1 -2
  53. package/build-module/higher-order/with-state/index.js.map +1 -1
  54. package/build-module/hooks/use-async-list/index.js +3 -4
  55. package/build-module/hooks/use-async-list/index.js.map +1 -1
  56. package/build-module/hooks/use-constrained-tabbing/index.js +1 -1
  57. package/build-module/hooks/use-constrained-tabbing/index.js.map +1 -1
  58. package/build-module/hooks/use-copy-on-click/index.js +5 -8
  59. package/build-module/hooks/use-copy-on-click/index.js.map +1 -1
  60. package/build-module/hooks/use-copy-to-clipboard/index.js +3 -4
  61. package/build-module/hooks/use-copy-to-clipboard/index.js.map +1 -1
  62. package/build-module/hooks/use-dialog/index.js +3 -7
  63. package/build-module/hooks/use-dialog/index.js.map +1 -1
  64. package/build-module/hooks/use-disabled/index.js +4 -7
  65. package/build-module/hooks/use-disabled/index.js.map +1 -1
  66. package/build-module/hooks/use-dragging/index.js +5 -6
  67. package/build-module/hooks/use-dragging/index.js.map +1 -1
  68. package/build-module/hooks/use-drop-zone/index.js +27 -21
  69. package/build-module/hooks/use-drop-zone/index.js.map +1 -1
  70. package/build-module/hooks/use-fixed-window-list/index.js +14 -22
  71. package/build-module/hooks/use-fixed-window-list/index.js.map +1 -1
  72. package/build-module/hooks/use-focus-on-mount/index.js +3 -4
  73. package/build-module/hooks/use-focus-on-mount/index.js.map +1 -1
  74. package/build-module/hooks/use-focus-outside/index.js +1 -3
  75. package/build-module/hooks/use-focus-outside/index.js.map +1 -1
  76. package/build-module/hooks/use-focus-return/index.js +3 -7
  77. package/build-module/hooks/use-focus-return/index.js.map +1 -1
  78. package/build-module/hooks/use-keyboard-shortcut/index.js +14 -14
  79. package/build-module/hooks/use-keyboard-shortcut/index.js.map +1 -1
  80. package/build-module/hooks/use-media-query/index.js +1 -1
  81. package/build-module/hooks/use-media-query/index.js.map +1 -1
  82. package/build-module/hooks/use-preferred-color-scheme/index.android.js +3 -4
  83. package/build-module/hooks/use-preferred-color-scheme/index.android.js.map +1 -1
  84. package/build-module/hooks/use-resize-observer/index.js +1 -2
  85. package/build-module/hooks/use-resize-observer/index.js.map +1 -1
  86. package/build-module/hooks/use-resize-observer/index.native.js +3 -4
  87. package/build-module/hooks/use-resize-observer/index.native.js.map +1 -1
  88. package/build-module/hooks/use-viewport-match/index.js +1 -2
  89. package/build-module/hooks/use-viewport-match/index.js.map +1 -1
  90. package/build-module/hooks/use-warn-on-change/index.js +2 -5
  91. package/build-module/hooks/use-warn-on-change/index.js.map +1 -1
  92. package/build-module/utils/debounce/index.js +1 -6
  93. package/build-module/utils/debounce/index.js.map +1 -1
  94. package/build-types/hooks/use-drop-zone/index.d.ts +11 -9
  95. package/build-types/hooks/use-drop-zone/index.d.ts.map +1 -1
  96. package/package.json +8 -8
  97. package/src/hooks/use-drop-zone/README.md +71 -0
  98. package/src/hooks/use-drop-zone/index.js +17 -10
  99. package/src/hooks/use-drop-zone/test/index.js +63 -0
  100. package/tsconfig.tsbuildinfo +1 -1
@@ -81,8 +81,7 @@ null);
81
81
  * @return {boolean} Whether viewport matches query.
82
82
  */
83
83
 
84
- const useViewportMatch = function (breakpoint) {
85
- let operator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '>=';
84
+ const useViewportMatch = (breakpoint, operator = '>=') => {
86
85
  const simulatedWidth = (0, _element.useContext)(ViewportMatchWidthContext);
87
86
  const mediaQuery = !simulatedWidth && `(${CONDITIONS[operator]}: ${BREAKPOINTS[breakpoint]}px)`;
88
87
  const mediaQueryResult = (0, _useMediaQuery.default)(mediaQuery || undefined);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-viewport-match/index.js"],"names":["BREAKPOINTS","huge","wide","large","medium","small","mobile","CONDITIONS","OPERATOR_EVALUATORS","breakpointValue","width","ViewportMatchWidthContext","useViewportMatch","breakpoint","operator","simulatedWidth","mediaQuery","mediaQueryResult","undefined","__experimentalWidthProvider","Provider"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,WAAW,GAAG;AACnBC,EAAAA,IAAI,EAAE,IADa;AAEnBC,EAAAA,IAAI,EAAE,IAFa;AAGnBC,EAAAA,KAAK,EAAE,GAHY;AAInBC,EAAAA,MAAM,EAAE,GAJW;AAKnBC,EAAAA,KAAK,EAAE,GALY;AAMnBC,EAAAA,MAAM,EAAE;AANW,CAApB;AASA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,UAAU,GAAG;AAClB,QAAM,WADY;AAElB,OAAK;AAFa,CAAnB;AAKA;AACA;AACA;AACA;AACA;;AACA,MAAMC,mBAAmB,GAAG;AAC3B,QAAM,CAAEC,eAAF,EAAmBC,KAAnB,KAA8BA,KAAK,IAAID,eADlB;AAE3B,OAAK,CAAEA,eAAF,EAAmBC,KAAnB,KAA8BA,KAAK,GAAGD;AAFhB,CAA5B;AAKA,MAAME,yBAAyB,GAAG;AACjC;AAA+B,IADE,CAAlC;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,gBAAgB,GAAG,UAAEC,UAAF,EAAmC;AAAA,MAArBC,QAAqB,uEAAV,IAAU;AAC3D,QAAMC,cAAc,GAAG,yBAAYJ,yBAAZ,CAAvB;AACA,QAAMK,UAAU,GACf,CAAED,cAAF,IACC,IAAIR,UAAU,CAAEO,QAAF,CAAc,KAAKd,WAAW,CAAEa,UAAF,CAAgB,KAF9D;AAGA,QAAMI,gBAAgB,GAAG,4BAAeD,UAAU,IAAIE,SAA7B,CAAzB;;AACA,MAAKH,cAAL,EAAsB;AACrB,WAAOP,mBAAmB,CAAEM,QAAF,CAAnB,CACNd,WAAW,CAAEa,UAAF,CADL,EAENE,cAFM,CAAP;AAIA;;AACD,SAAOE,gBAAP;AACA,CAbD;;AAeAL,gBAAgB,CAACO,2BAAjB,GACCR,yBAAyB,CAACS,QAD3B;eAGeR,gB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useMediaQuery from '../use-media-query';\n\n/**\n * @typedef {\"huge\" | \"wide\" | \"large\" | \"medium\" | \"small\" | \"mobile\"} WPBreakpoint\n */\n\n/**\n * Hash of breakpoint names with pixel width at which it becomes effective.\n *\n * @see _breakpoints.scss\n *\n * @type {Record<WPBreakpoint, number>}\n */\nconst BREAKPOINTS = {\n\thuge: 1440,\n\twide: 1280,\n\tlarge: 960,\n\tmedium: 782,\n\tsmall: 600,\n\tmobile: 480,\n};\n\n/**\n * @typedef {\">=\" | \"<\"} WPViewportOperator\n */\n\n/**\n * Object mapping media query operators to the condition to be used.\n *\n * @type {Record<WPViewportOperator, string>}\n */\nconst CONDITIONS = {\n\t'>=': 'min-width',\n\t'<': 'max-width',\n};\n\n/**\n * Object mapping media query operators to a function that given a breakpointValue and a width evaluates if the operator matches the values.\n *\n * @type {Record<WPViewportOperator, (breakpointValue: number, width: number) => boolean>}\n */\nconst OPERATOR_EVALUATORS = {\n\t'>=': ( breakpointValue, width ) => width >= breakpointValue,\n\t'<': ( breakpointValue, width ) => width < breakpointValue,\n};\n\nconst ViewportMatchWidthContext = createContext(\n\t/** @type {null | number} */ ( null )\n);\n\n/**\n * Returns true if the viewport matches the given query, or false otherwise.\n *\n * @param {WPBreakpoint} breakpoint Breakpoint size name.\n * @param {WPViewportOperator} [operator=\">=\"] Viewport operator.\n *\n * @example\n *\n * ```js\n * useViewportMatch( 'huge', '<' );\n * useViewportMatch( 'medium' );\n * ```\n *\n * @return {boolean} Whether viewport matches query.\n */\nconst useViewportMatch = ( breakpoint, operator = '>=' ) => {\n\tconst simulatedWidth = useContext( ViewportMatchWidthContext );\n\tconst mediaQuery =\n\t\t! simulatedWidth &&\n\t\t`(${ CONDITIONS[ operator ] }: ${ BREAKPOINTS[ breakpoint ] }px)`;\n\tconst mediaQueryResult = useMediaQuery( mediaQuery || undefined );\n\tif ( simulatedWidth ) {\n\t\treturn OPERATOR_EVALUATORS[ operator ](\n\t\t\tBREAKPOINTS[ breakpoint ],\n\t\t\tsimulatedWidth\n\t\t);\n\t}\n\treturn mediaQueryResult;\n};\n\nuseViewportMatch.__experimentalWidthProvider =\n\tViewportMatchWidthContext.Provider;\n\nexport default useViewportMatch;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-viewport-match/index.js"],"names":["BREAKPOINTS","huge","wide","large","medium","small","mobile","CONDITIONS","OPERATOR_EVALUATORS","breakpointValue","width","ViewportMatchWidthContext","useViewportMatch","breakpoint","operator","simulatedWidth","mediaQuery","mediaQueryResult","undefined","__experimentalWidthProvider","Provider"],"mappings":";;;;;;;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,WAAW,GAAG;AACnBC,EAAAA,IAAI,EAAE,IADa;AAEnBC,EAAAA,IAAI,EAAE,IAFa;AAGnBC,EAAAA,KAAK,EAAE,GAHY;AAInBC,EAAAA,MAAM,EAAE,GAJW;AAKnBC,EAAAA,KAAK,EAAE,GALY;AAMnBC,EAAAA,MAAM,EAAE;AANW,CAApB;AASA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AACA,MAAMC,UAAU,GAAG;AAClB,QAAM,WADY;AAElB,OAAK;AAFa,CAAnB;AAKA;AACA;AACA;AACA;AACA;;AACA,MAAMC,mBAAmB,GAAG;AAC3B,QAAM,CAAEC,eAAF,EAAmBC,KAAnB,KAA8BA,KAAK,IAAID,eADlB;AAE3B,OAAK,CAAEA,eAAF,EAAmBC,KAAnB,KAA8BA,KAAK,GAAGD;AAFhB,CAA5B;AAKA,MAAME,yBAAyB,GAAG;AACjC;AAA+B,IADE,CAAlC;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,gBAAgB,GAAG,CAAEC,UAAF,EAAcC,QAAQ,GAAG,IAAzB,KAAmC;AAC3D,QAAMC,cAAc,GAAG,yBAAYJ,yBAAZ,CAAvB;AACA,QAAMK,UAAU,GACf,CAAED,cAAF,IACC,IAAIR,UAAU,CAAEO,QAAF,CAAc,KAAKd,WAAW,CAAEa,UAAF,CAAgB,KAF9D;AAGA,QAAMI,gBAAgB,GAAG,4BAAeD,UAAU,IAAIE,SAA7B,CAAzB;;AACA,MAAKH,cAAL,EAAsB;AACrB,WAAOP,mBAAmB,CAAEM,QAAF,CAAnB,CACNd,WAAW,CAAEa,UAAF,CADL,EAENE,cAFM,CAAP;AAIA;;AACD,SAAOE,gBAAP;AACA,CAbD;;AAeAL,gBAAgB,CAACO,2BAAjB,GACCR,yBAAyB,CAACS,QAD3B;eAGeR,gB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useMediaQuery from '../use-media-query';\n\n/**\n * @typedef {\"huge\" | \"wide\" | \"large\" | \"medium\" | \"small\" | \"mobile\"} WPBreakpoint\n */\n\n/**\n * Hash of breakpoint names with pixel width at which it becomes effective.\n *\n * @see _breakpoints.scss\n *\n * @type {Record<WPBreakpoint, number>}\n */\nconst BREAKPOINTS = {\n\thuge: 1440,\n\twide: 1280,\n\tlarge: 960,\n\tmedium: 782,\n\tsmall: 600,\n\tmobile: 480,\n};\n\n/**\n * @typedef {\">=\" | \"<\"} WPViewportOperator\n */\n\n/**\n * Object mapping media query operators to the condition to be used.\n *\n * @type {Record<WPViewportOperator, string>}\n */\nconst CONDITIONS = {\n\t'>=': 'min-width',\n\t'<': 'max-width',\n};\n\n/**\n * Object mapping media query operators to a function that given a breakpointValue and a width evaluates if the operator matches the values.\n *\n * @type {Record<WPViewportOperator, (breakpointValue: number, width: number) => boolean>}\n */\nconst OPERATOR_EVALUATORS = {\n\t'>=': ( breakpointValue, width ) => width >= breakpointValue,\n\t'<': ( breakpointValue, width ) => width < breakpointValue,\n};\n\nconst ViewportMatchWidthContext = createContext(\n\t/** @type {null | number} */ ( null )\n);\n\n/**\n * Returns true if the viewport matches the given query, or false otherwise.\n *\n * @param {WPBreakpoint} breakpoint Breakpoint size name.\n * @param {WPViewportOperator} [operator=\">=\"] Viewport operator.\n *\n * @example\n *\n * ```js\n * useViewportMatch( 'huge', '<' );\n * useViewportMatch( 'medium' );\n * ```\n *\n * @return {boolean} Whether viewport matches query.\n */\nconst useViewportMatch = ( breakpoint, operator = '>=' ) => {\n\tconst simulatedWidth = useContext( ViewportMatchWidthContext );\n\tconst mediaQuery =\n\t\t! simulatedWidth &&\n\t\t`(${ CONDITIONS[ operator ] }: ${ BREAKPOINTS[ breakpoint ] }px)`;\n\tconst mediaQueryResult = useMediaQuery( mediaQuery || undefined );\n\tif ( simulatedWidth ) {\n\t\treturn OPERATOR_EVALUATORS[ operator ](\n\t\t\tBREAKPOINTS[ breakpoint ],\n\t\t\tsimulatedWidth\n\t\t);\n\t}\n\treturn mediaQueryResult;\n};\n\nuseViewportMatch.__experimentalWidthProvider =\n\tViewportMatchWidthContext.Provider;\n\nexport default useViewportMatch;\n"]}
@@ -35,12 +35,9 @@ var _usePrevious = _interopRequireDefault(require("../use-previous"));
35
35
  * @param {object} object Object which changes to compare.
36
36
  * @param {string} prefix Just a prefix to show when console logging.
37
37
  */
38
- function useWarnOnChange(object) {
39
- let prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Change detection';
38
+ function useWarnOnChange(object, prefix = 'Change detection') {
40
39
  const previousValues = (0, _usePrevious.default)(object);
41
- Object.entries(previousValues !== null && previousValues !== void 0 ? previousValues : []).forEach(_ref => {
42
- let [key, value] = _ref;
43
-
40
+ Object.entries(previousValues !== null && previousValues !== void 0 ? previousValues : []).forEach(([key, value]) => {
44
41
  if (value !== object[
45
42
  /** @type {keyof typeof object} */
46
43
  key]) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-warn-on-change/index.js"],"names":["useWarnOnChange","object","prefix","previousValues","Object","entries","forEach","key","value","console","warn"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGA;AACA;;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,eAAT,CAA0BC,MAA1B,EAAgE;AAAA,MAA9BC,MAA8B,uEAArB,kBAAqB;AAC/D,QAAMC,cAAc,GAAG,0BAAaF,MAAb,CAAvB;AAEAG,EAAAA,MAAM,CAACC,OAAP,CAAgBF,cAAhB,aAAgBA,cAAhB,cAAgBA,cAAhB,GAAkC,EAAlC,EAAuCG,OAAvC,CAAgD,QAAsB;AAAA,QAApB,CAAEC,GAAF,EAAOC,KAAP,CAAoB;;AACrE,QAAKA,KAAK,KAAKP,MAAM;AAAE;AAAqCM,IAAAA,GAAvC,CAArB,EAAsE;AACrE;AACAE,MAAAA,OAAO,CAACC,IAAR,CACE,GAAGR,MAAQ,KAAKK,GAAK,eADvB,EAECC,KAFD,EAGCP,MAAM;AAAE;AAAqCM,MAAAA,GAAvC;AACN;AAJD;AAMA;AACD,GAVD;AAWA;;eAEcP,e","sourcesContent":["/**\n * Internal dependencies\n */\nimport usePrevious from '../use-previous';\n\n// Disable reason: Object and object are distinctly different types in TypeScript and we mean the lowercase object in thise case\n// but eslint wants to force us to use `Object`. See https://stackoverflow.com/questions/49464634/difference-between-object-and-object-in-typescript\n/* eslint-disable jsdoc/check-types */\n/**\n * Hook that performs a shallow comparison between the preview value of an object\n * and the new one, if there's a difference, it prints it to the console.\n * this is useful in performance related work, to check why a component re-renders.\n *\n * @example\n *\n * ```jsx\n * function MyComponent(props) {\n * useWarnOnChange(props);\n *\n * return \"Something\";\n * }\n * ```\n *\n * @param {object} object Object which changes to compare.\n * @param {string} prefix Just a prefix to show when console logging.\n */\nfunction useWarnOnChange( object, prefix = 'Change detection' ) {\n\tconst previousValues = usePrevious( object );\n\n\tObject.entries( previousValues ?? [] ).forEach( ( [ key, value ] ) => {\n\t\tif ( value !== object[ /** @type {keyof typeof object} */ ( key ) ] ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t`${ prefix }: ${ key } key changed:`,\n\t\t\t\tvalue,\n\t\t\t\tobject[ /** @type {keyof typeof object} */ ( key ) ]\n\t\t\t\t/* eslint-enable jsdoc/check-types */\n\t\t\t);\n\t\t}\n\t} );\n}\n\nexport default useWarnOnChange;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-warn-on-change/index.js"],"names":["useWarnOnChange","object","prefix","previousValues","Object","entries","forEach","key","value","console","warn"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;AAGA;AACA;;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,eAAT,CAA0BC,MAA1B,EAAkCC,MAAM,GAAG,kBAA3C,EAAgE;AAC/D,QAAMC,cAAc,GAAG,0BAAaF,MAAb,CAAvB;AAEAG,EAAAA,MAAM,CAACC,OAAP,CAAgBF,cAAhB,aAAgBA,cAAhB,cAAgBA,cAAhB,GAAkC,EAAlC,EAAuCG,OAAvC,CAAgD,CAAE,CAAEC,GAAF,EAAOC,KAAP,CAAF,KAAsB;AACrE,QAAKA,KAAK,KAAKP,MAAM;AAAE;AAAqCM,IAAAA,GAAvC,CAArB,EAAsE;AACrE;AACAE,MAAAA,OAAO,CAACC,IAAR,CACE,GAAGR,MAAQ,KAAKK,GAAK,eADvB,EAECC,KAFD,EAGCP,MAAM;AAAE;AAAqCM,MAAAA,GAAvC;AACN;AAJD;AAMA;AACD,GAVD;AAWA;;eAEcP,e","sourcesContent":["/**\n * Internal dependencies\n */\nimport usePrevious from '../use-previous';\n\n// Disable reason: Object and object are distinctly different types in TypeScript and we mean the lowercase object in thise case\n// but eslint wants to force us to use `Object`. See https://stackoverflow.com/questions/49464634/difference-between-object-and-object-in-typescript\n/* eslint-disable jsdoc/check-types */\n/**\n * Hook that performs a shallow comparison between the preview value of an object\n * and the new one, if there's a difference, it prints it to the console.\n * this is useful in performance related work, to check why a component re-renders.\n *\n * @example\n *\n * ```jsx\n * function MyComponent(props) {\n * useWarnOnChange(props);\n *\n * return \"Something\";\n * }\n * ```\n *\n * @param {object} object Object which changes to compare.\n * @param {string} prefix Just a prefix to show when console logging.\n */\nfunction useWarnOnChange( object, prefix = 'Change detection' ) {\n\tconst previousValues = usePrevious( object );\n\n\tObject.entries( previousValues ?? [] ).forEach( ( [ key, value ] ) => {\n\t\tif ( value !== object[ /** @type {keyof typeof object} */ ( key ) ] ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.warn(\n\t\t\t\t`${ prefix }: ${ key } key changed:`,\n\t\t\t\tvalue,\n\t\t\t\tobject[ /** @type {keyof typeof object} */ ( key ) ]\n\t\t\t\t/* eslint-enable jsdoc/check-types */\n\t\t\t);\n\t\t}\n\t} );\n}\n\nexport default useWarnOnChange;\n"]}
@@ -189,14 +189,9 @@ const debounce = (func, wait, options) => {
189
189
  return timerId !== undefined;
190
190
  }
191
191
 
192
- function debounced() {
192
+ function debounced(...args) {
193
193
  const time = Date.now();
194
194
  const isInvoking = shouldInvoke(time);
195
-
196
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
197
- args[_key] = arguments[_key];
198
- }
199
-
200
195
  lastArgs = args;
201
196
  lastThis = this;
202
197
  lastCallTime = time;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/utils/debounce/index.ts"],"names":["debounce","func","wait","options","lastArgs","lastThis","maxWait","result","timerId","lastCallTime","lastInvokeTime","leading","maxing","trailing","undefined","Math","max","invokeFunc","time","args","thisArg","apply","startTimer","pendingFunc","waitTime","setTimeout","cancelTimer","clearTimeout","leadingEdge","timerExpired","getTimeSinceLastCall","remainingWait","timeSinceLastCall","timeSinceLastInvoke","timeWaiting","min","shouldInvoke","Date","now","trailingEdge","clearTimer","cancel","flush","pending","debounced","isInvoking"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,GAAG,CACvBC,IADuB,EAEvBC,IAFuB,EAGvBC,OAHuB,KAInB;AACJ,MAAIC,QAAJ;AACA,MAAIC,QAAJ;AACA,MAAIC,OAAO,GAAG,CAAd;AACA,M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AAP;AACA;;AACDqC,EAAAA,SAAS,CAACH,MAAV,GAAmBA,MAAnB;AACAG,EAAAA,SAAS,CAACF,KAAV,GAAkBA,KAAlB;AACAE,EAAAA,SAAS,CAACD,OAAV,GAAoBA,OAApB;AACA,SAAOC,SAAP;AACA,CA7JM","sourcesContent":["/**\n * Parts of this source were derived and modified from lodash,\n * released under the MIT license.\n *\n * https://github.com/lodash/lodash\n *\n * Copyright JS Foundation and other contributors <https://js.foundation/>\n *\n * Based on Underscore.js, copyright Jeremy Ashkenas,\n * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>\n *\n * This software consists of voluntary contributions made by many\n * individuals. For exact contribution history, see the revision history\n * available at https://github.com/lodash/lodash\n *\n * The following license applies to all parts of this software except as\n * documented below:\n *\n * ====\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\nexport interface DebounceOptions {\n\tleading: boolean;\n\tmaxWait: number;\n\ttrailing: boolean;\n}\n\nexport interface DebouncedFunc< T extends ( ...args: any[] ) => any > {\n\t/**\n\t * Call the original function, but applying the debounce rules.\n\t *\n\t * If the debounced function can be run immediately, this calls it and returns its return\n\t * value.\n\t *\n\t * Otherwise, it returns the return value of the last invocation, or undefined if the debounced\n\t * function was not invoked yet.\n\t */\n\t( ...args: Parameters< T > ): ReturnType< T > | undefined;\n\n\t/**\n\t * Throw away any pending invocation of the debounced function.\n\t */\n\tcancel(): void;\n\n\t/**\n\t * If there is a pending invocation of the debounced function, invoke it immediately and return\n\t * its return value.\n\t *\n\t * Otherwise, return the value from the last invocation, or undefined if the debounced function\n\t * was never invoked.\n\t */\n\tflush(): ReturnType< T > | undefined;\n}\n\n/**\n * A simplified and properly typed version of lodash's `debounce`, that\n * always uses timers instead of sometimes using rAF.\n *\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel delayed\n * `func` invocations and a `flush` method to immediately invoke them. Provide\n * `options` to indicate whether `func` should be invoked on the leading and/or\n * trailing edge of the `wait` timeout. The `func` is invoked with the last\n * arguments provided to the debounced function. Subsequent calls to the debounced\n * function return the result of the last `func` invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * @param {Function} func The function to debounce.\n * @param {number} wait The number of milliseconds to delay.\n * @param {Partial< DebounceOptions >} options The options object.\n * @param {boolean} options.leading Specify invoking on the leading edge of the timeout.\n * @param {number} options.maxWait The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} options.trailing Specify invoking on the trailing edge of the timeout.\n *\n * @return Returns the new debounced function.\n */\nexport const debounce = < FunctionT extends ( ...args: unknown[] ) => unknown >(\n\tfunc: FunctionT,\n\twait: number,\n\toptions?: Partial< DebounceOptions >\n) => {\n\tlet lastArgs: Parameters< FunctionT > | undefined;\n\tlet lastThis: unknown | undefined;\n\tlet maxWait = 0;\n\tlet result: ReturnType< FunctionT >;\n\tlet timerId: ReturnType< typeof setTimeout > | undefined;\n\tlet lastCallTime: number | undefined;\n\n\tlet lastInvokeTime = 0;\n\tlet leading = false;\n\tlet maxing = false;\n\tlet trailing = true;\n\n\tif ( options ) {\n\t\tleading = !! options.leading;\n\t\tmaxing = 'maxWait' in options;\n\t\tif ( options.maxWait !== undefined ) {\n\t\t\tmaxWait = Math.max( options.maxWait, wait );\n\t\t}\n\t\ttrailing = 'trailing' in options ? !! options.trailing : trailing;\n\t}\n\n\tfunction invokeFunc( time: number ) {\n\t\tconst args = lastArgs;\n\t\tconst thisArg = lastThis;\n\n\t\tlastArgs = undefined;\n\t\tlastThis = undefined;\n\t\tlastInvokeTime = time;\n\n\t\tresult = func.apply( thisArg, args! ) as ReturnType< FunctionT >;\n\t\treturn result;\n\t}\n\n\tfunction startTimer(\n\t\tpendingFunc: () => void,\n\t\twaitTime: number | undefined\n\t) {\n\t\ttimerId = setTimeout( pendingFunc, waitTime );\n\t}\n\n\tfunction cancelTimer() {\n\t\tif ( timerId !== undefined ) {\n\t\t\tclearTimeout( timerId );\n\t\t}\n\t}\n\n\tfunction leadingEdge( time: number ) {\n\t\t// Reset any `maxWait` timer.\n\t\tlastInvokeTime = time;\n\t\t// Start the timer for the trailing edge.\n\t\tstartTimer( timerExpired, wait );\n\t\t// Invoke the leading edge.\n\t\treturn leading ? invokeFunc( time ) : result;\n\t}\n\n\tfunction getTimeSinceLastCall( time: number ) {\n\t\treturn time - ( lastCallTime || 0 );\n\t}\n\n\tfunction remainingWait( time: number ) {\n\t\tconst timeSinceLastCall = getTimeSinceLastCall( time );\n\t\tconst timeSinceLastInvoke = time - lastInvokeTime;\n\t\tconst timeWaiting = wait - timeSinceLastCall;\n\n\t\treturn maxing\n\t\t\t? Math.min( timeWaiting, maxWait - timeSinceLastInvoke )\n\t\t\t: timeWaiting;\n\t}\n\n\tfunction shouldInvoke( time: number ) {\n\t\tconst timeSinceLastCall = getTimeSinceLastCall( time );\n\t\tconst timeSinceLastInvoke = time - lastInvokeTime;\n\n\t\t// Either this is the first call, activity has stopped and we're at the\n\t\t// trailing edge, the system time has gone backwards and we're treating\n\t\t// it as the trailing edge, or we've hit the `maxWait` limit.\n\t\treturn (\n\t\t\tlastCallTime === undefined ||\n\t\t\ttimeSinceLastCall >= wait ||\n\t\t\ttimeSinceLastCall < 0 ||\n\t\t\t( maxing && timeSinceLastInvoke >= maxWait )\n\t\t);\n\t}\n\n\tfunction timerExpired() {\n\t\tconst time = Date.now();\n\t\tif ( shouldInvoke( time ) ) {\n\t\t\treturn trailingEdge( time );\n\t\t}\n\t\t// Restart the timer.\n\t\tstartTimer( timerExpired, remainingWait( time ) );\n\t\treturn undefined;\n\t}\n\n\tfunction clearTimer() {\n\t\ttimerId = undefined;\n\t}\n\n\tfunction trailingEdge( time: number ) {\n\t\tclearTimer();\n\n\t\t// Only invoke if we have `lastArgs` which means `func` has been\n\t\t// debounced at least once.\n\t\tif ( trailing && lastArgs ) {\n\t\t\treturn invokeFunc( time );\n\t\t}\n\t\tlastArgs = lastThis = undefined;\n\t\treturn result;\n\t}\n\n\tfunction cancel() {\n\t\tcancelTimer();\n\t\tlastInvokeTime = 0;\n\t\tclearTimer();\n\t\tlastArgs = lastCallTime = lastThis = undefined;\n\t}\n\n\tfunction flush() {\n\t\treturn pending() ? trailingEdge( Date.now() ) : result;\n\t}\n\n\tfunction pending() {\n\t\treturn timerId !== undefined;\n\t}\n\n\tfunction debounced( this: unknown, ...args: Parameters< FunctionT > ) {\n\t\tconst time = Date.now();\n\t\tconst isInvoking = shouldInvoke( time );\n\n\t\tlastArgs = args;\n\t\tlastThis = this;\n\t\tlastCallTime = time;\n\n\t\tif ( isInvoking ) {\n\t\t\tif ( ! pending() ) {\n\t\t\t\treturn leadingEdge( lastCallTime );\n\t\t\t}\n\t\t\tif ( maxing ) {\n\t\t\t\t// Handle invocations in a tight loop.\n\t\t\t\tstartTimer( timerExpired, wait );\n\t\t\t\treturn invokeFunc( lastCallTime );\n\t\t\t}\n\t\t}\n\t\tif ( ! pending() ) {\n\t\t\tstartTimer( timerExpired, wait );\n\t\t}\n\t\treturn result;\n\t}\n\tdebounced.cancel = cancel;\n\tdebounced.flush = flush;\n\tdebounced.pending = pending;\n\treturn debounced;\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/utils/debounce/index.ts"],"names":["debounce","func","wait","options","lastArgs","lastThis","maxWait","result","timerId","lastCallTime","lastInvokeTime","leading","maxing","trailing","undefined","Math","max","invokeFunc","time","args","thisArg","apply","startTimer","pendingFunc","waitTime","setTimeout","cancelTimer","clearTimeout","leadingEdge","timerExpired","getTimeSinceLastCall","remainingWait","timeSinceLastCall","timeSinceLastInvoke","timeWaiting","min","shouldInvoke","Date","now","trailingEdge","clearTimer","cancel","flush","pending","debounced","isInvoking"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,QAAQ,GAAG,CACvBC,IADuB,EAEvBC,IAFuB,EAGvBC,OAHuB,KAInB;AACJ,MAAIC,QAAJ;AACA,MAAIC,QAAJ;AACA,MAAIC,OAAO,GAAG,CAAd;AACA,MAAIC,MAAJ;AACA,MAAIC,OAAJ;AACA,MAAIC,YAAJ;AAEA,MAAIC,cAAc,GAAG,CAArB;AACA,MAAIC,OAAO,GAAG,KAAd;AACA,MAAIC,MAAM,GAAG,KAAb;AACA,MAAIC,QAAQ,GAAG,I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were derived and modified from lodash,\n * released under the MIT license.\n *\n * https://github.com/lodash/lodash\n *\n * Copyright JS Foundation and other contributors <https://js.foundation/>\n *\n * Based on Underscore.js, copyright Jeremy Ashkenas,\n * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>\n *\n * This software consists of voluntary contributions made by many\n * individuals. For exact contribution history, see the revision history\n * available at https://github.com/lodash/lodash\n *\n * The following license applies to all parts of this software except as\n * documented below:\n *\n * ====\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\nexport interface DebounceOptions {\n\tleading: boolean;\n\tmaxWait: number;\n\ttrailing: boolean;\n}\n\nexport interface DebouncedFunc< T extends ( ...args: any[] ) => any > {\n\t/**\n\t * Call the original function, but applying the debounce rules.\n\t *\n\t * If the debounced function can be run immediately, this calls it and returns its return\n\t * value.\n\t *\n\t * Otherwise, it returns the return value of the last invocation, or undefined if the debounced\n\t * function was not invoked yet.\n\t */\n\t( ...args: Parameters< T > ): ReturnType< T > | undefined;\n\n\t/**\n\t * Throw away any pending invocation of the debounced function.\n\t */\n\tcancel(): void;\n\n\t/**\n\t * If there is a pending invocation of the debounced function, invoke it immediately and return\n\t * its return value.\n\t *\n\t * Otherwise, return the value from the last invocation, or undefined if the debounced function\n\t * was never invoked.\n\t */\n\tflush(): ReturnType< T > | undefined;\n}\n\n/**\n * A simplified and properly typed version of lodash's `debounce`, that\n * always uses timers instead of sometimes using rAF.\n *\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel delayed\n * `func` invocations and a `flush` method to immediately invoke them. Provide\n * `options` to indicate whether `func` should be invoked on the leading and/or\n * trailing edge of the `wait` timeout. The `func` is invoked with the last\n * arguments provided to the debounced function. Subsequent calls to the debounced\n * function return the result of the last `func` invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * @param {Function} func The function to debounce.\n * @param {number} wait The number of milliseconds to delay.\n * @param {Partial< DebounceOptions >} options The options object.\n * @param {boolean} options.leading Specify invoking on the leading edge of the timeout.\n * @param {number} options.maxWait The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} options.trailing Specify invoking on the trailing edge of the timeout.\n *\n * @return Returns the new debounced function.\n */\nexport const debounce = < FunctionT extends ( ...args: unknown[] ) => unknown >(\n\tfunc: FunctionT,\n\twait: number,\n\toptions?: Partial< DebounceOptions >\n) => {\n\tlet lastArgs: Parameters< FunctionT > | undefined;\n\tlet lastThis: unknown | undefined;\n\tlet maxWait = 0;\n\tlet result: ReturnType< FunctionT >;\n\tlet timerId: ReturnType< typeof setTimeout > | undefined;\n\tlet lastCallTime: number | undefined;\n\n\tlet lastInvokeTime = 0;\n\tlet leading = false;\n\tlet maxing = false;\n\tlet trailing = true;\n\n\tif ( options ) {\n\t\tleading = !! options.leading;\n\t\tmaxing = 'maxWait' in options;\n\t\tif ( options.maxWait !== undefined ) {\n\t\t\tmaxWait = Math.max( options.maxWait, wait );\n\t\t}\n\t\ttrailing = 'trailing' in options ? !! options.trailing : trailing;\n\t}\n\n\tfunction invokeFunc( time: number ) {\n\t\tconst args = lastArgs;\n\t\tconst thisArg = lastThis;\n\n\t\tlastArgs = undefined;\n\t\tlastThis = undefined;\n\t\tlastInvokeTime = time;\n\n\t\tresult = func.apply( thisArg, args! ) as ReturnType< FunctionT >;\n\t\treturn result;\n\t}\n\n\tfunction startTimer(\n\t\tpendingFunc: () => void,\n\t\twaitTime: number | undefined\n\t) {\n\t\ttimerId = setTimeout( pendingFunc, waitTime );\n\t}\n\n\tfunction cancelTimer() {\n\t\tif ( timerId !== undefined ) {\n\t\t\tclearTimeout( timerId );\n\t\t}\n\t}\n\n\tfunction leadingEdge( time: number ) {\n\t\t// Reset any `maxWait` timer.\n\t\tlastInvokeTime = time;\n\t\t// Start the timer for the trailing edge.\n\t\tstartTimer( timerExpired, wait );\n\t\t// Invoke the leading edge.\n\t\treturn leading ? invokeFunc( time ) : result;\n\t}\n\n\tfunction getTimeSinceLastCall( time: number ) {\n\t\treturn time - ( lastCallTime || 0 );\n\t}\n\n\tfunction remainingWait( time: number ) {\n\t\tconst timeSinceLastCall = getTimeSinceLastCall( time );\n\t\tconst timeSinceLastInvoke = time - lastInvokeTime;\n\t\tconst timeWaiting = wait - timeSinceLastCall;\n\n\t\treturn maxing\n\t\t\t? Math.min( timeWaiting, maxWait - timeSinceLastInvoke )\n\t\t\t: timeWaiting;\n\t}\n\n\tfunction shouldInvoke( time: number ) {\n\t\tconst timeSinceLastCall = getTimeSinceLastCall( time );\n\t\tconst timeSinceLastInvoke = time - lastInvokeTime;\n\n\t\t// Either this is the first call, activity has stopped and we're at the\n\t\t// trailing edge, the system time has gone backwards and we're treating\n\t\t// it as the trailing edge, or we've hit the `maxWait` limit.\n\t\treturn (\n\t\t\tlastCallTime === undefined ||\n\t\t\ttimeSinceLastCall >= wait ||\n\t\t\ttimeSinceLastCall < 0 ||\n\t\t\t( maxing && timeSinceLastInvoke >= maxWait )\n\t\t);\n\t}\n\n\tfunction timerExpired() {\n\t\tconst time = Date.now();\n\t\tif ( shouldInvoke( time ) ) {\n\t\t\treturn trailingEdge( time );\n\t\t}\n\t\t// Restart the timer.\n\t\tstartTimer( timerExpired, remainingWait( time ) );\n\t\treturn undefined;\n\t}\n\n\tfunction clearTimer() {\n\t\ttimerId = undefined;\n\t}\n\n\tfunction trailingEdge( time: number ) {\n\t\tclearTimer();\n\n\t\t// Only invoke if we have `lastArgs` which means `func` has been\n\t\t// debounced at least once.\n\t\tif ( trailing && lastArgs ) {\n\t\t\treturn invokeFunc( time );\n\t\t}\n\t\tlastArgs = lastThis = undefined;\n\t\treturn result;\n\t}\n\n\tfunction cancel() {\n\t\tcancelTimer();\n\t\tlastInvokeTime = 0;\n\t\tclearTimer();\n\t\tlastArgs = lastCallTime = lastThis = undefined;\n\t}\n\n\tfunction flush() {\n\t\treturn pending() ? trailingEdge( Date.now() ) : result;\n\t}\n\n\tfunction pending() {\n\t\treturn timerId !== undefined;\n\t}\n\n\tfunction debounced( this: unknown, ...args: Parameters< FunctionT > ) {\n\t\tconst time = Date.now();\n\t\tconst isInvoking = shouldInvoke( time );\n\n\t\tlastArgs = args;\n\t\tlastThis = this;\n\t\tlastCallTime = time;\n\n\t\tif ( isInvoking ) {\n\t\t\tif ( ! pending() ) {\n\t\t\t\treturn leadingEdge( lastCallTime );\n\t\t\t}\n\t\t\tif ( maxing ) {\n\t\t\t\t// Handle invocations in a tight loop.\n\t\t\t\tstartTimer( timerExpired, wait );\n\t\t\t\treturn invokeFunc( lastCallTime );\n\t\t\t}\n\t\t}\n\t\tif ( ! pending() ) {\n\t\t\tstartTimer( timerExpired, wait );\n\t\t}\n\t\treturn result;\n\t}\n\tdebounced.cancel = cancel;\n\tdebounced.flush = flush;\n\tdebounced.pending = pending;\n\treturn debounced;\n};\n"]}
@@ -47,27 +47,14 @@
47
47
  *
48
48
  * @param {boolean} reverse True if right-to-left, false for left-to-right composition.
49
49
  */
50
- const basePipe = function () {
51
- let reverse = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
52
- return function () {
53
- for (var _len = arguments.length, funcs = new Array(_len), _key = 0; _key < _len; _key++) {
54
- funcs[_key] = arguments[_key];
55
- }
50
+ const basePipe = (reverse = false) => (...funcs) => (...args) => {
51
+ const functions = funcs.flat();
56
52
 
57
- return function () {
58
- const functions = funcs.flat();
53
+ if (reverse) {
54
+ functions.reverse();
55
+ }
59
56
 
60
- if (reverse) {
61
- functions.reverse();
62
- }
63
-
64
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
65
- args[_key2] = arguments[_key2];
66
- }
67
-
68
- return functions.reduce((prev, func) => [func(...prev)], args)[0];
69
- };
70
- };
57
+ return functions.reduce((prev, func) => [func(...prev)], args)[0];
71
58
  };
72
59
  /**
73
60
  * Composes multiple higher-order components into a single higher-order component. Performs left-to-right function
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/pipe.ts"],"names":["basePipe","reverse","funcs","functions","flat","args","reduce","prev","func","pipe"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,QAAQ,GACb;AAAA,MAAEC,OAAF,uEAAqB,KAArB;AAAA,SACA;AAAA,sCAAKC,KAAL;AAAKA,MAAAA,KAAL;AAAA;;AAAA,WACA,YAA0B;AACzB,YAAMC,SAAS,GAAGD,KAAK,CAACE,IAAN,EAAlB;;AACA,UAAKH,OAAL,EAAe;AACdE,QAAAA,SAAS,CAACF,OAAV;AACA;;AAJwB,yCAArBI,IAAqB;AAArBA,QAAAA,IAAqB;AAAA;;AAKzB,aAAOF,SAAS,CAACG,MAAV,CACN,CAAEC,IAAF,EAAQC,IAAR,KAAkB,CAAEA,IAAI,CAAE,GAAGD,IAAL,CAAN,CADZ,EAENF,IAFM,EAGJ,CAHI,CAAP;AAIA,KAVD;AAAA,GADA;AAAA,CADD;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMI,IAAI,GAAGT,QAAQ,EAArB;AAEA,SAASA,QAAT;AAEA,eAAeS,IAAf","sourcesContent":["/**\n * Parts of this source were derived and modified from lodash,\n * released under the MIT license.\n *\n * https://github.com/lodash/lodash\n *\n * Copyright JS Foundation and other contributors <https://js.foundation/>\n *\n * Based on Underscore.js, copyright Jeremy Ashkenas,\n * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>\n *\n * This software consists of voluntary contributions made by many\n * individuals. For exact contribution history, see the revision history\n * available at https://github.com/lodash/lodash\n *\n * The following license applies to all parts of this software except as\n * documented below:\n *\n * ====\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Creates a pipe function.\n *\n * Allows to choose whether to perform left-to-right or right-to-left composition.\n *\n * @see https://docs-lodash.com/v4/flow/\n *\n * @param {boolean} reverse True if right-to-left, false for left-to-right composition.\n */\nconst basePipe =\n\t( reverse: boolean = false ) =>\n\t( ...funcs: Function[] ) =>\n\t( ...args: unknown[] ) => {\n\t\tconst functions = funcs.flat();\n\t\tif ( reverse ) {\n\t\t\tfunctions.reverse();\n\t\t}\n\t\treturn functions.reduce(\n\t\t\t( prev, func ) => [ func( ...prev ) ],\n\t\t\targs\n\t\t)[ 0 ];\n\t};\n\n/**\n * Composes multiple higher-order components into a single higher-order component. Performs left-to-right function\n * composition, where each successive invocation is supplied the return value of the previous.\n *\n * This is inspired by `lodash`'s `flow` function.\n *\n * @see https://docs-lodash.com/v4/flow/\n */\nconst pipe = basePipe();\n\nexport { basePipe };\n\nexport default pipe;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/pipe.ts"],"names":["basePipe","reverse","funcs","args","functions","flat","reduce","prev","func","pipe"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,QAAQ,GACb,CAAEC,OAAgB,GAAG,KAArB,KACA,CAAE,GAAGC,KAAL,KACA,CAAE,GAAGC,IAAL,KAA0B;AACzB,QAAMC,SAAS,GAAGF,KAAK,CAACG,IAAN,EAAlB;;AACA,MAAKJ,OAAL,EAAe;AACdG,IAAAA,SAAS,CAACH,OAAV;AACA;;AACD,SAAOG,SAAS,CAACE,MAAV,CACN,CAAEC,IAAF,EAAQC,IAAR,KAAkB,CAAEA,IAAI,CAAE,GAAGD,IAAL,CAAN,CADZ,EAENJ,IAFM,EAGJ,CAHI,CAAP;AAIA,CAZF;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMM,IAAI,GAAGT,QAAQ,EAArB;AAEA,SAASA,QAAT;AAEA,eAAeS,IAAf","sourcesContent":["/**\n * Parts of this source were derived and modified from lodash,\n * released under the MIT license.\n *\n * https://github.com/lodash/lodash\n *\n * Copyright JS Foundation and other contributors <https://js.foundation/>\n *\n * Based on Underscore.js, copyright Jeremy Ashkenas,\n * DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>\n *\n * This software consists of voluntary contributions made by many\n * individuals. For exact contribution history, see the revision history\n * available at https://github.com/lodash/lodash\n *\n * The following license applies to all parts of this software except as\n * documented below:\n *\n * ====\n *\n * Permission is hereby granted, free of charge, to any person obtaining\n * a copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\n * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/**\n * Creates a pipe function.\n *\n * Allows to choose whether to perform left-to-right or right-to-left composition.\n *\n * @see https://docs-lodash.com/v4/flow/\n *\n * @param {boolean} reverse True if right-to-left, false for left-to-right composition.\n */\nconst basePipe =\n\t( reverse: boolean = false ) =>\n\t( ...funcs: Function[] ) =>\n\t( ...args: unknown[] ) => {\n\t\tconst functions = funcs.flat();\n\t\tif ( reverse ) {\n\t\t\tfunctions.reverse();\n\t\t}\n\t\treturn functions.reduce(\n\t\t\t( prev, func ) => [ func( ...prev ) ],\n\t\t\targs\n\t\t)[ 0 ];\n\t};\n\n/**\n * Composes multiple higher-order components into a single higher-order component. Performs left-to-right function\n * composition, where each successive invocation is supplied the return value of the previous.\n *\n * This is inspired by `lodash`'s `flow` function.\n *\n * @see https://docs-lodash.com/v4/flow/\n */\nconst pipe = basePipe();\n\nexport { basePipe };\n\nexport default pipe;\n"]}
@@ -47,9 +47,7 @@ class Listener {
47
47
  handleEvent(
48
48
  /** @type {any} */
49
49
  event) {
50
- var _this$listeners$event;
51
-
52
- (_this$listeners$event = this.listeners[event.type]) === null || _this$listeners$event === void 0 ? void 0 : _this$listeners$event.forEach((
50
+ this.listeners[event.type]?.forEach((
53
51
  /** @type {any} */
54
52
  instance) => {
55
53
  instance.handleEvent(event);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/higher-order/with-global-events/listener.js"],"names":["Listener","constructor","listeners","handleEvent","bind","add","eventType","instance","window","addEventListener","push","remove","filter","listener","length","removeEventListener","event","type","forEach"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,MAAMA,QAAN,CAAe;AACdC,EAAAA,WAAW,GAAG;AACb;AACA,SAAKC,SAAL,GAAiB,EAAjB;AAEA,SAAKC,WAAL,GAAmB,KAAKA,WAAL,CAAiBC,IAAjB,CAAuB,IAAvB,CAAnB;AACA;;AAEDC,EAAAA,GAAG;AAAE;AAAmBC,EAAAA,SAArB;AAAgC;AAAmBC,EAAAA,QAAnD,EAA8D;AAChE,QAAK,CAAE,KAAKL,SAAL,CAAgBI,SAAhB,CAAP,EAAqC;AACpC;AACAE,MAAAA,MAAM,CAACC,gBAAP,CAAyBH,SAAzB,EAAoC,KAAKH,WAAzC;AACA,WAAKD,SAAL,CAAgBI,SAAhB,IAA8B,EAA9B;AACA;;AAED,SAAKJ,SAAL,CAAgBI,SAAhB,EAA4BI,IAA5B,CAAkCH,QAAlC;AACA;;AAEDI,EAAAA,MAAM;AAAE;AAAmBL,EAAAA,SAArB;AAAgC;AAAmBC,EAAAA,QAAnD,EAA8D;AACnE,QAAK,CAAE,KAAKL,SAAL,CAAgBI,SAAhB,CAAP,EAAqC;AACpC;AACA;;AAED,SAAKJ,SAAL,CAAgBI,SAAhB,IAA8B,KAAKJ,SAAL,CAAgBI,SAAhB,EAA4BM,MAA5B,CAC7B;AAAE;AAAmBC,IAAAA,QAArB,KAAmCA,QAAQ,KAAKN,QADnB,CAA9B;;AAIA,QAAK,CAAE,KAAKL,SAAL,CAAgBI,SAAhB,EAA4BQ,MAAnC,EAA4C;AAC3C;AACAN,MAAAA,MAAM,CAACO,mBAAP,CAA4BT,SAA5B,EAAuC,KAAKH,WAA5C;AACA,aAAO,KAAKD,SAAL,CAAgBI,SAAhB,CAAP;AACA;AACD;;AAEDH,EAAAA,WAAW;AAAE;AAAmBa,EAAAA,KAArB,EAA6B;AAAA;;AACvC,kCAAKd,SAAL,CAAgBc,KAAK,CAACC,IAAtB,iFAA8BC,OAA9B,CACC;AAAE;AAAmBX,IAAAA,QAArB,KAAmC;AAClCA,MAAAA,QAAQ,CAACJ,WAAT,CAAsBa,KAAtB;AACA,KAHF;AAKA;;AAxCa;;AA2Cf,eAAehB,QAAf","sourcesContent":["/**\n * Class responsible for orchestrating event handling on the global window,\n * binding a single event to be shared across all handling instances, and\n * removing the handler when no instances are listening for the event.\n */\nclass Listener {\n\tconstructor() {\n\t\t/** @type {any} */\n\t\tthis.listeners = {};\n\n\t\tthis.handleEvent = this.handleEvent.bind( this );\n\t}\n\n\tadd( /** @type {any} */ eventType, /** @type {any} */ instance ) {\n\t\tif ( ! this.listeners[ eventType ] ) {\n\t\t\t// Adding first listener for this type, so bind event.\n\t\t\twindow.addEventListener( eventType, this.handleEvent );\n\t\t\tthis.listeners[ eventType ] = [];\n\t\t}\n\n\t\tthis.listeners[ eventType ].push( instance );\n\t}\n\n\tremove( /** @type {any} */ eventType, /** @type {any} */ instance ) {\n\t\tif ( ! this.listeners[ eventType ] ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.listeners[ eventType ] = this.listeners[ eventType ].filter(\n\t\t\t( /** @type {any} */ listener ) => listener !== instance\n\t\t);\n\n\t\tif ( ! this.listeners[ eventType ].length ) {\n\t\t\t// Removing last listener for this type, so unbind event.\n\t\t\twindow.removeEventListener( eventType, this.handleEvent );\n\t\t\tdelete this.listeners[ eventType ];\n\t\t}\n\t}\n\n\thandleEvent( /** @type {any} */ event ) {\n\t\tthis.listeners[ event.type ]?.forEach(\n\t\t\t( /** @type {any} */ instance ) => {\n\t\t\t\tinstance.handleEvent( event );\n\t\t\t}\n\t\t);\n\t}\n}\n\nexport default Listener;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/higher-order/with-global-events/listener.js"],"names":["Listener","constructor","listeners","handleEvent","bind","add","eventType","instance","window","addEventListener","push","remove","filter","listener","length","removeEventListener","event","type","forEach"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA,MAAMA,QAAN,CAAe;AACdC,EAAAA,WAAW,GAAG;AACb;AACA,SAAKC,SAAL,GAAiB,EAAjB;AAEA,SAAKC,WAAL,GAAmB,KAAKA,WAAL,CAAiBC,IAAjB,CAAuB,IAAvB,CAAnB;AACA;;AAEDC,EAAAA,GAAG;AAAE;AAAmBC,EAAAA,SAArB;AAAgC;AAAmBC,EAAAA,QAAnD,EAA8D;AAChE,QAAK,CAAE,KAAKL,SAAL,CAAgBI,SAAhB,CAAP,EAAqC;AACpC;AACAE,MAAAA,MAAM,CAACC,gBAAP,CAAyBH,SAAzB,EAAoC,KAAKH,WAAzC;AACA,WAAKD,SAAL,CAAgBI,SAAhB,IAA8B,EAA9B;AACA;;AAED,SAAKJ,SAAL,CAAgBI,SAAhB,EAA4BI,IAA5B,CAAkCH,QAAlC;AACA;;AAEDI,EAAAA,MAAM;AAAE;AAAmBL,EAAAA,SAArB;AAAgC;AAAmBC,EAAAA,QAAnD,EAA8D;AACnE,QAAK,CAAE,KAAKL,SAAL,CAAgBI,SAAhB,CAAP,EAAqC;AACpC;AACA;;AAED,SAAKJ,SAAL,CAAgBI,SAAhB,IAA8B,KAAKJ,SAAL,CAAgBI,SAAhB,EAA4BM,MAA5B,CAC7B;AAAE;AAAmBC,IAAAA,QAArB,KAAmCA,QAAQ,KAAKN,QADnB,CAA9B;;AAIA,QAAK,CAAE,KAAKL,SAAL,CAAgBI,SAAhB,EAA4BQ,MAAnC,EAA4C;AAC3C;AACAN,MAAAA,MAAM,CAACO,mBAAP,CAA4BT,SAA5B,EAAuC,KAAKH,WAA5C;AACA,aAAO,KAAKD,SAAL,CAAgBI,SAAhB,CAAP;AACA;AACD;;AAEDH,EAAAA,WAAW;AAAE;AAAmBa,EAAAA,KAArB,EAA6B;AACvC,SAAKd,SAAL,CAAgBc,KAAK,CAACC,IAAtB,GAA8BC,OAA9B,CACC;AAAE;AAAmBX,IAAAA,QAArB,KAAmC;AAClCA,MAAAA,QAAQ,CAACJ,WAAT,CAAsBa,KAAtB;AACA,KAHF;AAKA;;AAxCa;;AA2Cf,eAAehB,QAAf","sourcesContent":["/**\n * Class responsible for orchestrating event handling on the global window,\n * binding a single event to be shared across all handling instances, and\n * removing the handler when no instances are listening for the event.\n */\nclass Listener {\n\tconstructor() {\n\t\t/** @type {any} */\n\t\tthis.listeners = {};\n\n\t\tthis.handleEvent = this.handleEvent.bind( this );\n\t}\n\n\tadd( /** @type {any} */ eventType, /** @type {any} */ instance ) {\n\t\tif ( ! this.listeners[ eventType ] ) {\n\t\t\t// Adding first listener for this type, so bind event.\n\t\t\twindow.addEventListener( eventType, this.handleEvent );\n\t\t\tthis.listeners[ eventType ] = [];\n\t\t}\n\n\t\tthis.listeners[ eventType ].push( instance );\n\t}\n\n\tremove( /** @type {any} */ eventType, /** @type {any} */ instance ) {\n\t\tif ( ! this.listeners[ eventType ] ) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.listeners[ eventType ] = this.listeners[ eventType ].filter(\n\t\t\t( /** @type {any} */ listener ) => listener !== instance\n\t\t);\n\n\t\tif ( ! this.listeners[ eventType ].length ) {\n\t\t\t// Removing last listener for this type, so unbind event.\n\t\t\twindow.removeEventListener( eventType, this.handleEvent );\n\t\t\tdelete this.listeners[ eventType ];\n\t\t}\n\t}\n\n\thandleEvent( /** @type {any} */ event ) {\n\t\tthis.listeners[ event.type ]?.forEach(\n\t\t\t( /** @type {any} */ instance ) => {\n\t\t\t\tinstance.handleEvent( event );\n\t\t\t}\n\t\t);\n\t}\n}\n\nexport default Listener;\n"]}
@@ -22,8 +22,7 @@ import { createHigherOrderComponent } from '../../utils/create-higher-order-comp
22
22
  * @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.
23
23
  */
24
24
 
25
- export default function withState() {
26
- let initialState = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
25
+ export default function withState(initialState = {}) {
27
26
  deprecated('wp.compose.withState', {
28
27
  since: '5.8',
29
28
  alternative: 'wp.element.useState'
@@ -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,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
+ {"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,CAAoBC,YAAY,GAAG,EAAnC,EAAwC;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"]}
@@ -37,10 +37,9 @@ function getFirstItemsPresentInState(list, state) {
37
37
  */
38
38
 
39
39
 
40
- function useAsyncList(list) {
41
- let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
42
- step: 1
43
- };
40
+ function useAsyncList(list, config = {
41
+ step: 1
42
+ }) {
44
43
  const {
45
44
  step = 1
46
45
  } = config;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-async-list/index.ts"],"names":["flushSync","useEffect","useState","createQueue","getFirstItemsPresentInState","list","state","firstItems","i","length","item","includes","push","useAsyncList","config","step","current","setCurrent","concat","slice","asyncQueue","add","reset"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,SAApB,EAA+BC,QAA/B,QAA+C,oBAA/C;AACA,SAASC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A8D;AAC7DK,MAAAA,UAAU,CAACC,GAAX,CAAgB,EAAhB,EAAoB,MAAM;AACzBrB,QAAAA,SAAS,CAAE,MAAM;AAChBiB,UAAAA,UAAU,CAAIX,KAAF,IAAa,CACxB,GAAGA,KADqB,EAExB,GAAGD,IAAI,CAACc,KAAL,CAAYX,CAAZ,EAAeA,CAAC,GAAGO,IAAnB,CAFqB,CAAf,CAAV;AAIA,SALQ,CAAT;AAMA,OAPD;AAQA;;AAED,WAAO,MAAMK,UAAU,CAACE,KAAX,EAAb;AACA,GAvBQ,EAuBN,CAAEjB,IAAF,CAvBM,CAAT;AAyBA,SAAOW,OAAP;AACA;;AAED,eAAeH,YAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { flushSync, useEffect, useState } from '@wordpress/element';\nimport { createQueue } from '@wordpress/priority-queue';\n\ntype AsyncListConfig = {\n\tstep: number;\n};\n\n/**\n * Returns the first items from list that are present on state.\n *\n * @param list New array.\n * @param state Current state.\n * @return First items present iin state.\n */\nfunction getFirstItemsPresentInState< T >( list: T[], state: T[] ): T[] {\n\tconst firstItems = [];\n\n\tfor ( let i = 0; i < list.length; i++ ) {\n\t\tconst item = list[ i ];\n\t\tif ( ! state.includes( item ) ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tfirstItems.push( item );\n\t}\n\n\treturn firstItems;\n}\n\n/**\n * React hook returns an array which items get asynchronously appended from a source array.\n * This behavior is useful if we want to render a list of items asynchronously for performance reasons.\n *\n * @param list Source array.\n * @param config Configuration object.\n *\n * @return Async array.\n */\nfunction useAsyncList< T >(\n\tlist: T[],\n\tconfig: AsyncListConfig = { step: 1 }\n): T[] {\n\tconst { step = 1 } = config;\n\tconst [ current, setCurrent ] = useState< T[] >( [] );\n\n\tuseEffect( () => {\n\t\t// On reset, we keep the first items that were previously rendered.\n\t\tlet firstItems = getFirstItemsPresentInState( list, current );\n\t\tif ( firstItems.length < step ) {\n\t\t\tfirstItems = firstItems.concat(\n\t\t\t\tlist.slice( firstItems.length, step )\n\t\t\t);\n\t\t}\n\t\tsetCurrent( firstItems );\n\n\t\tconst asyncQueue = createQueue();\n\t\tfor ( let i = firstItems.length; i < list.length; i += step ) {\n\t\t\tasyncQueue.add( {}, () => {\n\t\t\t\tflushSync( () => {\n\t\t\t\t\tsetCurrent( ( state ) => [\n\t\t\t\t\t\t...state,\n\t\t\t\t\t\t...list.slice( i, i + step ),\n\t\t\t\t\t] );\n\t\t\t\t} );\n\t\t\t} );\n\t\t}\n\n\t\treturn () => asyncQueue.reset();\n\t}, [ list ] );\n\n\treturn current;\n}\n\nexport default useAsyncList;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-async-list/index.ts"],"names":["flushSync","useEffect","useState","createQueue","getFirstItemsPresentInState","list","state","firstItems","i","length","item","includes","push","useAsyncList","config","step","current","setCurrent","concat","slice","asyncQueue","add","reset"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,SAApB,EAA+BC,QAA/B,QAA+C,oBAA/C;AACA,SAASC,WAAT,QAA4B,2BAA5B;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,2BAAT,CAA2CC,IAA3C,EAAsDC,KAAtD,EAAwE;AACvE,QAAMC,UAAU,GAAG,EAAnB;;AAEA,OAAM,IAAIC,CAAC,GAAG,CAAd,EAAiBA,CAAC,GAAGH,IAAI,CAACI,MAA1B,EAAkCD,CAAC,EAAnC,EAAwC;AACvC,UAAME,IAAI,GAAGL,IAAI,CAAEG,CAAF,CAAjB;;AACA,QAAK,CAAEF,KAAK,CAACK,QAAN,CAAgBD,IAAhB,CAAP,EAAgC;AAC/B;AACA;;AAEDH,IAAAA,UAAU,CAACK,IAAX,CAAiBF,IAAjB;AACA;;AAED,SAAOH,UAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SAASM,YAAT,CACCR,IADD,EAECS,MAAuB,GAAG;AAAEC,EAAAA,IAAI,EAAE;AAAR,CAF3B,EAGO;AACN,QAAM;AAAEA,IAAAA,IAAI,GAAG;AAAT,MAAeD,MAArB;AACA,QAAM,CAAEE,OAAF,EAAWC,UAAX,IAA0Bf,QAAQ,CAAS,EAAT,CAAxC;AAEAD,EAAAA,SAAS,CAAE,MAAM;AAChB;AACA,QAAIM,UAAU,GAAGH,2BAA2B,CAAEC,IAAF,EAAQW,OAAR,CAA5C;;AACA,QAAKT,UAAU,CAACE,MAAX,GAAoBM,IAAzB,EAAgC;AAC/BR,MAAAA,UAAU,GAAGA,UAAU,CAACW,MAAX,CACZb,IAAI,CAACc,KAAL,CAAYZ,UAAU,CAACE,MAAvB,EAA+BM,IAA/B,CADY,CAAb;AAGA;;AACDE,IAAAA,UAAU,CAAEV,UAAF,CAAV;AAEA,UAAMa,UAAU,GAAGjB,WAAW,EAA9B;;AACA,SAAM,IAAIK,CAAC,GAAGD,UAAU,CAACE,MAAzB,EAAiCD,CAAC,GAAGH,IAAI,CAACI,MAA1C,EAAkDD,CAAC,IAAIO,IAAvD,EAA8D;AAC7DK,MAAAA,UAAU,CAACC,GAAX,CAAgB,EAAhB,EAAoB,MAAM;AACzBrB,QAAAA,SAAS,CAAE,MAAM;AAChBiB,UAAAA,UAAU,CAAIX,KAAF,IAAa,CACxB,GAAGA,KADqB,EAExB,GAAGD,IAAI,CAACc,KAAL,CAAYX,CAAZ,EAAeA,CAAC,GAAGO,IAAnB,CAFqB,CAAf,CAAV;AAIA,SALQ,CAAT;AAMA,OAPD;AAQA;;AAED,WAAO,MAAMK,UAAU,CAACE,KAAX,EAAb;AACA,GAvBQ,EAuBN,CAAEjB,IAAF,CAvBM,CAAT;AAyBA,SAAOW,OAAP;AACA;;AAED,eAAeH,YAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { flushSync, useEffect, useState } from '@wordpress/element';\nimport { createQueue } from '@wordpress/priority-queue';\n\ntype AsyncListConfig = {\n\tstep: number;\n};\n\n/**\n * Returns the first items from list that are present on state.\n *\n * @param list New array.\n * @param state Current state.\n * @return First items present iin state.\n */\nfunction getFirstItemsPresentInState< T >( list: T[], state: T[] ): T[] {\n\tconst firstItems = [];\n\n\tfor ( let i = 0; i < list.length; i++ ) {\n\t\tconst item = list[ i ];\n\t\tif ( ! state.includes( item ) ) {\n\t\t\tbreak;\n\t\t}\n\n\t\tfirstItems.push( item );\n\t}\n\n\treturn firstItems;\n}\n\n/**\n * React hook returns an array which items get asynchronously appended from a source array.\n * This behavior is useful if we want to render a list of items asynchronously for performance reasons.\n *\n * @param list Source array.\n * @param config Configuration object.\n *\n * @return Async array.\n */\nfunction useAsyncList< T >(\n\tlist: T[],\n\tconfig: AsyncListConfig = { step: 1 }\n): T[] {\n\tconst { step = 1 } = config;\n\tconst [ current, setCurrent ] = useState< T[] >( [] );\n\n\tuseEffect( () => {\n\t\t// On reset, we keep the first items that were previously rendered.\n\t\tlet firstItems = getFirstItemsPresentInState( list, current );\n\t\tif ( firstItems.length < step ) {\n\t\t\tfirstItems = firstItems.concat(\n\t\t\t\tlist.slice( firstItems.length, step )\n\t\t\t);\n\t\t}\n\t\tsetCurrent( firstItems );\n\n\t\tconst asyncQueue = createQueue();\n\t\tfor ( let i = firstItems.length; i < list.length; i += step ) {\n\t\t\tasyncQueue.add( {}, () => {\n\t\t\t\tflushSync( () => {\n\t\t\t\t\tsetCurrent( ( state ) => [\n\t\t\t\t\t\t...state,\n\t\t\t\t\t\t...list.slice( i, i + step ),\n\t\t\t\t\t] );\n\t\t\t\t} );\n\t\t\t} );\n\t\t}\n\n\t\treturn () => asyncQueue.reset();\n\t}, [ list ] );\n\n\treturn current;\n}\n\nexport default useAsyncList;\n"]}
@@ -63,7 +63,7 @@ function useConstrainedTabbing() {
63
63
  event.preventDefault();
64
64
  /** @type {HTMLElement} */
65
65
 
66
- nextElement === null || nextElement === void 0 ? void 0 : nextElement.focus();
66
+ nextElement?.focus();
67
67
  return;
68
68
  } // If the element that is about to receive focus is inside the
69
69
  // area, rely on native browsers behavior and let tabbing follow
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-constrained-tabbing/index.js"],"names":["TAB","focus","useRefEffect","useConstrainedTabbing","node","onKeyDown","event","keyCode","shiftKey","target","action","nextElement","tabbable","contains","preventDefault","domAction","ownerDocument","trap","createElement","tabIndex","addEventListener","removeChild","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,qBAApB;AACA,SAASC,KAAT,QAAsB,gBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,mBAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,qBAAT,GAAiC;AAChC,SAAOD,YAAY,CAAE;AAAE;AAA2BE,EAAAA,IAA7B,KAAuC;AAC3D,aAASC,SAAT;AAAoB;AAA6BC,IAAAA,KAAjD,EAAyD;AACxD,YAAM;AAAEC,QAAAA,OAAF;AAAWC,QAAAA,QAAX;AAAqBC,QAAAA;AAArB,UAAgCH,KAAtC;;AAEA,UAAKC,OAAO,KAAKP,GAAjB,EAAuB;AACtB;AACA;;AAED,YAAMU,MAAM,GAAGF,QAAQ,GAAG,cAAH,GAAoB,UAA3C;AACA,YAAMG,WAAW,GAChBV,KAAK,CAACW,QAAN,CAAgBF,MAAhB;AACC;AAA6BD,MAAAA,MAD9B,KAEK,IAHN,CARwD,CAaxD;AACA;AACA;AACA;AACA;AACA;;AACA;AACC;AAA6BA,MAAAA,MAAF,CAAWI,QAAX,CAAqBF,WAArB,CAD5B,EAEE;AACDL,QAAAA,KAAK,CAACQ,cAAN;AACA;;AAA6BH,QAAAA,WAAF,aAAEA,WAAF,uBAAEA,WAAF,CAAiBV,KAAjB;AAC3B;AACA,OAzBuD,CA2BxD;AACA;AACA;;;AACA,UAAKG,IAAI,CAACS,QAAL,CAAeF,WAAf,CAAL,EAAoC;AACnC;AACA,OAhCuD,CAkCxD;AACA;AACA;AACA;;;AACA,YAAMI,SAAS,GAAGP,QAAQ,GAAG,QAAH,GAAc,SAAxC;AACA,YAAM;AAAEQ,QAAAA;AAAF,UAAoBZ,IAA1B;AACA,YAAMa,IAAI,GAAGD,aAAa,CAACE,aAAd,CAA6B,KAA7B,CAAb;AAEAD,MAAAA,IAAI,CAACE,QAAL,GAAgB,CAAC,CAAjB;AACAf,MAAAA,IAAI,CAAEW,SAAF,CAAJ,CAAmBE,IAAnB,EA3CwD,CA6CxD;;AACAA,MAAAA,IAAI,CAACG,gBAAL,CAAuB,MAAvB,EAA+B,MAAMhB,IAAI,CAACiB,WAAL,CAAkBJ,IAAlB,CAArC;AAEAA,MAAAA,IAAI,CAAChB,KAAL;AACA;;AAEDG,IAAAA,IAAI,CAACgB,gBAAL,CAAuB,SAAvB,EAAkCf,SAAlC;AACA,WAAO,MAAM;AACZD,MAAAA,IAAI,CAACkB,mBAAL,CAA0B,SAA1B,EAAqCjB,SAArC;AACA,KAFD;AAGA,GAxDkB,EAwDhB,EAxDgB,CAAnB;AAyDA;;AAED,eAAeF,qBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { TAB } from '@wordpress/keycodes';\nimport { focus } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport useRefEffect from '../use-ref-effect';\n\n/**\n * In Dialogs/modals, the tabbing must be constrained to the content of\n * the wrapper element. This hook adds the behavior to the returned ref.\n *\n * @return {import('react').RefCallback<Element>} Element Ref.\n *\n * @example\n * ```js\n * import { useConstrainedTabbing } from '@wordpress/compose';\n *\n * const ConstrainedTabbingExample = () => {\n * const constrainedTabbingRef = useConstrainedTabbing()\n * return (\n * <div ref={ constrainedTabbingRef }>\n * <Button />\n * <Button />\n * </div>\n * );\n * }\n * ```\n */\nfunction useConstrainedTabbing() {\n\treturn useRefEffect( ( /** @type {HTMLElement} */ node ) => {\n\t\tfunction onKeyDown( /** @type {KeyboardEvent} */ event ) {\n\t\t\tconst { keyCode, shiftKey, target } = event;\n\n\t\t\tif ( keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst action = shiftKey ? 'findPrevious' : 'findNext';\n\t\t\tconst nextElement =\n\t\t\t\tfocus.tabbable[ action ](\n\t\t\t\t\t/** @type {HTMLElement} */ ( target )\n\t\t\t\t) || null;\n\n\t\t\t// When the target element contains the element that is about to\n\t\t\t// receive focus, for example when the target is a tabbable\n\t\t\t// container, browsers may disagree on where to move focus next.\n\t\t\t// In this case we can't rely on native browsers behavior. We need\n\t\t\t// to manage focus instead.\n\t\t\t// See https://github.com/WordPress/gutenberg/issues/46041.\n\t\t\tif (\n\t\t\t\t/** @type {HTMLElement} */ ( target ).contains( nextElement )\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t/** @type {HTMLElement} */ ( nextElement )?.focus();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the element that is about to receive focus is inside the\n\t\t\t// area, rely on native browsers behavior and let tabbing follow\n\t\t\t// the native tab sequence.\n\t\t\tif ( node.contains( nextElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the element that is about to receive focus is outside the\n\t\t\t// area, move focus to a div and insert it at the start or end of\n\t\t\t// the area, depending on the direction. Without preventing default\n\t\t\t// behaviour, the browser will then move focus to the next element.\n\t\t\tconst domAction = shiftKey ? 'append' : 'prepend';\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst trap = ownerDocument.createElement( 'div' );\n\n\t\t\ttrap.tabIndex = -1;\n\t\t\tnode[ domAction ]( trap );\n\n\t\t\t// Remove itself when the trap loses focus.\n\t\t\ttrap.addEventListener( 'blur', () => node.removeChild( trap ) );\n\n\t\t\ttrap.focus();\n\t\t}\n\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n\nexport default useConstrainedTabbing;\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-constrained-tabbing/index.js"],"names":["TAB","focus","useRefEffect","useConstrainedTabbing","node","onKeyDown","event","keyCode","shiftKey","target","action","nextElement","tabbable","contains","preventDefault","domAction","ownerDocument","trap","createElement","tabIndex","addEventListener","removeChild","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,qBAApB;AACA,SAASC,KAAT,QAAsB,gBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,mBAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,qBAAT,GAAiC;AAChC,SAAOD,YAAY,CAAE;AAAE;AAA2BE,EAAAA,IAA7B,KAAuC;AAC3D,aAASC,SAAT;AAAoB;AAA6BC,IAAAA,KAAjD,EAAyD;AACxD,YAAM;AAAEC,QAAAA,OAAF;AAAWC,QAAAA,QAAX;AAAqBC,QAAAA;AAArB,UAAgCH,KAAtC;;AAEA,UAAKC,OAAO,KAAKP,GAAjB,EAAuB;AACtB;AACA;;AAED,YAAMU,MAAM,GAAGF,QAAQ,GAAG,cAAH,GAAoB,UAA3C;AACA,YAAMG,WAAW,GAChBV,KAAK,CAACW,QAAN,CAAgBF,MAAhB;AACC;AAA6BD,MAAAA,MAD9B,KAEK,IAHN,CARwD,CAaxD;AACA;AACA;AACA;AACA;AACA;;AACA;AACC;AAA6BA,MAAAA,MAAF,CAAWI,QAAX,CAAqBF,WAArB,CAD5B,EAEE;AACDL,QAAAA,KAAK,CAACQ,cAAN;AACA;;AAA6BH,QAAAA,WAAF,EAAiBV,KAAjB;AAC3B;AACA,OAzBuD,CA2BxD;AACA;AACA;;;AACA,UAAKG,IAAI,CAACS,QAAL,CAAeF,WAAf,CAAL,EAAoC;AACnC;AACA,OAhCuD,CAkCxD;AACA;AACA;AACA;;;AACA,YAAMI,SAAS,GAAGP,QAAQ,GAAG,QAAH,GAAc,SAAxC;AACA,YAAM;AAAEQ,QAAAA;AAAF,UAAoBZ,IAA1B;AACA,YAAMa,IAAI,GAAGD,aAAa,CAACE,aAAd,CAA6B,KAA7B,CAAb;AAEAD,MAAAA,IAAI,CAACE,QAAL,GAAgB,CAAC,CAAjB;AACAf,MAAAA,IAAI,CAAEW,SAAF,CAAJ,CAAmBE,IAAnB,EA3CwD,CA6CxD;;AACAA,MAAAA,IAAI,CAACG,gBAAL,CAAuB,MAAvB,EAA+B,MAAMhB,IAAI,CAACiB,WAAL,CAAkBJ,IAAlB,CAArC;AAEAA,MAAAA,IAAI,CAAChB,KAAL;AACA;;AAEDG,IAAAA,IAAI,CAACgB,gBAAL,CAAuB,SAAvB,EAAkCf,SAAlC;AACA,WAAO,MAAM;AACZD,MAAAA,IAAI,CAACkB,mBAAL,CAA0B,SAA1B,EAAqCjB,SAArC;AACA,KAFD;AAGA,GAxDkB,EAwDhB,EAxDgB,CAAnB;AAyDA;;AAED,eAAeF,qBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { TAB } from '@wordpress/keycodes';\nimport { focus } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport useRefEffect from '../use-ref-effect';\n\n/**\n * In Dialogs/modals, the tabbing must be constrained to the content of\n * the wrapper element. This hook adds the behavior to the returned ref.\n *\n * @return {import('react').RefCallback<Element>} Element Ref.\n *\n * @example\n * ```js\n * import { useConstrainedTabbing } from '@wordpress/compose';\n *\n * const ConstrainedTabbingExample = () => {\n * const constrainedTabbingRef = useConstrainedTabbing()\n * return (\n * <div ref={ constrainedTabbingRef }>\n * <Button />\n * <Button />\n * </div>\n * );\n * }\n * ```\n */\nfunction useConstrainedTabbing() {\n\treturn useRefEffect( ( /** @type {HTMLElement} */ node ) => {\n\t\tfunction onKeyDown( /** @type {KeyboardEvent} */ event ) {\n\t\t\tconst { keyCode, shiftKey, target } = event;\n\n\t\t\tif ( keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst action = shiftKey ? 'findPrevious' : 'findNext';\n\t\t\tconst nextElement =\n\t\t\t\tfocus.tabbable[ action ](\n\t\t\t\t\t/** @type {HTMLElement} */ ( target )\n\t\t\t\t) || null;\n\n\t\t\t// When the target element contains the element that is about to\n\t\t\t// receive focus, for example when the target is a tabbable\n\t\t\t// container, browsers may disagree on where to move focus next.\n\t\t\t// In this case we can't rely on native browsers behavior. We need\n\t\t\t// to manage focus instead.\n\t\t\t// See https://github.com/WordPress/gutenberg/issues/46041.\n\t\t\tif (\n\t\t\t\t/** @type {HTMLElement} */ ( target ).contains( nextElement )\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t/** @type {HTMLElement} */ ( nextElement )?.focus();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the element that is about to receive focus is inside the\n\t\t\t// area, rely on native browsers behavior and let tabbing follow\n\t\t\t// the native tab sequence.\n\t\t\tif ( node.contains( nextElement ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the element that is about to receive focus is outside the\n\t\t\t// area, move focus to a div and insert it at the start or end of\n\t\t\t// the area, depending on the direction. Without preventing default\n\t\t\t// behaviour, the browser will then move focus to the next element.\n\t\t\tconst domAction = shiftKey ? 'append' : 'prepend';\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst trap = ownerDocument.createElement( 'div' );\n\n\t\t\ttrap.tabIndex = -1;\n\t\t\tnode[ domAction ]( trap );\n\n\t\t\t// Remove itself when the trap loses focus.\n\t\t\ttrap.addEventListener( 'blur', () => node.removeChild( trap ) );\n\n\t\t\ttrap.focus();\n\t\t}\n\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n\nexport default useConstrainedTabbing;\n"]}
@@ -24,9 +24,7 @@ import deprecated from '@wordpress/deprecated';
24
24
  * timeout.
25
25
  */
26
26
 
27
- export default function useCopyOnClick(ref, text) {
28
- let timeout = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 4000;
29
-
27
+ export default function useCopyOnClick(ref, text, timeout = 4000) {
30
28
  /* eslint-enable jsdoc/no-undefined-types */
31
29
  deprecated('wp.compose.useCopyOnClick', {
32
30
  since: '5.8',
@@ -48,11 +46,10 @@ export default function useCopyOnClick(ref, text) {
48
46
  clipboard.current = new Clipboard(ref.current, {
49
47
  text: () => typeof text === 'function' ? text() : text
50
48
  });
51
- clipboard.current.on('success', _ref => {
52
- let {
53
- clearSelection,
54
- trigger
55
- } = _ref;
49
+ clipboard.current.on('success', ({
50
+ clearSelection,
51
+ trigger
52
+ }) => {
56
53
  // Clearing selection will move focus back to the triggering button,
57
54
  // ensuring that it is not reset to the body, and further that it is
58
55
  // kept within the rendered node.
@@ -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","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
+ {"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,EAAoCC,OAAO,GAAG,IAA9C,EAAqD;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,CAAE;AAAEC,MAAAA,cAAF;AAAkBC,MAAAA;AAAlB,KAAF,KAAmC;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"]}
@@ -48,10 +48,9 @@ export default function useCopyToClipboard(text, onSuccess) {
48
48
  }
49
49
 
50
50
  });
51
- clipboard.on('success', _ref => {
52
- let {
53
- clearSelection
54
- } = _ref;
51
+ clipboard.on('success', ({
52
+ clearSelection
53
+ }) => {
55
54
  // Clearing selection will move focus back to the triggering
56
55
  // button, ensuring that it is not reset to the body, and
57
56
  // further that it is kept within the rendered node.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-copy-to-clipboard/index.js"],"names":["Clipboard","useRef","useRefEffect","useUpdatedRef","value","ref","current","useCopyToClipboard","text","onSuccess","textRef","onSuccessRef","node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A2BhB,EA3BgB,CAAnB;AA4BA","sourcesContent":["/**\n * External dependencies\n */\nimport Clipboard from 'clipboard';\n\n/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useRefEffect from '../use-ref-effect';\n\n/**\n * @template T\n * @param {T} value\n * @return {import('react').RefObject<T>} The updated ref\n */\nfunction useUpdatedRef( value ) {\n\tconst ref = useRef( value );\n\tref.current = value;\n\treturn ref;\n}\n\n/**\n * Copies the given text to the clipboard when the element is clicked.\n *\n * @template {HTMLElement} TElementType\n * @param {string | (() => string)} text The text to copy. Use a function if not\n * already available and expensive to compute.\n * @param {Function} onSuccess Called when to text is copied.\n *\n * @return {import('react').Ref<TElementType>} A ref to assign to the target element.\n */\nexport default function useCopyToClipboard( text, onSuccess ) {\n\t// Store the dependencies as refs and continuously update them so they're\n\t// fresh when the callback is called.\n\tconst textRef = useUpdatedRef( text );\n\tconst onSuccessRef = useUpdatedRef( onSuccess );\n\treturn useRefEffect( ( node ) => {\n\t\t// Clipboard listens to click events.\n\t\tconst clipboard = new Clipboard( node, {\n\t\t\ttext() {\n\t\t\t\treturn typeof textRef.current === 'function'\n\t\t\t\t\t? textRef.current()\n\t\t\t\t\t: textRef.current || '';\n\t\t\t},\n\t\t} );\n\n\t\tclipboard.on( 'success', ( { clearSelection } ) => {\n\t\t\t// Clearing selection will move focus back to the triggering\n\t\t\t// button, ensuring that it is not reset to the body, and\n\t\t\t// further that it is kept within the rendered node.\n\t\t\tclearSelection();\n\t\t\t// Handle ClipboardJS focus bug, see\n\t\t\t// https://github.com/zenorocha/clipboard.js/issues/680\n\t\t\tnode.focus();\n\n\t\t\tif ( onSuccessRef.current ) {\n\t\t\t\tonSuccessRef.current();\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tclipboard.destroy();\n\t\t};\n\t}, [] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-copy-to-clipboard/index.js"],"names":["Clipboard","useRef","useRefEffect","useUpdatedRef","value","ref","current","useCopyToClipboard","text","onSuccess","textRef","onSuccessRef","node","clipboard","on","clearSelection","focus","destroy"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAP,MAAsB,WAAtB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,mBAAzB;AAEA;AACA;AACA;AACA;AACA;;AACA,SAASC,aAAT,CAAwBC,KAAxB,EAAgC;AAC/B,QAAMC,GAAG,GAAGJ,MAAM,CAAEG,KAAF,CAAlB;AACAC,EAAAA,GAAG,CAACC,OAAJ,GAAcF,KAAd;AACA,SAAOC,GAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,eAAe,SAASE,kBAAT,CAA6BC,IAA7B,EAAmCC,SAAnC,EAA+C;AAC7D;AACA;AACA,QAAMC,OAAO,GAAGP,aAAa,CAAEK,IAAF,CAA7B;AACA,QAAMG,YAAY,GAAGR,aAAa,CAAEM,SAAF,CAAlC;AACA,SAAOP,YAAY,CAAIU,IAAF,IAAY;AAChC;AACA,UAAMC,SAAS,GAAG,IAAIb,SAAJ,CAAeY,IAAf,EAAqB;AACtCJ,MAAAA,IAAI,GAAG;AACN,eAAO,OAAOE,OAAO,CAACJ,OAAf,KAA2B,UAA3B,GACJI,OAAO,CAACJ,OAAR,EADI,GAEJI,OAAO,CAACJ,OAAR,IAAmB,EAFtB;AAGA;;AALqC,KAArB,CAAlB;AAQAO,IAAAA,SAAS,CAACC,EAAV,CAAc,SAAd,EAAyB,CAAE;AAAEC,MAAAA;AAAF,KAAF,KAA0B;AAClD;AACA;AACA;AACAA,MAAAA,cAAc,GAJoC,CAKlD;AACA;;AACAH,MAAAA,IAAI,CAACI,KAAL;;AAEA,UAAKL,YAAY,CAACL,OAAlB,EAA4B;AAC3BK,QAAAA,YAAY,CAACL,OAAb;AACA;AACD,KAZD;AAcA,WAAO,MAAM;AACZO,MAAAA,SAAS,CAACI,OAAV;AACA,KAFD;AAGA,GA3BkB,EA2BhB,EA3BgB,CAAnB;AA4BA","sourcesContent":["/**\n * External dependencies\n */\nimport Clipboard from 'clipboard';\n\n/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useRefEffect from '../use-ref-effect';\n\n/**\n * @template T\n * @param {T} value\n * @return {import('react').RefObject<T>} The updated ref\n */\nfunction useUpdatedRef( value ) {\n\tconst ref = useRef( value );\n\tref.current = value;\n\treturn ref;\n}\n\n/**\n * Copies the given text to the clipboard when the element is clicked.\n *\n * @template {HTMLElement} TElementType\n * @param {string | (() => string)} text The text to copy. Use a function if not\n * already available and expensive to compute.\n * @param {Function} onSuccess Called when to text is copied.\n *\n * @return {import('react').Ref<TElementType>} A ref to assign to the target element.\n */\nexport default function useCopyToClipboard( text, onSuccess ) {\n\t// Store the dependencies as refs and continuously update them so they're\n\t// fresh when the callback is called.\n\tconst textRef = useUpdatedRef( text );\n\tconst onSuccessRef = useUpdatedRef( onSuccess );\n\treturn useRefEffect( ( node ) => {\n\t\t// Clipboard listens to click events.\n\t\tconst clipboard = new Clipboard( node, {\n\t\t\ttext() {\n\t\t\t\treturn typeof textRef.current === 'function'\n\t\t\t\t\t? textRef.current()\n\t\t\t\t\t: textRef.current || '';\n\t\t\t},\n\t\t} );\n\n\t\tclipboard.on( 'success', ( { clearSelection } ) => {\n\t\t\t// Clearing selection will move focus back to the triggering\n\t\t\t// button, ensuring that it is not reset to the body, and\n\t\t\t// further that it is kept within the rendered node.\n\t\t\tclearSelection();\n\t\t\t// Handle ClipboardJS focus bug, see\n\t\t\t// https://github.com/zenorocha/clipboard.js/issues/680\n\t\t\tnode.focus();\n\n\t\t\tif ( onSuccessRef.current ) {\n\t\t\t\tonSuccessRef.current();\n\t\t\t}\n\t\t} );\n\n\t\treturn () => {\n\t\t\tclipboard.destroy();\n\t\t};\n\t}, [] );\n}\n"]}
@@ -35,13 +35,11 @@ function useDialog(options) {
35
35
  const focusOnMountRef = useFocusOnMount(options.focusOnMount);
36
36
  const focusReturnRef = useFocusReturn();
37
37
  const focusOutsideProps = useFocusOutside(event => {
38
- var _currentOptions$curre, _currentOptions$curre2;
39
-
40
38
  // This unstable prop is here only to manage backward compatibility
41
39
  // for the Popover component otherwise, the onClose should be enough.
42
- if ((_currentOptions$curre = currentOptions.current) !== null && _currentOptions$curre !== void 0 && _currentOptions$curre.__unstableOnClose) {
40
+ if (currentOptions.current?.__unstableOnClose) {
43
41
  currentOptions.current.__unstableOnClose('focus-outside', event);
44
- } else if ((_currentOptions$curre2 = currentOptions.current) !== null && _currentOptions$curre2 !== void 0 && _currentOptions$curre2.onClose) {
42
+ } else if (currentOptions.current?.onClose) {
45
43
  currentOptions.current.onClose();
46
44
  }
47
45
  });
@@ -51,10 +49,8 @@ function useDialog(options) {
51
49
  }
52
50
 
53
51
  node.addEventListener('keydown', event => {
54
- var _currentOptions$curre3;
55
-
56
52
  // Close on escape.
57
- if (event.keyCode === ESCAPE && !event.defaultPrevented && (_currentOptions$curre3 = currentOptions.current) !== null && _currentOptions$curre3 !== void 0 && _currentOptions$curre3.onClose) {
53
+ if (event.keyCode === ESCAPE && !event.defaultPrevented && currentOptions.current?.onClose) {
58
54
  event.preventDefault();
59
55
  currentOptions.current.onClose();
60
56
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-dialog/index.ts"],"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;;AAGA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,SAAjB,EAA4BC,WAA5B,Q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,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,KAVD;AAWA,GAhBmC,EAgBjC,EAhBiC,CAApC;AAkBA,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,CAAC;AAFZ,GAPM,CAAP;AAYA;;AAED,eAAepB,SAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { RefCallback, SyntheticEvent } from 'react';\n\n/**\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\ntype DialogOptions = {\n\tfocusOnMount?: Parameters< typeof useFocusOnMount >[ 0 ];\n\tonClose?: () => void;\n\t/**\n\t * Use the `onClose` prop instead.\n\t *\n\t * @deprecated\n\t */\n\t__unstableOnClose?: (\n\t\ttype: string | undefined,\n\t\tevent: SyntheticEvent\n\t) => void;\n};\n\ntype useDialogReturn = [\n\tRefCallback< HTMLElement >,\n\tReturnType< typeof useFocusOutside > & Pick< HTMLElement, 'tabIndex' >\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 options Dialog Options.\n */\nfunction useDialog( options: DialogOptions ): useDialogReturn {\n\tconst currentOptions = useRef< DialogOptions | undefined >();\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\tif ( currentOptions.current?.__unstableOnClose ) {\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: HTMLElement ) => {\n\t\tif ( ! node ) {\n\t\t\treturn;\n\t\t}\n\n\t\tnode.addEventListener( 'keydown', ( event: KeyboardEvent ) => {\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.ts"],"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;;AAGA;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;;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,SAAT,CAAoBC,OAApB,EAA8D;AAC7D,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;AACvD;AACA;AACA,QAAKT,cAAc,CAACC,OAAf,EAAwBS,iBAA7B,EAAiD;AAChDV,MAAAA,cAAc,CAACC,OAAf,CAAuBS,iBAAvB,CAA0C,eAA1C,EAA2DD,KAA3D;AACA,KAFD,MAEO,IAAKT,cAAc,CAACC,OAAf,EAAwBU,OAA7B,EAAuC;AAC7CX,MAAAA,cAAc,CAACC,OAAf,CAAuBU,OAAvB;AACA;AACD,GARwC,CAAzC;AASA,QAAMC,gBAAgB,GAAGrB,WAAW,CAAIsB,IAAF,IAAyB;AAC9D,QAAK,CAAEA,IAAP,EAAc;AACb;AACA;;AAEDA,IAAAA,IAAI,CAACC,gBAAL,CAAuB,SAAvB,EAAoCL,KAAF,IAA4B;AAC7D;AACA,UACCA,KAAK,CAACM,OAAN,KAAkBvB,MAAlB,IACA,CAAEiB,KAAK,CAACO,gBADR,IAEAhB,cAAc,CAACC,OAAf,EAAwBU,OAHzB,EAIE;AACDF,QAAAA,KAAK,CAACQ,cAAN;AACAjB,QAAAA,cAAc,CAACC,OAAf,CAAuBU,OAAvB;AACA;AACD,KAVD;AAWA,GAhBmC,EAgBjC,EAhBiC,CAApC;AAkBA,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,CAAC;AAFZ,GAPM,CAAP;AAYA;;AAED,eAAepB,SAAf","sourcesContent":["/**\n * External dependencies\n */\nimport type { RefCallback, SyntheticEvent } from 'react';\n\n/**\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\ntype DialogOptions = {\n\tfocusOnMount?: Parameters< typeof useFocusOnMount >[ 0 ];\n\tonClose?: () => void;\n\t/**\n\t * Use the `onClose` prop instead.\n\t *\n\t * @deprecated\n\t */\n\t__unstableOnClose?: (\n\t\ttype: string | undefined,\n\t\tevent: SyntheticEvent\n\t) => void;\n};\n\ntype useDialogReturn = [\n\tRefCallback< HTMLElement >,\n\tReturnType< typeof useFocusOutside > & Pick< HTMLElement, 'tabIndex' >\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 options Dialog Options.\n */\nfunction useDialog( options: DialogOptions ): useDialogReturn {\n\tconst currentOptions = useRef< DialogOptions | undefined >();\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\tif ( currentOptions.current?.__unstableOnClose ) {\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: HTMLElement ) => {\n\t\tif ( ! node ) {\n\t\t\treturn;\n\t\t}\n\n\t\tnode.addEventListener( 'keydown', ( event: KeyboardEvent ) => {\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"]}
@@ -30,18 +30,15 @@ import useRefEffect from '../use-ref-effect';
30
30
  * ```
31
31
  */
32
32
 
33
- export default function useDisabled() {
34
- let {
35
- isDisabled: isDisabledProp = false
36
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
33
+ export default function useDisabled({
34
+ isDisabled: isDisabledProp = false
35
+ } = {}) {
37
36
  return useRefEffect(node => {
38
- var _node$ownerDocument;
39
-
40
37
  if (isDisabledProp) {
41
38
  return;
42
39
  }
43
40
 
44
- const defaultView = node === null || node === void 0 ? void 0 : (_node$ownerDocument = node.ownerDocument) === null || _node$ownerDocument === void 0 ? void 0 : _node$ownerDocument.defaultView;
41
+ const defaultView = node?.ownerDocument?.defaultView;
45
42
 
46
43
  if (!defaultView) {
47
44
  return;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-disabled/index.ts"],"names":["debounce","useRefEffect","useDisabled","isDisabled","isDisabledProp","node","defaultView","ownerDocument","updates","disable","childNodes","forEach","child","HTMLElement","getAttribute","setAttribute","push","removeAttribute","debouncedDisable","leading","observer","window","MutationObserver","observe","childList","disconnect","cancel","update"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,sBAAzB;AACA,OAAOC,YAAP,MAAyB,mBAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,WAAT,GAEN;AAAA,MAF4B;AACpCC,IAAAA,UAAU,EAAEC,cAAc,GAAG;AAD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ArC;AACA,KAND;AAOA,GA/CiB,EAgDlB,CAAEvB,cAAF,CAhDkB,CAAnB;AAkDA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { debounce } from '../../utils/debounce';\nimport useRefEffect from '../use-ref-effect';\n\n/**\n * In some circumstances, such as block previews, all focusable DOM elements\n * (input fields, links, buttons, etc.) need to be disabled. This hook adds the\n * behavior to disable nested DOM elements to the returned ref.\n *\n * If you can, prefer the use of the inert HTML attribute.\n *\n * @param {Object} config Configuration object.\n * @param {boolean=} config.isDisabled Whether the element should be disabled.\n * @return {import('react').RefCallback<HTMLElement>} Element Ref.\n *\n * @example\n * ```js\n * import { useDisabled } from '@wordpress/compose';\n *\n * const DisabledExample = () => {\n * \tconst disabledRef = useDisabled();\n *\treturn (\n *\t\t<div ref={ disabledRef }>\n *\t\t\t<a href=\"#\">This link will have tabindex set to -1</a>\n *\t\t\t<input placeholder=\"This input will have the disabled attribute added to it.\" type=\"text\" />\n *\t\t</div>\n *\t);\n * };\n * ```\n */\nexport default function useDisabled( {\n\tisDisabled: isDisabledProp = false,\n} = {} ) {\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( isDisabledProp ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst defaultView = node?.ownerDocument?.defaultView;\n\t\t\tif ( ! defaultView ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t/** A variable keeping track of the previous updates in order to restore them. */\n\t\t\tconst updates: Function[] = [];\n\t\t\tconst disable = () => {\n\t\t\t\tnode.childNodes.forEach( ( child ) => {\n\t\t\t\t\tif ( ! ( child instanceof defaultView.HTMLElement ) ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif ( ! child.getAttribute( 'inert' ) ) {\n\t\t\t\t\t\tchild.setAttribute( 'inert', 'true' );\n\t\t\t\t\t\tupdates.push( () => {\n\t\t\t\t\t\t\tchild.removeAttribute( 'inert' );\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t};\n\n\t\t\t// Debounce re-disable since disabling process itself will incur\n\t\t\t// additional mutations which should be ignored.\n\t\t\tconst debouncedDisable = debounce( disable, 0, {\n\t\t\t\tleading: true,\n\t\t\t} );\n\t\t\tdisable();\n\n\t\t\t/** @type {MutationObserver | undefined} */\n\t\t\tconst observer = new window.MutationObserver( debouncedDisable );\n\t\t\tobserver.observe( node, {\n\t\t\t\tchildList: true,\n\t\t\t} );\n\n\t\t\treturn () => {\n\t\t\t\tif ( observer ) {\n\t\t\t\t\tobserver.disconnect();\n\t\t\t\t}\n\t\t\t\tdebouncedDisable.cancel();\n\t\t\t\tupdates.forEach( ( update ) => update() );\n\t\t\t};\n\t\t},\n\t\t[ isDisabledProp ]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-disabled/index.ts"],"names":["debounce","useRefEffect","useDisabled","isDisabled","isDisabledProp","node","defaultView","ownerDocument","updates","disable","childNodes","forEach","child","HTMLElement","getAttribute","setAttribute","push","removeAttribute","debouncedDisable","leading","observer","window","MutationObserver","observe","childList","disconnect","cancel","update"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,sBAAzB;AACA,OAAOC,YAAP,MAAyB,mBAAzB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,WAAT,CAAsB;AACpCC,EAAAA,UAAU,EAAEC,cAAc,GAAG;AADO,IAEjC,EAFW,EAEN;AACR,SAAOH,YAAY,CAChBI,IAAF,IAAY;AACX,QAAKD,cAAL,EAAsB;AACrB;AACA;;AAED,UAAME,WAAW,GAAGD,IAAI,EAAEE,aAAN,EAAqBD,WAAzC;;AACA,QAAK,CAAEA,WAAP,EAAqB;AACpB;AACA;AAED;;;AACA,UAAME,OAAmB,GAAG,EAA5B;;AACA,UAAMC,OAAO,GAAG,MAAM;AACrBJ,MAAAA,IAAI,CAACK,UAAL,CAAgBC,OAAhB,CAA2BC,KAAF,IAAa;AACrC,YAAK,EAAIA,KAAK,YAAYN,WAAW,CAACO,WAAjC,CAAL,EAAsD;AACrD;AACA;;AACD,YAAK,CAAED,KAAK,CAACE,YAAN,CAAoB,OAApB,CAAP,EAAuC;AACtCF,UAAAA,KAAK,CAACG,YAAN,CAAoB,OAApB,EAA6B,MAA7B;AACAP,UAAAA,OAAO,CAACQ,IAAR,CAAc,MAAM;AACnBJ,YAAAA,KAAK,CAACK,eAAN,CAAuB,OAAvB;AACA,WAFD;AAGA;AACD,OAVD;AAWA,KAZD,CAZW,CA0BX;AACA;;;AACA,UAAMC,gBAAgB,GAAGlB,QAAQ,CAAES,OAAF,EAAW,CAAX,EAAc;AAC9CU,MAAAA,OAAO,EAAE;AADqC,KAAd,CAAjC;AAGAV,IAAAA,OAAO;AAEP;;AACA,UAAMW,QAAQ,GAAG,IAAIC,MAAM,CAACC,gBAAX,CAA6BJ,gBAA7B,CAAjB;AACAE,IAAAA,QAAQ,CAACG,OAAT,CAAkBlB,IAAlB,EAAwB;AACvBmB,MAAAA,SAAS,EAAE;AADY,KAAxB;AAIA,WAAO,MAAM;AACZ,UAAKJ,QAAL,EAAgB;AACfA,QAAAA,QAAQ,CAACK,UAAT;AACA;;AACDP,MAAAA,gBAAgB,CAACQ,MAAjB;AACAlB,MAAAA,OAAO,CAACG,OAAR,CAAmBgB,MAAF,IAAcA,MAAM,EAArC;AACA,KAND;AAOA,GA/CiB,EAgDlB,CAAEvB,cAAF,CAhDkB,CAAnB;AAkDA","sourcesContent":["/**\n * Internal dependencies\n */\nimport { debounce } from '../../utils/debounce';\nimport useRefEffect from '../use-ref-effect';\n\n/**\n * In some circumstances, such as block previews, all focusable DOM elements\n * (input fields, links, buttons, etc.) need to be disabled. This hook adds the\n * behavior to disable nested DOM elements to the returned ref.\n *\n * If you can, prefer the use of the inert HTML attribute.\n *\n * @param {Object} config Configuration object.\n * @param {boolean=} config.isDisabled Whether the element should be disabled.\n * @return {import('react').RefCallback<HTMLElement>} Element Ref.\n *\n * @example\n * ```js\n * import { useDisabled } from '@wordpress/compose';\n *\n * const DisabledExample = () => {\n * \tconst disabledRef = useDisabled();\n *\treturn (\n *\t\t<div ref={ disabledRef }>\n *\t\t\t<a href=\"#\">This link will have tabindex set to -1</a>\n *\t\t\t<input placeholder=\"This input will have the disabled attribute added to it.\" type=\"text\" />\n *\t\t</div>\n *\t);\n * };\n * ```\n */\nexport default function useDisabled( {\n\tisDisabled: isDisabledProp = false,\n} = {} ) {\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tif ( isDisabledProp ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst defaultView = node?.ownerDocument?.defaultView;\n\t\t\tif ( ! defaultView ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t/** A variable keeping track of the previous updates in order to restore them. */\n\t\t\tconst updates: Function[] = [];\n\t\t\tconst disable = () => {\n\t\t\t\tnode.childNodes.forEach( ( child ) => {\n\t\t\t\t\tif ( ! ( child instanceof defaultView.HTMLElement ) ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tif ( ! child.getAttribute( 'inert' ) ) {\n\t\t\t\t\t\tchild.setAttribute( 'inert', 'true' );\n\t\t\t\t\t\tupdates.push( () => {\n\t\t\t\t\t\t\tchild.removeAttribute( 'inert' );\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t};\n\n\t\t\t// Debounce re-disable since disabling process itself will incur\n\t\t\t// additional mutations which should be ignored.\n\t\t\tconst debouncedDisable = debounce( disable, 0, {\n\t\t\t\tleading: true,\n\t\t\t} );\n\t\t\tdisable();\n\n\t\t\t/** @type {MutationObserver | undefined} */\n\t\t\tconst observer = new window.MutationObserver( debouncedDisable );\n\t\t\tobserver.observe( node, {\n\t\t\t\tchildList: true,\n\t\t\t} );\n\n\t\t\treturn () => {\n\t\t\t\tif ( observer ) {\n\t\t\t\t\tobserver.disconnect();\n\t\t\t\t}\n\t\t\t\tdebouncedDisable.cancel();\n\t\t\t\tupdates.forEach( ( update ) => update() );\n\t\t\t};\n\t\t},\n\t\t[ isDisabledProp ]\n\t);\n}\n"]}
@@ -16,12 +16,11 @@ import useIsomorphicLayoutEffect from '../use-isomorphic-layout-effect'; // Even
16
16
  * @param {(e?: MouseEvent) => void} props.onDragEnd
17
17
  */
18
18
 
19
- export default function useDragging(_ref) {
20
- let {
21
- onDragStart,
22
- onDragMove,
23
- onDragEnd
24
- } = _ref;
19
+ export default function useDragging({
20
+ onDragStart,
21
+ onDragMove,
22
+ onDragEnd
23
+ }) {
25
24
  const [isDragging, setIsDragging] = useState(false);
26
25
  const eventsRef = useRef({
27
26
  onDragStart,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/compose/src/hooks/use-dragging/index.js"],"names":["useCallback","useEffect","useRef","useState","useIsomorphicLayoutEffect","useDragging","onDragStart","onDragMove","onDragEnd","isDragging","setIsDragging","eventsRef","current","onMouseMove","event","endDrag","document","removeEventListener","startDrag","addEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,EAAyCC,QAAzC,QAAyD,oBAAzD;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,iCAAtC,C,CAEA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,WAAT,OAA+D;AAAA,MAAzC;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,UAAf;AAA2BC,IAAAA;AAA3B,GAAyC;AAC7E,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgCP,QAAQ,CAAE,KAAF,CAA9C;AAEA,QAAMQ,SAAS,GAAGT,MAAM,CAAE;AACzBI,IAAAA,WADyB;AAEzBC,IAAAA,UAFyB;AAGzBC,IAAAA;AAHyB,GAAF,CAAxB;AAKAJ,EAA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AA7B,CA/B6E,CAwC7E;;AACAT,EAAAA,SAAS,CAAE,MAAM;AAChB,WAAO,MAAM;AACZ,UAAKQ,UAAL,EAAkB;AACjBO,QAAAA,QAAQ,CAACC,mBAAT,CAA8B,WAA9B,EAA2CJ,WAA3C;AACAG,QAAAA,QAAQ,CAACC,mBAAT,CAA8B,SAA9B,EAAyCF,OAAzC;AACA;AACD,KALD;AAMA,GAPQ,EAON,CAAEN,UAAF,CAPM,CAAT;AASA,SAAO;AACNS,IAAAA,SADM;AAENH,IAAAA,OAFM;AAGNN,IAAAA;AAHM,GAAP;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useIsomorphicLayoutEffect from '../use-isomorphic-layout-effect';\n\n// Event handlers that are triggered from `document` listeners accept a MouseEvent,\n// while those triggered from React listeners accept a React.MouseEvent.\n/**\n * @param {Object} props\n * @param {(e: import('react').MouseEvent) => void} props.onDragStart\n * @param {(e: MouseEvent) => void} props.onDragMove\n * @param {(e?: MouseEvent) => void} props.onDragEnd\n */\nexport default function useDragging( { onDragStart, onDragMove, onDragEnd } ) {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\n\tconst eventsRef = useRef( {\n\t\tonDragStart,\n\t\tonDragMove,\n\t\tonDragEnd,\n\t} );\n\tuseIsomorphicLayoutEffect( () => {\n\t\teventsRef.current.onDragStart = onDragStart;\n\t\teventsRef.current.onDragMove = onDragMove;\n\t\teventsRef.current.onDragEnd = onDragEnd;\n\t}, [ onDragStart, onDragMove, onDragEnd ] );\n\n\t/** @type {(e: MouseEvent) => void} */\n\tconst onMouseMove = useCallback(\n\t\t( event ) =>\n\t\t\teventsRef.current.onDragMove &&\n\t\t\teventsRef.current.onDragMove( event ),\n\t\t[]\n\t);\n\t/** @type {(e?: MouseEvent) => void} */\n\tconst endDrag = useCallback( ( event ) => {\n\t\tif ( eventsRef.current.onDragEnd ) {\n\t\t\teventsRef.current.onDragEnd( event );\n\t\t}\n\t\tdocument.removeEventListener( 'mousemove', onMouseMove );\n\t\tdocument.removeEventListener( 'mouseup', endDrag );\n\t\tsetIsDragging( false );\n\t}, [] );\n\t/** @type {(e: import('react').MouseEvent) => void} */\n\tconst startDrag = useCallback( ( event ) => {\n\t\tif ( eventsRef.current.onDragStart ) {\n\t\t\teventsRef.current.onDragStart( event );\n\t\t}\n\t\tdocument.addEventListener( 'mousemove', onMouseMove );\n\t\tdocument.addEventListener( 'mouseup', endDrag );\n\t\tsetIsDragging( true );\n\t}, [] );\n\n\t// Remove the global events when unmounting if needed.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging ) {\n\t\t\t\tdocument.removeEventListener( 'mousemove', onMouseMove );\n\t\t\t\tdocument.removeEventListener( 'mouseup', endDrag );\n\t\t\t}\n\t\t};\n\t}, [ isDragging ] );\n\n\treturn {\n\t\tstartDrag,\n\t\tendDrag,\n\t\tisDragging,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/compose/src/hooks/use-dragging/index.js"],"names":["useCallback","useEffect","useRef","useState","useIsomorphicLayoutEffect","useDragging","onDragStart","onDragMove","onDragEnd","isDragging","setIsDragging","eventsRef","current","onMouseMove","event","endDrag","document","removeEventListener","startDrag","addEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,SAAtB,EAAiCC,MAAjC,EAAyCC,QAAzC,QAAyD,oBAAzD;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,iCAAtC,C,CAEA;AACA;;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,eAAe,SAASC,WAAT,CAAsB;AAAEC,EAAAA,WAAF;AAAeC,EAAAA,UAAf;AAA2BC,EAAAA;AAA3B,CAAtB,EAA+D;AAC7E,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgCP,QAAQ,CAAE,KAAF,CAA9C;AAEA,QAAMQ,SAAS,GAAGT,MAAM,CAAE;AACzB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A3B,EAAsCJ,OAAtC;AACAL,IAAAA,aAAa,CAAE,IAAF,CAAb;AACA,GAP4B,EAO1B,EAP0B,CAA7B,CA/B6E,CAwC7E;;AACAT,EAAAA,SAAS,CAAE,MAAM;AAChB,WAAO,MAAM;AACZ,UAAKQ,UAAL,EAAkB;AACjBO,QAAAA,QAAQ,CAACC,mBAAT,CAA8B,WAA9B,EAA2CJ,WAA3C;AACAG,QAAAA,QAAQ,CAACC,mBAAT,CAA8B,SAA9B,EAAyCF,OAAzC;AACA;AACD,KALD;AAMA,GAPQ,EAON,CAAEN,UAAF,CAPM,CAAT;AASA,SAAO;AACNS,IAAAA,SADM;AAENH,IAAAA,OAFM;AAGNN,IAAAA;AAHM,GAAP;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useIsomorphicLayoutEffect from '../use-isomorphic-layout-effect';\n\n// Event handlers that are triggered from `document` listeners accept a MouseEvent,\n// while those triggered from React listeners accept a React.MouseEvent.\n/**\n * @param {Object} props\n * @param {(e: import('react').MouseEvent) => void} props.onDragStart\n * @param {(e: MouseEvent) => void} props.onDragMove\n * @param {(e?: MouseEvent) => void} props.onDragEnd\n */\nexport default function useDragging( { onDragStart, onDragMove, onDragEnd } ) {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\n\tconst eventsRef = useRef( {\n\t\tonDragStart,\n\t\tonDragMove,\n\t\tonDragEnd,\n\t} );\n\tuseIsomorphicLayoutEffect( () => {\n\t\teventsRef.current.onDragStart = onDragStart;\n\t\teventsRef.current.onDragMove = onDragMove;\n\t\teventsRef.current.onDragEnd = onDragEnd;\n\t}, [ onDragStart, onDragMove, onDragEnd ] );\n\n\t/** @type {(e: MouseEvent) => void} */\n\tconst onMouseMove = useCallback(\n\t\t( event ) =>\n\t\t\teventsRef.current.onDragMove &&\n\t\t\teventsRef.current.onDragMove( event ),\n\t\t[]\n\t);\n\t/** @type {(e?: MouseEvent) => void} */\n\tconst endDrag = useCallback( ( event ) => {\n\t\tif ( eventsRef.current.onDragEnd ) {\n\t\t\teventsRef.current.onDragEnd( event );\n\t\t}\n\t\tdocument.removeEventListener( 'mousemove', onMouseMove );\n\t\tdocument.removeEventListener( 'mouseup', endDrag );\n\t\tsetIsDragging( false );\n\t}, [] );\n\t/** @type {(e: import('react').MouseEvent) => void} */\n\tconst startDrag = useCallback( ( event ) => {\n\t\tif ( eventsRef.current.onDragStart ) {\n\t\t\teventsRef.current.onDragStart( event );\n\t\t}\n\t\tdocument.addEventListener( 'mousemove', onMouseMove );\n\t\tdocument.addEventListener( 'mouseup', endDrag );\n\t\tsetIsDragging( true );\n\t}, [] );\n\n\t// Remove the global events when unmounting if needed.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging ) {\n\t\t\t\tdocument.removeEventListener( 'mousemove', onMouseMove );\n\t\t\t\tdocument.removeEventListener( 'mouseup', endDrag );\n\t\t\t}\n\t\t};\n\t}, [ isDragging ] );\n\n\treturn {\n\t\tstartDrag,\n\t\tendDrag,\n\t\tisDragging,\n\t};\n}\n"]}