@wordpress/components 21.0.1 → 21.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/CHANGELOG.md +16 -7
  2. package/build/autocomplete/get-default-use-items.js +3 -3
  3. package/build/autocomplete/get-default-use-items.js.map +1 -1
  4. package/build/box-control/unit-control.js +0 -1
  5. package/build/box-control/unit-control.js.map +1 -1
  6. package/build/button/index.js +5 -1
  7. package/build/button/index.js.map +1 -1
  8. package/build/drop-zone/index.js +7 -1
  9. package/build/drop-zone/index.js.map +1 -1
  10. package/build/higher-order/with-filters/index.js +1 -1
  11. package/build/higher-order/with-filters/index.js.map +1 -1
  12. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +3 -3
  13. package/build/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  14. package/build/mobile/link-picker/link-picker-results.native.js +3 -3
  15. package/build/mobile/link-picker/link-picker-results.native.js.map +1 -1
  16. package/build/range-control/input-range.js +1 -15
  17. package/build/range-control/input-range.js.map +1 -1
  18. package/build/range-control/tooltip.js +1 -1
  19. package/build/range-control/tooltip.js.map +1 -1
  20. package/build/range-control/utils.js +2 -58
  21. package/build/range-control/utils.js.map +1 -1
  22. package/build/tree-grid/index.js +13 -8
  23. package/build/tree-grid/index.js.map +1 -1
  24. package/build/unit-control/index.js +2 -2
  25. package/build/unit-control/index.js.map +1 -1
  26. package/build/unit-control/index.native.js +10 -2
  27. package/build/unit-control/index.native.js.map +1 -1
  28. package/build/unit-control/styles/unit-control-styles.js +21 -32
  29. package/build/unit-control/styles/unit-control-styles.js.map +1 -1
  30. package/build/utils/hooks/use-controlled-state.js +2 -3
  31. package/build/utils/hooks/use-controlled-state.js.map +1 -1
  32. package/build-module/autocomplete/get-default-use-items.js +1 -1
  33. package/build-module/autocomplete/get-default-use-items.js.map +1 -1
  34. package/build-module/box-control/unit-control.js +0 -1
  35. package/build-module/box-control/unit-control.js.map +1 -1
  36. package/build-module/button/index.js +5 -1
  37. package/build-module/button/index.js.map +1 -1
  38. package/build-module/drop-zone/index.js +7 -1
  39. package/build-module/drop-zone/index.js.map +1 -1
  40. package/build-module/higher-order/with-filters/index.js +2 -2
  41. package/build-module/higher-order/with-filters/index.js.map +1 -1
  42. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -1
  43. package/build-module/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js.map +1 -1
  44. package/build-module/mobile/link-picker/link-picker-results.native.js +1 -1
  45. package/build-module/mobile/link-picker/link-picker-results.native.js.map +1 -1
  46. package/build-module/range-control/input-range.js +1 -14
  47. package/build-module/range-control/input-range.js.map +1 -1
  48. package/build-module/range-control/tooltip.js +1 -1
  49. package/build-module/range-control/tooltip.js.map +1 -1
  50. package/build-module/range-control/utils.js +2 -57
  51. package/build-module/range-control/utils.js.map +1 -1
  52. package/build-module/tree-grid/index.js +13 -8
  53. package/build-module/tree-grid/index.js.map +1 -1
  54. package/build-module/unit-control/index.js +2 -2
  55. package/build-module/unit-control/index.js.map +1 -1
  56. package/build-module/unit-control/index.native.js +10 -2
  57. package/build-module/unit-control/index.native.js.map +1 -1
  58. package/build-module/unit-control/styles/unit-control-styles.js +20 -31
  59. package/build-module/unit-control/styles/unit-control-styles.js.map +1 -1
  60. package/build-module/utils/hooks/use-controlled-state.js +3 -4
  61. package/build-module/utils/hooks/use-controlled-state.js.map +1 -1
  62. package/build-types/button/index.d.ts.map +1 -1
  63. package/build-types/drop-zone/index.d.ts.map +1 -1
  64. package/build-types/popover/stories/e2e/index.d.ts +8 -0
  65. package/build-types/popover/stories/e2e/index.d.ts.map +1 -0
  66. package/build-types/range-control/input-range.d.ts.map +1 -1
  67. package/build-types/range-control/stories/index.d.ts.map +1 -1
  68. package/build-types/range-control/types.d.ts +0 -2
  69. package/build-types/range-control/types.d.ts.map +1 -1
  70. package/build-types/range-control/utils.d.ts +1 -12
  71. package/build-types/range-control/utils.d.ts.map +1 -1
  72. package/build-types/unit-control/styles/unit-control-styles.d.ts +1 -4
  73. package/build-types/unit-control/styles/unit-control-styles.d.ts.map +1 -1
  74. package/build-types/utils/hooks/use-controlled-state.d.ts.map +1 -1
  75. package/package.json +17 -17
  76. package/src/autocomplete/get-default-use-items.js +1 -1
  77. package/src/box-control/unit-control.js +0 -1
  78. package/src/button/index.js +7 -1
  79. package/src/button/test/index.js +36 -0
  80. package/src/color-palette/test/__snapshots__/index.js.snap +169 -1106
  81. package/src/color-palette/test/index.js +107 -61
  82. package/src/drop-zone/index.tsx +4 -1
  83. package/src/font-size-picker/stories/e2e/index.js +47 -0
  84. package/src/higher-order/with-filters/index.js +2 -2
  85. package/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js +1 -2
  86. package/src/mobile/link-picker/link-picker-results.native.js +1 -1
  87. package/src/popover/stories/e2e/index.tsx +25 -0
  88. package/src/range-control/README.md +6 -7
  89. package/src/range-control/input-range.tsx +1 -21
  90. package/src/range-control/stories/index.tsx +2 -1
  91. package/src/range-control/tooltip.tsx +1 -1
  92. package/src/range-control/types.ts +0 -2
  93. package/src/range-control/utils.ts +3 -75
  94. package/src/tree-grid/index.js +23 -14
  95. package/src/tree-grid/test/__snapshots__/cell.js.snap +21 -17
  96. package/src/tree-grid/test/__snapshots__/index.js.snap +1 -1
  97. package/src/unit-control/index.native.js +8 -0
  98. package/src/unit-control/index.tsx +2 -2
  99. package/src/unit-control/styles/unit-control-styles.ts +0 -20
  100. package/src/unit-control/test/index.tsx +6 -3
  101. package/src/utils/hooks/use-controlled-state.js +9 -6
  102. package/tsconfig.tsbuildinfo +1 -1
  103. package/src/unit-control/test/__snapshots__/index.tsx.snap +0 -31
package/CHANGELOG.md CHANGED
@@ -2,24 +2,31 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- ### Bug Fix
6
-
7
- - The `LinkedButton` to unlink sides in `BoxControl`, `BorderBoxControl` and `BorderRadiusControl` have changed from a rectangular primary button to an icon-only button, with a sentence case tooltip, and default-size icon for better legibility. The `Button` component has been fixed so when `isSmall` and `icon` props are set, and no text is present, the button shape is square rather than rectangular.
5
+ ## 21.1.0 (2022-09-21)
8
6
 
9
- ### New Features
7
+ ### Deprecations
10
8
 
11
9
  - `Popover`: added new `anchor` prop, supposed to supersede all previous anchor-related props (`anchorRef`, `anchorRect`, `getAnchorRect`). These older anchor-related props are now marked as deprecated and are scheduled to be removed in WordPress 6.3 ([#43691](https://github.com/WordPress/gutenberg/pull/43691)).
12
10
 
11
+ ### Bug Fix
12
+
13
+ - `Button`: Remove unexpected `has-text` class when empty children are passed ([#44198](https://github.com/WordPress/gutenberg/pull/44198)).
14
+ - The `LinkedButton` to unlink sides in `BoxControl`, `BorderBoxControl` and `BorderRadiusControl` have changed from a rectangular primary button to an icon-only button, with a sentence case tooltip, and default-size icon for better legibility. The `Button` component has been fixed so when `isSmall` and `icon` props are set, and no text is present, the button shape is square rather than rectangular.
15
+
13
16
  ### Internal
14
17
 
15
18
  - `NavigationMenu` updated to ignore `react/exhaustive-deps` eslint rule ([#44090](https://github.com/WordPress/gutenberg/pull/44090)).
19
+ - `RangeControl`: updated to pass `react/exhaustive-deps` eslint rule ([#44271](https://github.com/WordPress/gutenberg/pull/44271)).
20
+ - `UnitControl` updated to pass the `react/exhaustive-deps` eslint rule ([#44161](https://github.com/WordPress/gutenberg/pull/44161)).
16
21
 
17
22
  ## 21.0.0 (2022-09-13)
18
23
 
19
- ### Breaking Changes
24
+ ### Deprecations
20
25
 
21
26
  - `FontSizePicker`: Deprecate bottom margin style. Add a `__nextHasNoMarginBottom` prop to start opting into the margin-free styles that will become the default in a future version, currently scheduled to be WordPress 6.4 ([#43870](https://github.com/WordPress/gutenberg/pull/43870)).
22
27
  - `AnglePickerControl`: Deprecate bottom margin style. Add a `__nextHasNoMarginBottom` prop to start opting into the margin-free styles that will become the default in a future version, currently scheduled to be WordPress 6.4 ([#43867](https://github.com/WordPress/gutenberg/pull/43867)).
28
+ - `Popover`: deprecate `__unstableShift` prop in favour of new `shift` prop. The `__unstableShift` is currently scheduled for removal in WordPress 6.3 ([#43845](https://github.com/WordPress/gutenberg/pull/43845)).
29
+ - `Popover`: removed the `__unstableObserveElement` prop, which is not necessary anymore. The functionality is now supported directly by the component without the need of an external prop ([#43617](https://github.com/WordPress/gutenberg/pull/43617)).
23
30
 
24
31
  ### Bug Fix
25
32
 
@@ -40,12 +47,12 @@
40
47
  - `RangeControl`: Tweak dark gray marking color to be consistent with the grays in `@wordpress/base-styles` ([#43773](https://github.com/WordPress/gutenberg/pull/43773)).
41
48
  - `UnitControl`: Tweak unit dropdown color to be consistent with the grays in `@wordpress/base-styles` ([#43773](https://github.com/WordPress/gutenberg/pull/43773)).
42
49
  - `SearchControl`: Add `__nextHasNoMargin` prop for opting into the new margin-free styles ([#43871](https://github.com/WordPress/gutenberg/pull/43871)).
50
+ - `UnitControl`: Consistently hide spin buttons ([#43985](https://github.com/WordPress/gutenberg/pull/43985)).
43
51
  - `CardHeader`, `CardBody`, `CardFooter`: Tweak `isShady` background colors to be consistent with the grays in `@wordpress/base-styles` ([#43719](https://github.com/WordPress/gutenberg/pull/43719)).
44
52
  - `InputControl`, `SelectControl`: Tweak `disabled` colors to be consistent with the grays in `@wordpress/base-styles` ([#43719](https://github.com/WordPress/gutenberg/pull/43719)).
45
53
  - `FocalPointPicker`: Tweak media placeholder background color to be consistent with the grays in `@wordpress/base-styles` ([#43994](https://github.com/WordPress/gutenberg/pull/43994)).
46
54
  - `RangeControl`: Tweak rail, track, and mark colors to be consistent with the grays in `@wordpress/base-styles` ([#43994](https://github.com/WordPress/gutenberg/pull/43994)).
47
55
  - `UnitControl`: Tweak unit dropdown hover color to be consistent with the grays in `@wordpress/base-styles` ([#43994](https://github.com/WordPress/gutenberg/pull/43994)).
48
- - `Popover`: stabilize `__unstableShift` to `shift` ([#43845](https://github.com/WordPress/gutenberg/pull/43845)).
49
56
 
50
57
  ### Internal
51
58
 
@@ -77,12 +84,14 @@
77
84
  - `IsolatedEventContainer`: Refactor tests to `@testing-library/react` ([#44073](https://github.com/WordPress/gutenberg/pull/44073)).
78
85
  - `KeyboardShortcuts`: Refactor tests to `@testing-library/react` ([#44075](https://github.com/WordPress/gutenberg/pull/44075)).
79
86
  - `Slot`/`Fill`: Refactor tests to `@testing-library/react` ([#44084](https://github.com/WordPress/gutenberg/pull/44084)).
87
+ - `ColorPalette`: Refactor tests to `@testing-library/react` ([#44108](https://github.com/WordPress/gutenberg/pull/44108)).
80
88
 
81
89
  ## 20.0.0 (2022-08-24)
82
90
 
83
- ### Breaking Changes
91
+ ### Deprecations
84
92
 
85
93
  - `CustomSelectControl`: Deprecate constrained width style. Add a `__nextUnconstrainedWidth` prop to start opting into the unconstrained width that will become the default in a future version, currently scheduled to be WordPress 6.4 ([#43230](https://github.com/WordPress/gutenberg/pull/43230)).
94
+ - `Popover`: deprecate `__unstableForcePosition` prop in favour of new `flip` and `resize` props. The `__unstableForcePosition` is currently scheduled for removal in WordPress 6.3 ([#43546](https://github.com/WordPress/gutenberg/pull/43546)).
86
95
 
87
96
  ### Bug Fix
88
97
 
@@ -7,10 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = getDefaultUseItems;
9
9
 
10
- var _lodash = require("lodash");
11
-
12
10
  var _removeAccents = _interopRequireDefault(require("remove-accents"));
13
11
 
12
+ var _compose = require("@wordpress/compose");
13
+
14
14
  var _element = require("@wordpress/element");
15
15
 
16
16
  var _strings = require("../utils/strings");
@@ -78,7 +78,7 @@ function getDefaultUseItems(autocompleter) {
78
78
  options,
79
79
  isDebounced
80
80
  } = autocompleter;
81
- const loadOptions = (0, _lodash.debounce)(() => {
81
+ const loadOptions = (0, _compose.debounce)(() => {
82
82
  const promise = Promise.resolve(typeof options === 'function' ? options(filterValue) : options).then(optionsData => {
83
83
  if (promise.canceled) {
84
84
  return;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/autocomplete/get-default-use-items.js"],"names":["filterOptions","search","options","maxResults","filtered","i","length","option","keywords","label","isMatch","some","keyword","test","push","getDefaultUseItems","autocompleter","filterValue","items","setItems","isDebounced","loadOptions","promise","Promise","resolve","then","optionsData","canceled","keyedOptions","map","optionData","optionIndex","key","name","value","getOptionLabel","getOptionKeywords","isDisabled","isOptionDisabled","RegExp","cancel"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AAKA;;AAdA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AAGA,SAASA,aAAT,CAAwBC,MAAxB,EAAgE;AAAA,MAAhCC,OAAgC,uEAAtB,EAAsB;AAAA,MAAlBC,UAAkB,uEAAL,EAAK;AAC/D,QAAMC,QAAQ,GAAG,EAAjB;;AACA,OAAM,IAAIC,CAAC,GAAG,CAAd,EAAiBA,CAAC,GAAGH,OAAO,CAACI,MAA7B,EAAqCD,CAAC,EAAtC,EAA2C;AAC1C,UAAME,MAAM,GAAGL,OAAO,CAAEG,CAAF,CAAtB,CAD0C,CAG1C;;AACA,QAAI;AAAEG,MAAAA,QAAQ,GAAG;AAAb,QAAoBD,MAAxB;;AACA,QAAK,aAAa,OAAOA,MAAM,CAACE,KAAhC,EAAwC;AACvCD,MAAAA,QAAQ,GAAG,CAAE,GAAGA,QAAL,EAAeD,MAAM,CAACE,KAAtB,CAAX;AACA;;AAED,UAAMC,OAAO,GAAGF,QAAQ,CAACG,IAAT,CAAiBC,OAAF,IAC9BX,MAAM,CAACY,IAAP,CAAa,4BAAeD,OAAf,CAAb,CADe,CAAhB;;AAGA,QAAK,CAAEF,OAAP,EAAiB;AAChB;AACA;;AAEDN,IAAAA,QAAQ,CAACU,IAAT,CAAeP,MAAf,EAhB0C,CAkB1C;;AACA,QAAKH,QAAQ,CAACE,MAAT,KAAoBH,UAAzB,EAAsC;AACrC;AACA;AACD;;AAED,SAAOC,QAAP;AACA;;AAEc,SAASW,kBAAT,CAA6BC,aAA7B,EAA6C;AAC3D,SAASC,WAAF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AxCD,CAApB;AA2CA,YAAME,OAAO,GAAGD,WAAW,EAA3B;AAEA,aAAO,MAAM;AACZA,QAAAA,WAAW,CAACmB,MAAZ;;AACA,YAAKlB,OAAL,EAAe;AACdA,UAAAA,OAAO,CAACK,QAAR,GAAmB,IAAnB;AACA;AACD,OALD;AAMA,KArDD,EAqDG,CAAEV,WAAF,CArDH;AAuDA,WAAO,CAAEC,KAAF,CAAP;AACA,GArED;AAsEA","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { useLayoutEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { escapeRegExp } from '../utils/strings';\n\nfunction filterOptions( search, options = [], maxResults = 10 ) {\n\tconst filtered = [];\n\tfor ( let i = 0; i < options.length; i++ ) {\n\t\tconst option = options[ i ];\n\n\t\t// Merge label into keywords.\n\t\tlet { keywords = [] } = option;\n\t\tif ( 'string' === typeof option.label ) {\n\t\t\tkeywords = [ ...keywords, option.label ];\n\t\t}\n\n\t\tconst isMatch = keywords.some( ( keyword ) =>\n\t\t\tsearch.test( removeAccents( keyword ) )\n\t\t);\n\t\tif ( ! isMatch ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfiltered.push( option );\n\n\t\t// Abort early if max reached.\n\t\tif ( filtered.length === maxResults ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn filtered;\n}\n\nexport default function getDefaultUseItems( autocompleter ) {\n\treturn ( filterValue ) => {\n\t\tconst [ items, setItems ] = useState( [] );\n\t\t/*\n\t\t * We support both synchronous and asynchronous retrieval of completer options\n\t\t * but internally treat all as async so we maintain a single, consistent code path.\n\t\t *\n\t\t * Because networks can be slow, and the internet is wonderfully unpredictable,\n\t\t * we don't want two promises updating the state at once. This ensures that only\n\t\t * the most recent promise will act on `optionsData`. This doesn't use the state\n\t\t * because `setState` is batched, and so there's no guarantee that setting\n\t\t * `activePromise` in the state would result in it actually being in `this.state`\n\t\t * before the promise resolves and we check to see if this is the active promise or not.\n\t\t */\n\t\tuseLayoutEffect( () => {\n\t\t\tconst { options, isDebounced } = autocompleter;\n\t\t\tconst loadOptions = debounce(\n\t\t\t\t() => {\n\t\t\t\t\tconst promise = Promise.resolve(\n\t\t\t\t\t\ttypeof options === 'function'\n\t\t\t\t\t\t\t? options( filterValue )\n\t\t\t\t\t\t\t: options\n\t\t\t\t\t).then( ( optionsData ) => {\n\t\t\t\t\t\tif ( promise.canceled ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst keyedOptions = optionsData.map(\n\t\t\t\t\t\t\t( optionData, optionIndex ) => ( {\n\t\t\t\t\t\t\t\tkey: `${ autocompleter.name }-${ optionIndex }`,\n\t\t\t\t\t\t\t\tvalue: optionData,\n\t\t\t\t\t\t\t\tlabel: autocompleter.getOptionLabel(\n\t\t\t\t\t\t\t\t\toptionData\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tkeywords: autocompleter.getOptionKeywords\n\t\t\t\t\t\t\t\t\t? autocompleter.getOptionKeywords(\n\t\t\t\t\t\t\t\t\t\t\toptionData\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: [],\n\t\t\t\t\t\t\t\tisDisabled: autocompleter.isOptionDisabled\n\t\t\t\t\t\t\t\t\t? autocompleter.isOptionDisabled(\n\t\t\t\t\t\t\t\t\t\t\toptionData\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: false,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Create a regular expression to filter the options.\n\t\t\t\t\t\tconst search = new RegExp(\n\t\t\t\t\t\t\t'(?:\\\\b|\\\\s|^)' + escapeRegExp( filterValue ),\n\t\t\t\t\t\t\t'i'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsetItems( filterOptions( search, keyedOptions ) );\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn promise;\n\t\t\t\t},\n\t\t\t\tisDebounced ? 250 : 0\n\t\t\t);\n\n\t\t\tconst promise = loadOptions();\n\n\t\t\treturn () => {\n\t\t\t\tloadOptions.cancel();\n\t\t\t\tif ( promise ) {\n\t\t\t\t\tpromise.canceled = true;\n\t\t\t\t}\n\t\t\t};\n\t\t}, [ filterValue ] );\n\n\t\treturn [ items ];\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/autocomplete/get-default-use-items.js"],"names":["filterOptions","search","options","maxResults","filtered","i","length","option","keywords","label","isMatch","some","keyword","test","push","getDefaultUseItems","autocompleter","filterValue","items","setItems","isDebounced","loadOptions","promise","Promise","resolve","then","optionsData","canceled","keyedOptions","map","optionData","optionIndex","key","name","value","getOptionLabel","getOptionKeywords","isDisabled","isOptionDisabled","RegExp","cancel"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAGA,SAASA,aAAT,CAAwBC,MAAxB,EAAgE;AAAA,MAAhCC,OAAgC,uEAAtB,EAAsB;AAAA,MAAlBC,UAAkB,uEAAL,EAAK;AAC/D,QAAMC,QAAQ,GAAG,EAAjB;;AACA,OAAM,IAAIC,CAAC,GAAG,CAAd,EAAiBA,CAAC,GAAGH,OAAO,CAACI,MAA7B,EAAqCD,CAAC,EAAtC,EAA2C;AAC1C,UAAME,MAAM,GAAGL,OAAO,CAAEG,CAAF,CAAtB,CAD0C,CAG1C;;AACA,QAAI;AAAEG,MAAAA,QAAQ,GAAG;AAAb,QAAoBD,MAAxB;;AACA,QAAK,aAAa,OAAOA,MAAM,CAACE,KAAhC,EAAwC;AACvCD,MAAAA,QAAQ,GAAG,CAAE,GAAGA,QAAL,EAAeD,MAAM,CAACE,KAAtB,CAAX;AACA;;AAED,UAAMC,OAAO,GAAGF,QAAQ,CAACG,IAAT,CAAiBC,OAAF,IAC9BX,MAAM,CAACY,IAAP,CAAa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AAf6B,WAAjC,CADoB,CAArB,CAJ0B,CAwB1B;;AACA,gBAAM7B,MAAM,GAAG,IAAIsC,MAAJ,CACd,kBAAkB,2BAActB,WAAd,CADJ,EAEd,GAFc,CAAf;AAIAE,UAAAA,QAAQ,CAAEnB,aAAa,CAAEC,MAAF,EAAU2B,YAAV,CAAf,CAAR;AACA,SAlCe,CAAhB;AAoCA,eAAON,OAAP;AACA,OAvCkB,EAwCnBF,WAAW,GAAG,GAAH,GAAS,CAxCD,CAApB;AA2CA,YAAME,OAAO,GAAGD,WAAW,EAA3B;AAEA,aAAO,MAAM;AACZA,QAAAA,WAAW,CAACmB,MAAZ;;AACA,YAAKlB,OAAL,EAAe;AACdA,UAAAA,OAAO,CAACK,QAAR,GAAmB,IAAnB;AACA;AACD,OALD;AAMA,KArDD,EAqDG,CAAEV,WAAF,CArDH;AAuDA,WAAO,CAAEC,KAAF,CAAP;AACA,GArED;AAsEA","sourcesContent":["/**\n * External dependencies\n */\nimport removeAccents from 'remove-accents';\n\n/**\n * WordPress dependencies\n */\nimport { debounce } from '@wordpress/compose';\nimport { useLayoutEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { escapeRegExp } from '../utils/strings';\n\nfunction filterOptions( search, options = [], maxResults = 10 ) {\n\tconst filtered = [];\n\tfor ( let i = 0; i < options.length; i++ ) {\n\t\tconst option = options[ i ];\n\n\t\t// Merge label into keywords.\n\t\tlet { keywords = [] } = option;\n\t\tif ( 'string' === typeof option.label ) {\n\t\t\tkeywords = [ ...keywords, option.label ];\n\t\t}\n\n\t\tconst isMatch = keywords.some( ( keyword ) =>\n\t\t\tsearch.test( removeAccents( keyword ) )\n\t\t);\n\t\tif ( ! isMatch ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfiltered.push( option );\n\n\t\t// Abort early if max reached.\n\t\tif ( filtered.length === maxResults ) {\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn filtered;\n}\n\nexport default function getDefaultUseItems( autocompleter ) {\n\treturn ( filterValue ) => {\n\t\tconst [ items, setItems ] = useState( [] );\n\t\t/*\n\t\t * We support both synchronous and asynchronous retrieval of completer options\n\t\t * but internally treat all as async so we maintain a single, consistent code path.\n\t\t *\n\t\t * Because networks can be slow, and the internet is wonderfully unpredictable,\n\t\t * we don't want two promises updating the state at once. This ensures that only\n\t\t * the most recent promise will act on `optionsData`. This doesn't use the state\n\t\t * because `setState` is batched, and so there's no guarantee that setting\n\t\t * `activePromise` in the state would result in it actually being in `this.state`\n\t\t * before the promise resolves and we check to see if this is the active promise or not.\n\t\t */\n\t\tuseLayoutEffect( () => {\n\t\t\tconst { options, isDebounced } = autocompleter;\n\t\t\tconst loadOptions = debounce(\n\t\t\t\t() => {\n\t\t\t\t\tconst promise = Promise.resolve(\n\t\t\t\t\t\ttypeof options === 'function'\n\t\t\t\t\t\t\t? options( filterValue )\n\t\t\t\t\t\t\t: options\n\t\t\t\t\t).then( ( optionsData ) => {\n\t\t\t\t\t\tif ( promise.canceled ) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tconst keyedOptions = optionsData.map(\n\t\t\t\t\t\t\t( optionData, optionIndex ) => ( {\n\t\t\t\t\t\t\t\tkey: `${ autocompleter.name }-${ optionIndex }`,\n\t\t\t\t\t\t\t\tvalue: optionData,\n\t\t\t\t\t\t\t\tlabel: autocompleter.getOptionLabel(\n\t\t\t\t\t\t\t\t\toptionData\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\tkeywords: autocompleter.getOptionKeywords\n\t\t\t\t\t\t\t\t\t? autocompleter.getOptionKeywords(\n\t\t\t\t\t\t\t\t\t\t\toptionData\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: [],\n\t\t\t\t\t\t\t\tisDisabled: autocompleter.isOptionDisabled\n\t\t\t\t\t\t\t\t\t? autocompleter.isOptionDisabled(\n\t\t\t\t\t\t\t\t\t\t\toptionData\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: false,\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Create a regular expression to filter the options.\n\t\t\t\t\t\tconst search = new RegExp(\n\t\t\t\t\t\t\t'(?:\\\\b|\\\\s|^)' + escapeRegExp( filterValue ),\n\t\t\t\t\t\t\t'i'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tsetItems( filterOptions( search, keyedOptions ) );\n\t\t\t\t\t} );\n\n\t\t\t\t\treturn promise;\n\t\t\t\t},\n\t\t\t\tisDebounced ? 250 : 0\n\t\t\t);\n\n\t\t\tconst promise = loadOptions();\n\n\t\t\treturn () => {\n\t\t\t\tloadOptions.cancel();\n\t\t\t\tif ( promise ) {\n\t\t\t\t\tpromise.canceled = true;\n\t\t\t\t}\n\t\t\t};\n\t\t}, [ filterValue ] );\n\n\t\treturn [ items ];\n\t};\n}\n"]}
@@ -54,7 +54,6 @@ function BoxUnitControl(_ref) {
54
54
  }, (0, _element.createElement)(_boxControlStyles.UnitControl, (0, _extends2.default)({
55
55
  "aria-label": label,
56
56
  className: "component-box-control__unit-control",
57
- hideHTMLArrows: true,
58
57
  isFirst: isFirst,
59
58
  isLast: isLast,
60
59
  isOnly: isOnly,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/box-control/unit-control.js"],"names":["noop","BoxUnitControl","isFirst","isLast","isOnly","onHoverOn","onHoverOff","label","value","props","bindHoverGesture","event","state","hovering","Tooltip","children","text"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEe,SAASC,cAAT,OASX;AAAA,MAToC;AACvCC,IAAAA,OADuC;AAEvCC,IAAAA,MAFuC;AAGvCC,IAAAA,MAHuC;AAIvCC,IAAAA,SAAS,GAAGL,IAJ2B;AAKvCM,IAAAA,UAAU,GAAGN,IAL0B;AAMvCO,IAAAA,KANuC;AAOvCC,IAAAA,KAPuC;AAQvC,OAAGC;AARoC,GASpC;AACH,QAAMC,gBAAgB,GAAG,qBAAU,SAA2B;AAAA,QAAzB;AAAEC,MAAAA,KAAF;AAAS,SAAGC;AAAZ,KAAyB;;AAC7D,QAAKA,KAAK,CAACC,QAAX,EAAsB;AACrBR,MAAAA,SAAS,CAAEM,KAAF,EAASC,KAAT,CAAT;AACA,KAFD,MAEO;AACNN,MAAAA,UAAU,CAAEK,KAAF,EAASC,KAAT,CAAV;AACA;AACD,GANwB,CAAzB;AAQA,SACC,4BAAC,oCAAD,EAAyBF,gBAAgB,EAAzC,EACC,4BAAC,OAAD;AAAS,IAAA,IAAI,EAAGH;AAAhB,KACC,4BAAC,6BAAD;AACC,kBAAaA,KADd;AAEC,IAAA,SAAS,EAAC,qCAFX;AAGC,IAAA,cAAc,MAHf;AAIC,IAAA,OAAO,EAAGL,OAJX;AAKC,IAAA,MAAM,EAAGC,MALV;AAMC,IAAA,MAAM,EAAGC,MANV;AAOC,IAAA,oBAAoB,MAPrB;AAQC,IAAA,wBAAwB,EAAG,KAR5B;AASC,IAAA,KAAK,EAAGI;AATT,KAUMC,KAVN,EADD,CADD,CADD;AAkBA;;AAED,SAASK,OAAT,QAAuC;AAAA,MAArB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAqB;AACtC,MAAK,CAAEA,IAAP,EAAc,OAAOD,QAAP;AAEd;AACD;AACA;AACA;AACA;AACA;AACA;AACA;;AACC,SACC,4BAAC,gBAAD;AAAa,IAAA,IAAI,EAAGC,IAApB;AAA2B,IAAA,QAAQ,EAAC;AAApC,KACC,yCAAOD,QAAP,CADD,CADD;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport { useHover } from '@use-gesture/react';\n\n/**\n * Internal dependencies\n */\nimport BaseTooltip from '../tooltip';\nimport { UnitControlWrapper, UnitControl } from './styles/box-control-styles';\n\nconst noop = () => {};\n\nexport default function BoxUnitControl( {\n\tisFirst,\n\tisLast,\n\tisOnly,\n\tonHoverOn = noop,\n\tonHoverOff = noop,\n\tlabel,\n\tvalue,\n\t...props\n} ) {\n\tconst bindHoverGesture = useHover( ( { event, ...state } ) => {\n\t\tif ( state.hovering ) {\n\t\t\tonHoverOn( event, state );\n\t\t} else {\n\t\t\tonHoverOff( event, state );\n\t\t}\n\t} );\n\n\treturn (\n\t\t<UnitControlWrapper { ...bindHoverGesture() }>\n\t\t\t<Tooltip text={ label }>\n\t\t\t\t<UnitControl\n\t\t\t\t\taria-label={ label }\n\t\t\t\t\tclassName=\"component-box-control__unit-control\"\n\t\t\t\t\thideHTMLArrows\n\t\t\t\t\tisFirst={ isFirst }\n\t\t\t\t\tisLast={ isLast }\n\t\t\t\t\tisOnly={ isOnly }\n\t\t\t\t\tisPressEnterToChange\n\t\t\t\t\tisResetValueOnUnitChange={ false }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\t{ ...props }\n\t\t\t\t/>\n\t\t\t</Tooltip>\n\t\t</UnitControlWrapper>\n\t);\n}\n\nfunction Tooltip( { children, text } ) {\n\tif ( ! text ) return children;\n\n\t/**\n\t * Wrapping the children in a `<div />` as Tooltip as it attempts\n\t * to render the <UnitControl />. Using a plain `<div />` appears to\n\t * resolve this issue.\n\t *\n\t * Originally discovered and referenced here:\n\t * https://github.com/WordPress/gutenberg/pull/24966#issuecomment-685875026\n\t */\n\treturn (\n\t\t<BaseTooltip text={ text } position=\"top\">\n\t\t\t<div>{ children }</div>\n\t\t</BaseTooltip>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/box-control/unit-control.js"],"names":["noop","BoxUnitControl","isFirst","isLast","isOnly","onHoverOn","onHoverOff","label","value","props","bindHoverGesture","event","state","hovering","Tooltip","children","text"],"mappings":";;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;AAIA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEe,SAASC,cAAT,OASX;AAAA,MAToC;AACvCC,IAAAA,OADuC;AAEvCC,IAAAA,MAFuC;AAGvCC,IAAAA,MAHuC;AAIvCC,IAAAA,SAAS,GAAGL,IAJ2B;AAKvCM,IAAAA,UAAU,GAAGN,IAL0B;AAMvCO,IAAAA,KANuC;AAOvCC,IAAAA,KAPuC;AAQvC,OAAGC;AARoC,GASpC;AACH,QAAMC,gBAAgB,GAAG,qBAAU,SAA2B;AAAA,QAAzB;AAAEC,MAAAA,KAAF;AAAS,SAAGC;AAAZ,KAAyB;;AAC7D,QAAKA,KAAK,CAACC,QAAX,EAAsB;AACrBR,MAAAA,SAAS,CAAEM,KAAF,EAASC,KAAT,CAAT;AACA,KAFD,MAEO;AACNN,MAAAA,UAAU,CAAEK,KAAF,EAASC,KAAT,CAAV;AACA;AACD,GANwB,CAAzB;AAQA,SACC,4BAAC,oCAAD,EAAyBF,gBAAgB,EAAzC,EACC,4BAAC,OAAD;AAAS,IAAA,IAAI,EAAGH;AAAhB,KACC,4BAAC,6BAAD;AACC,kBAAaA,KADd;AAEC,IAAA,SAAS,EAAC,qCAFX;AAGC,IAAA,OAAO,EAAGL,OAHX;AAIC,IAAA,MAAM,EAAGC,MAJV;AAKC,IAAA,MAAM,EAAGC,MALV;AAMC,IAAA,oBAAoB,MANrB;AAOC,IAAA,wBAAwB,EAAG,KAP5B;AAQC,IAAA,KAAK,EAAGI;AART,KASMC,KATN,EADD,CADD,CADD;AAiBA;;AAED,SAASK,OAAT,QAAuC;AAAA,MAArB;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAqB;AACtC,MAAK,CAAEA,IAAP,EAAc,OAAOD,QAAP;AAEd;AACD;AACA;AACA;AACA;AACA;AACA;AACA;;AACC,SACC,4BAAC,gBAAD;AAAa,IAAA,IAAI,EAAGC,IAApB;AAA2B,IAAA,QAAQ,EAAC;AAApC,KACC,yCAAOD,QAAP,CADD,CADD;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport { useHover } from '@use-gesture/react';\n\n/**\n * Internal dependencies\n */\nimport BaseTooltip from '../tooltip';\nimport { UnitControlWrapper, UnitControl } from './styles/box-control-styles';\n\nconst noop = () => {};\n\nexport default function BoxUnitControl( {\n\tisFirst,\n\tisLast,\n\tisOnly,\n\tonHoverOn = noop,\n\tonHoverOff = noop,\n\tlabel,\n\tvalue,\n\t...props\n} ) {\n\tconst bindHoverGesture = useHover( ( { event, ...state } ) => {\n\t\tif ( state.hovering ) {\n\t\t\tonHoverOn( event, state );\n\t\t} else {\n\t\t\tonHoverOff( event, state );\n\t\t}\n\t} );\n\n\treturn (\n\t\t<UnitControlWrapper { ...bindHoverGesture() }>\n\t\t\t<Tooltip text={ label }>\n\t\t\t\t<UnitControl\n\t\t\t\t\taria-label={ label }\n\t\t\t\t\tclassName=\"component-box-control__unit-control\"\n\t\t\t\t\tisFirst={ isFirst }\n\t\t\t\t\tisLast={ isLast }\n\t\t\t\t\tisOnly={ isOnly }\n\t\t\t\t\tisPressEnterToChange\n\t\t\t\t\tisResetValueOnUnitChange={ false }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\t{ ...props }\n\t\t\t\t/>\n\t\t\t</Tooltip>\n\t\t</UnitControlWrapper>\n\t);\n}\n\nfunction Tooltip( { children, text } ) {\n\tif ( ! text ) return children;\n\n\t/**\n\t * Wrapping the children in a `<div />` as Tooltip as it attempts\n\t * to render the <UnitControl />. Using a plain `<div />` appears to\n\t * resolve this issue.\n\t *\n\t * Originally discovered and referenced here:\n\t * https://github.com/WordPress/gutenberg/pull/24966#issuecomment-685875026\n\t */\n\treturn (\n\t\t<BaseTooltip text={ text } position=\"top\">\n\t\t\t<div>{ children }</div>\n\t\t</BaseTooltip>\n\t);\n}\n"]}
@@ -92,6 +92,8 @@ function useDeprecatedProps(_ref) {
92
92
  }
93
93
 
94
94
  function Button(props, ref) {
95
+ var _children$, _children$$props;
96
+
95
97
  const {
96
98
  href,
97
99
  target,
@@ -116,6 +118,8 @@ function Button(props, ref) {
116
118
  ...additionalProps
117
119
  } = useDeprecatedProps(props);
118
120
  const instanceId = (0, _compose.useInstanceId)(Button, 'components-button__description');
121
+ const hasChildren = (children === null || children === void 0 ? void 0 : children[0]) && children[0] !== null && // Tooltip should not considered as a child
122
+ (children === null || children === void 0 ? void 0 : (_children$ = children[0]) === null || _children$ === void 0 ? void 0 : (_children$$props = _children$.props) === null || _children$$props === void 0 ? void 0 : _children$$props.className) !== 'components-tooltip';
119
123
  const classes = (0, _classnames.default)('components-button', className, {
120
124
  'is-secondary': variant === 'secondary',
121
125
  'is-primary': variant === 'primary',
@@ -125,7 +129,7 @@ function Button(props, ref) {
125
129
  'is-busy': isBusy,
126
130
  'is-link': variant === 'link',
127
131
  'is-destructive': isDestructive,
128
- 'has-text': !!icon && !!children,
132
+ 'has-text': !!icon && hasChildren,
129
133
  'has-icon': !!icon
130
134
  });
131
135
  const trulyDisabled = disabled && !isFocusable;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/button/index.js"],"names":["disabledEventsOnDisabledButton","useDeprecatedProps","isDefault","isPrimary","isSecondary","isTertiary","isLink","variant","otherProps","computedVariant","since","alternative","version","Button","props","ref","href","target","isSmall","isPressed","isBusy","isDestructive","className","disabled","icon","iconPosition","iconSize","showTooltip","tooltipPosition","shortcut","label","children","text","__experimentalIsFocusable","isFocusable","describedBy","additionalProps","instanceId","classes","trulyDisabled","Tag","undefined","tagProps","type","disabledEvent","event","stopPropagation","preventDefault","shouldShowTooltip","length","descriptionId","describedById","element"],"mappings":";;;;;;;;;;AAUA;;;;AANA;;AAKA;;AAEA;;AAKA;;AACA;;AACA;;AAlBA;;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAKA,MAAMA,8BAA8B,GAAG,CAAE,aAAF,EAAiB,SAAjB,CAAvC;;AAEA,SAASC,kBAAT,OAQI;AAAA,MARyB;AAC5BC,IAAAA,SAD4B;AAE5BC,IAAAA,SAF4B;AAG5BC,IAAAA,WAH4B;AAI5BC,IAAAA,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CA,WAAlC,GAAgDL,KADxD;AAEC,IAAA,QAAQ,EAAGD,QAFZ;AAGC,IAAA,QAAQ,EAAGD;AAHZ,KAKGwB,OALH,CADD,EAQGjB,WAAW,IACZ,4BAAC,8BAAD,QACC;AAAM,IAAA,EAAE,EAAGe;AAAX,KAA6Bf,WAA7B,CADD,CATF,CADD;AAgBA;;eAEc,yBAAYtB,MAAZ,C","sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { forwardRef } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Tooltip from '../tooltip';\nimport Icon from '../icon';\nimport { VisuallyHidden } from '../visually-hidden';\n\nconst disabledEventsOnDisabledButton = [ 'onMouseDown', 'onClick' ];\n\nfunction useDeprecatedProps( {\n\tisDefault,\n\tisPrimary,\n\tisSecondary,\n\tisTertiary,\n\tisLink,\n\tvariant,\n\t...otherProps\n} ) {\n\tlet computedVariant = variant;\n\n\tif ( isPrimary ) {\n\t\tcomputedVariant ??= 'primary';\n\t}\n\n\tif ( isTertiary ) {\n\t\tcomputedVariant ??= 'tertiary';\n\t}\n\n\tif ( isSecondary ) {\n\t\tcomputedVariant ??= 'secondary';\n\t}\n\n\tif ( isDefault ) {\n\t\tdeprecated( 'Button isDefault prop', {\n\t\t\tsince: '5.4',\n\t\t\talternative: 'variant=\"secondary\"',\n\t\t\tversion: '6.2',\n\t\t} );\n\n\t\tcomputedVariant ??= 'secondary';\n\t}\n\n\tif ( isLink ) {\n\t\tcomputedVariant ??= 'link';\n\t}\n\n\treturn {\n\t\t...otherProps,\n\t\tvariant: computedVariant,\n\t};\n}\n\nexport function Button( props, ref ) {\n\tconst {\n\t\thref,\n\t\ttarget,\n\t\tisSmall,\n\t\tisPressed,\n\t\tisBusy,\n\t\tisDestructive,\n\t\tclassName,\n\t\tdisabled,\n\t\ticon,\n\t\ticonPosition = 'left',\n\t\ticonSize,\n\t\tshowTooltip,\n\t\ttooltipPosition,\n\t\tshortcut,\n\t\tlabel,\n\t\tchildren,\n\t\ttext,\n\t\tvariant,\n\t\t__experimentalIsFocusable: isFocusable,\n\t\tdescribedBy,\n\t\t...additionalProps\n\t} = useDeprecatedProps( props );\n\tconst instanceId = useInstanceId(\n\t\tButton,\n\t\t'components-button__description'\n\t);\n\n\tconst classes = classnames( 'components-button', className, {\n\t\t'is-secondary': variant === 'secondary',\n\t\t'is-primary': variant === 'primary',\n\t\t'is-small': isSmall,\n\t\t'is-tertiary': variant === 'tertiary',\n\t\t'is-pressed': isPressed,\n\t\t'is-busy': isBusy,\n\t\t'is-link': variant === 'link',\n\t\t'is-destructive': isDestructive,\n\t\t'has-text': !! icon && !! children,\n\t\t'has-icon': !! icon,\n\t} );\n\n\tconst trulyDisabled = disabled && ! isFocusable;\n\tconst Tag = href !== undefined && ! trulyDisabled ? 'a' : 'button';\n\tconst tagProps =\n\t\tTag === 'a'\n\t\t\t? { href, target }\n\t\t\t: {\n\t\t\t\t\ttype: 'button',\n\t\t\t\t\tdisabled: trulyDisabled,\n\t\t\t\t\t'aria-pressed': isPressed,\n\t\t\t };\n\n\tif ( disabled && isFocusable ) {\n\t\t// In this case, the button will be disabled, but still focusable and\n\t\t// perceivable by screen reader users.\n\t\ttagProps[ 'aria-disabled' ] = true;\n\n\t\tfor ( const disabledEvent of disabledEventsOnDisabledButton ) {\n\t\t\tadditionalProps[ disabledEvent ] = ( event ) => {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tevent.preventDefault();\n\t\t\t};\n\t\t}\n\t}\n\n\t// Should show the tooltip if...\n\tconst shouldShowTooltip =\n\t\t! trulyDisabled &&\n\t\t// An explicit tooltip is passed or...\n\t\t( ( showTooltip && label ) ||\n\t\t\t// There's a shortcut or...\n\t\t\tshortcut ||\n\t\t\t// There's a label and...\n\t\t\t( !! label &&\n\t\t\t\t// The children are empty and...\n\t\t\t\t! children?.length &&\n\t\t\t\t// The tooltip is not explicitly disabled.\n\t\t\t\tfalse !== showTooltip ) );\n\n\tconst descriptionId = describedBy ? instanceId : null;\n\n\tconst describedById =\n\t\tadditionalProps[ 'aria-describedby' ] || descriptionId;\n\n\tconst element = (\n\t\t<Tag\n\t\t\t{ ...tagProps }\n\t\t\t{ ...additionalProps }\n\t\t\tclassName={ classes }\n\t\t\taria-label={ additionalProps[ 'aria-label' ] || label }\n\t\t\taria-describedby={ describedById }\n\t\t\tref={ ref }\n\t\t>\n\t\t\t{ icon && iconPosition === 'left' && (\n\t\t\t\t<Icon icon={ icon } size={ iconSize } />\n\t\t\t) }\n\t\t\t{ text && <>{ text }</> }\n\t\t\t{ icon && iconPosition === 'right' && (\n\t\t\t\t<Icon icon={ icon } size={ iconSize } />\n\t\t\t) }\n\t\t\t{ children }\n\t\t</Tag>\n\t);\n\n\tif ( ! shouldShowTooltip ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ element }\n\t\t\t\t{ describedBy && (\n\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t<span id={ descriptionId }>{ describedBy }</span>\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Tooltip\n\t\t\t\ttext={ children?.length && describedBy ? describedBy : label }\n\t\t\t\tshortcut={ shortcut }\n\t\t\t\tposition={ tooltipPosition }\n\t\t\t>\n\t\t\t\t{ element }\n\t\t\t</Tooltip>\n\t\t\t{ describedBy && (\n\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t<span id={ descriptionId }>{ describedBy }</span>\n\t\t\t\t</VisuallyHidden>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default forwardRef( Button );\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/button/index.js"],"names":["disabledEventsOnDisabledButton","useDeprecatedProps","isDefault","isPrimary","isSecondary","isTertiary","isLink","variant","otherProps","computedVariant","since","alternative","version","Button","props","ref","href","target","isSmall","isPressed","isBusy","isDestructive","className","disabled","icon","iconPosition","iconSize","showTooltip","tooltipPosition","shortcut","label","children","text","__experimentalIsFocusable","isFocusable","describedBy","additionalProps","instanceId","hasChildren","classes","trulyDisabled","Tag","undefined","tagProps","type","disabledEvent","event","stopPropagation","preventDefault","shouldShowTooltip","length","descriptionId","describedById","element"],"mappings":";;;;;;;;;;AAUA;;;;AANA;;AAKA;;AAEA;;AAKA;;AACA;;AACA;;AAlBA;;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAKA,MAAMA,8BAA8B,GAAG,CAAE,aAAF,EAAiB,SAAjB,CAAvC;;AAEA,SAASC,kBAAT,OAQI;AAAA,MARyB;AAC5BC,IAAAA,SAD4B;AAE5BC,IAAAA,SAF4B;AAG5BC,IAAAA,WAH4B;AAI5BC,IAAAA,UAJ4B;AAK5BC,IAAAA,MAL4B;AAM5BC,IAAAA,OAN4B;AAO5B,OAAGC;AAPyB,GAQzB;AACH,MAAIC,eAAe,GAAGF,OAAtB;;AAEA,MAAKJ,SAAL,EAAiB;AAAA;;AAChB,wBAAAM,eAAe,UAAf,qDAAAA,eAAe,GAAK,SAApB;AACA;;AAED,MAAKJ,UAAL,EAAkB;AAAA;;AACjB,yBAAAI,eAAe,UAAf,uDAAAA,eAAe,GAAK,UAApB;AACA;;AAED,MAAKL,WAAL,EAAmB;AAAA;;AAClB,yBAAAK,eAAe,UAAf,uDAAAA,eAAe,GAAK,WAApB;AACA;;AAED,MAAKP,SAAL,EAAiB;AAAA;;AAChB,6BAAY,uBAAZ,EAAqC;AACpCQ,MAAAA,KAAK,EAAE,KAD6B;AAEpCC,MAAAA,WAAW,EAAE,qBAFuB;AAGpCC,MAAAA,OAAO,EAAE;AAH2B,KAArC;AAMA,yBAAAH,eAAe,UAAf,uDAAAA,eAAe,GAAK,WAApB;AACA;;AAED,MAAKH,MAAL,EAAc;AAAA;;AACb,yBAAAG,eAAe,UAAf,uDAAAA,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QAAME,OAAO,GACZ,4BAAC,GAAD,6BACMV,QADN,EAEMP,eAFN;AAGC,IAAA,SAAS,EAAGG,OAHb;AAIC,kBAAaH,eAAe,CAAE,YAAF,CAAf,IAAmCN,KAJjD;AAKC,wBAAmBsB,aALpB;AAMC,IAAA,GAAG,EAAGrC;AANP,MAQGS,IAAI,IAAIC,YAAY,KAAK,MAAzB,IACD,4BAAC,aAAD;AAAM,IAAA,IAAI,EAAGD,IAAb;AAAoB,IAAA,IAAI,EAAGE;AAA3B,IATF,EAWGM,IAAI,IAAI,qDAAIA,IAAJ,CAXX,EAYGR,IAAI,IAAIC,YAAY,KAAK,OAAzB,IACD,4BAAC,aAAD;AAAM,IAAA,IAAI,EAAGD,IAAb;AAAoB,IAAA,IAAI,EAAGE;AAA3B,IAbF,EAeGK,QAfH,CADD;;AAoBA,MAAK,CAAEkB,iBAAP,EAA2B;AAC1B,WACC,qDACGI,OADH,EAEGlB,WAAW,IACZ,4BAAC,8BAAD,QACC;AAAM,MAAA,EAAE,EAAGgB;AAAX,OAA6BhB,WAA7B,CADD,CAHF,CADD;AAUA;;AAED,SACC,qDACC,4BAAC,gBAAD;AACC,IAAA,IAAI,EAAGJ,QAAQ,SAAR,IAAAA,QAAQ,WAAR,IAAAA,QAAQ,CAAEmB,MAAV,IAAoBf,WAApB,GAAkCA,WAAlC,GAAgDL,KADxD;AAEC,IAAA,QAAQ,EAAGD,QAFZ;AAGC,IAAA,QAAQ,EAAGD;AAHZ,KAKGyB,OALH,CADD,EAQGlB,WAAW,IACZ,4BAAC,8BAAD,QACC;AAAM,IAAA,EAAE,EAAGgB;AAAX,KAA6BhB,WAA7B,CADD,CATF,CADD;AAgBA;;eAEc,yBAAYtB,MAAZ,C","sourcesContent":["// @ts-nocheck\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { forwardRef } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Tooltip from '../tooltip';\nimport Icon from '../icon';\nimport { VisuallyHidden } from '../visually-hidden';\n\nconst disabledEventsOnDisabledButton = [ 'onMouseDown', 'onClick' ];\n\nfunction useDeprecatedProps( {\n\tisDefault,\n\tisPrimary,\n\tisSecondary,\n\tisTertiary,\n\tisLink,\n\tvariant,\n\t...otherProps\n} ) {\n\tlet computedVariant = variant;\n\n\tif ( isPrimary ) {\n\t\tcomputedVariant ??= 'primary';\n\t}\n\n\tif ( isTertiary ) {\n\t\tcomputedVariant ??= 'tertiary';\n\t}\n\n\tif ( isSecondary ) {\n\t\tcomputedVariant ??= 'secondary';\n\t}\n\n\tif ( isDefault ) {\n\t\tdeprecated( 'Button isDefault prop', {\n\t\t\tsince: '5.4',\n\t\t\talternative: 'variant=\"secondary\"',\n\t\t\tversion: '6.2',\n\t\t} );\n\n\t\tcomputedVariant ??= 'secondary';\n\t}\n\n\tif ( isLink ) {\n\t\tcomputedVariant ??= 'link';\n\t}\n\n\treturn {\n\t\t...otherProps,\n\t\tvariant: computedVariant,\n\t};\n}\n\nexport function Button( props, ref ) {\n\tconst {\n\t\thref,\n\t\ttarget,\n\t\tisSmall,\n\t\tisPressed,\n\t\tisBusy,\n\t\tisDestructive,\n\t\tclassName,\n\t\tdisabled,\n\t\ticon,\n\t\ticonPosition = 'left',\n\t\ticonSize,\n\t\tshowTooltip,\n\t\ttooltipPosition,\n\t\tshortcut,\n\t\tlabel,\n\t\tchildren,\n\t\ttext,\n\t\tvariant,\n\t\t__experimentalIsFocusable: isFocusable,\n\t\tdescribedBy,\n\t\t...additionalProps\n\t} = useDeprecatedProps( props );\n\tconst instanceId = useInstanceId(\n\t\tButton,\n\t\t'components-button__description'\n\t);\n\n\tconst hasChildren =\n\t\tchildren?.[ 0 ] &&\n\t\tchildren[ 0 ] !== null &&\n\t\t// Tooltip should not considered as a child\n\t\tchildren?.[ 0 ]?.props?.className !== 'components-tooltip';\n\n\tconst classes = classnames( 'components-button', className, {\n\t\t'is-secondary': variant === 'secondary',\n\t\t'is-primary': variant === 'primary',\n\t\t'is-small': isSmall,\n\t\t'is-tertiary': variant === 'tertiary',\n\t\t'is-pressed': isPressed,\n\t\t'is-busy': isBusy,\n\t\t'is-link': variant === 'link',\n\t\t'is-destructive': isDestructive,\n\t\t'has-text': !! icon && hasChildren,\n\t\t'has-icon': !! icon,\n\t} );\n\n\tconst trulyDisabled = disabled && ! isFocusable;\n\tconst Tag = href !== undefined && ! trulyDisabled ? 'a' : 'button';\n\tconst tagProps =\n\t\tTag === 'a'\n\t\t\t? { href, target }\n\t\t\t: {\n\t\t\t\t\ttype: 'button',\n\t\t\t\t\tdisabled: trulyDisabled,\n\t\t\t\t\t'aria-pressed': isPressed,\n\t\t\t };\n\n\tif ( disabled && isFocusable ) {\n\t\t// In this case, the button will be disabled, but still focusable and\n\t\t// perceivable by screen reader users.\n\t\ttagProps[ 'aria-disabled' ] = true;\n\n\t\tfor ( const disabledEvent of disabledEventsOnDisabledButton ) {\n\t\t\tadditionalProps[ disabledEvent ] = ( event ) => {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tevent.preventDefault();\n\t\t\t};\n\t\t}\n\t}\n\n\t// Should show the tooltip if...\n\tconst shouldShowTooltip =\n\t\t! trulyDisabled &&\n\t\t// An explicit tooltip is passed or...\n\t\t( ( showTooltip && label ) ||\n\t\t\t// There's a shortcut or...\n\t\t\tshortcut ||\n\t\t\t// There's a label and...\n\t\t\t( !! label &&\n\t\t\t\t// The children are empty and...\n\t\t\t\t! children?.length &&\n\t\t\t\t// The tooltip is not explicitly disabled.\n\t\t\t\tfalse !== showTooltip ) );\n\n\tconst descriptionId = describedBy ? instanceId : null;\n\n\tconst describedById =\n\t\tadditionalProps[ 'aria-describedby' ] || descriptionId;\n\n\tconst element = (\n\t\t<Tag\n\t\t\t{ ...tagProps }\n\t\t\t{ ...additionalProps }\n\t\t\tclassName={ classes }\n\t\t\taria-label={ additionalProps[ 'aria-label' ] || label }\n\t\t\taria-describedby={ describedById }\n\t\t\tref={ ref }\n\t\t>\n\t\t\t{ icon && iconPosition === 'left' && (\n\t\t\t\t<Icon icon={ icon } size={ iconSize } />\n\t\t\t) }\n\t\t\t{ text && <>{ text }</> }\n\t\t\t{ icon && iconPosition === 'right' && (\n\t\t\t\t<Icon icon={ icon } size={ iconSize } />\n\t\t\t) }\n\t\t\t{ children }\n\t\t</Tag>\n\t);\n\n\tif ( ! shouldShowTooltip ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ element }\n\t\t\t\t{ describedBy && (\n\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t<span id={ descriptionId }>{ describedBy }</span>\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Tooltip\n\t\t\t\ttext={ children?.length && describedBy ? describedBy : label }\n\t\t\t\tshortcut={ shortcut }\n\t\t\t\tposition={ tooltipPosition }\n\t\t\t>\n\t\t\t\t{ element }\n\t\t\t</Tooltip>\n\t\t\t{ describedBy && (\n\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t<span id={ descriptionId }>{ describedBy }</span>\n\t\t\t\t</VisuallyHidden>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default forwardRef( Button );\n"]}
@@ -173,7 +173,13 @@ function DropZoneComponent(_ref) {
173
173
  initial: disableMotion ? 'show' : 'hidden',
174
174
  animate: "show",
175
175
  exit: disableMotion ? 'show' : 'exit',
176
- className: "components-drop-zone__content"
176
+ className: "components-drop-zone__content" // Without this, when this div is shown,
177
+ // Safari calls a onDropZoneLeave causing a loop because of this bug
178
+ // https://bugs.webkit.org/show_bug.cgi?id=66547
179
+ ,
180
+ style: {
181
+ pointerEvents: 'none'
182
+ }
177
183
  }, (0, _element.createElement)(_animation.__unstableMotion.div, {
178
184
  variants: foreground
179
185
  }, (0, _element.createElement)(_icons.Icon, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/drop-zone/index.tsx"],"names":["DropZoneComponent","className","label","onFilesDrop","onHTMLDrop","onDrop","restProps","isDraggingOverDocument","setIsDraggingOverDocument","isDraggingOverElement","setIsDraggingOverElement","type","setType","ref","event","files","dataTransfer","html","getData","length","onDragStart","_type","types","includes","onDragEnd","undefined","onDragEnter","onDragLeave","disableMotion","children","backdrop","hidden","scaleY","opacity","show","transition","duration","delay","delayChildren","exit","foreground","scale","upload","classes"],"mappings":";;;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AAQA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,iBAAT,OAOqD;AAAA,MAPzB;AAClCC,IAAAA,SADkC;AAElCC,IAAAA,KAFkC;AAGlCC,IAAAA,WAHkC;AAIlCC,IAAAA,UAJkC;AAKlCC,IAAAA,MALkC;AAMlC,OAAGC;AAN+B,GAOyB;AAC3D,QAAM,CAAEC,sBAAF,EAA0BC,yBAA1B,IACL,wBADD;AAEA,QAAM,CAAEC,qBAAF,EAAyBC,wBAAzB,IACL,wBADD;AAEA,QAAM,CAAEC,IAAF,EAAQC,OAAR,IAAoB,wBAA1B;AACA,QAAMC,GAAG,GAAG,wCAAa;AACxBR,IAAAA,MAAM,CAAES,KAAF,EAAU;AAAA;;AACf,YAAMC,KAAK,GAAGD,KAAK,CAACE,YAAN,GACX,mCAA0BF,KAAK,CAACE,YAAhC,CADW,GAEX,EAFH;AAGA,YAAMC,IAAI,0BAAGH,KAAK,CAACE,YAAT,wDAAG,oBAAoBE,OAApB,CAA6B,WAA7B,CAAb;AAEA;AACH;AACA;AACA;;AACG,UAAKD,IAAI,IAAIb,UAAb,EAA0B;AACzBA,QAAAA,UAAU,CAAEa,IAAF,CAAV;AACA,OAFD,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S,EAAC;AAFX,MADD,EAKC;AAAM,MAAA,SAAS,EAAC;AAAhB,OACGxC,KAAK,GAAGA,KAAH,GAAW,cAAI,sBAAJ,CADnB,CALD,CAPD,CADD;AAmBA;;AAED,QAAMyC,OAAO,GAAG,yBAAY,sBAAZ,EAAoC1C,SAApC,EAA+C;AAC9D,iBACC,CAAEM,sBAAsB,IAAIE,qBAA5B,MACIE,IAAI,KAAK,MAAT,IAAmBR,WAArB,IACCQ,IAAI,KAAK,MAAT,IAAmBP,UADpB,IAECO,IAAI,KAAK,SAAT,IAAsBN,MAHzB,CAF6D;AAM9D,iCAA6BE,sBANiC;AAO9D,gCAA4BE,qBAPkC;AAQ9D,KAAG,eAAeE,IAAM,EAAxB,GAA6B,CAAC,CAAEA;AAR8B,GAA/C,CAAhB;AAWA,SACC,8DAAUL,SAAV;AAAsB,IAAA,GAAG,EAAGO,GAA5B;AAAkC,IAAA,SAAS,EAAG8B;AAA9C,MACGf,aAAa,GACdC,QADc,GAGd,4BAAC,oCAAD,QAAmBA,QAAnB,CAJF,CADD;AASA;;eAEc7B,iB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { upload, Icon } from '@wordpress/icons';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\nimport {\n\t__experimentalUseDropZone as useDropZone,\n\tuseReducedMotion,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '../animation';\nimport type { DropType, DropZoneProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\n/**\n * `DropZone` is a component creating a drop zone area taking the full size of its parent element. It supports dropping files, HTML content or any other HTML drop event.\n *\n * ```jsx\n * import { DropZone } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyDropZone = () => {\n * const [ hasDropped, setHasDropped ] = useState( false );\n *\n * return (\n * <div>\n * { hasDropped ? 'Dropped!' : 'Drop something here' }\n * <DropZone\n * onFilesDrop={ () => setHasDropped( true ) }\n * onHTMLDrop={ () => setHasDropped( true ) }\n * onDrop={ () => setHasDropped( true ) }\n * />\n * </div>\n * );\n * }\n * ```\n */\nexport function DropZoneComponent( {\n\tclassName,\n\tlabel,\n\tonFilesDrop,\n\tonHTMLDrop,\n\tonDrop,\n\t...restProps\n}: WordPressComponentProps< DropZoneProps, 'div', false > ) {\n\tconst [ isDraggingOverDocument, setIsDraggingOverDocument ] =\n\t\tuseState< boolean >();\n\tconst [ isDraggingOverElement, setIsDraggingOverElement ] =\n\t\tuseState< boolean >();\n\tconst [ type, setType ] = useState< DropType >();\n\tconst ref = useDropZone( {\n\t\tonDrop( event ) {\n\t\t\tconst files = event.dataTransfer\n\t\t\t\t? getFilesFromDataTransfer( event.dataTransfer )\n\t\t\t\t: [];\n\t\t\tconst html = event.dataTransfer?.getData( 'text/html' );\n\n\t\t\t/**\n\t\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t\t */\n\t\t\tif ( html && onHTMLDrop ) {\n\t\t\t\tonHTMLDrop( html );\n\t\t\t} else if ( files.length && onFilesDrop ) {\n\t\t\t\tonFilesDrop( files );\n\t\t\t} else if ( onDrop ) {\n\t\t\t\tonDrop( event );\n\t\t\t}\n\t\t},\n\t\tonDragStart( event ) {\n\t\t\tsetIsDraggingOverDocument( true );\n\n\t\t\tlet _type: DropType = 'default';\n\n\t\t\t/**\n\t\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t\t */\n\t\t\tif ( event.dataTransfer?.types.includes( 'text/html' ) ) {\n\t\t\t\t_type = 'html';\n\t\t\t} else if (\n\t\t\t\t// Check for the types because sometimes the files themselves\n\t\t\t\t// are only available on drop.\n\t\t\t\tevent.dataTransfer?.types.includes( 'Files' ) ||\n\t\t\t\t( event.dataTransfer\n\t\t\t\t\t? getFilesFromDataTransfer( event.dataTransfer )\n\t\t\t\t\t: []\n\t\t\t\t).length > 0\n\t\t\t) {\n\t\t\t\t_type = 'file';\n\t\t\t}\n\n\t\t\tsetType( _type );\n\t\t},\n\t\tonDragEnd() {\n\t\t\tsetIsDraggingOverDocument( false );\n\t\t\tsetType( undefined );\n\t\t},\n\t\tonDragEnter() {\n\t\t\tsetIsDraggingOverElement( true );\n\t\t},\n\t\tonDragLeave() {\n\t\t\tsetIsDraggingOverElement( false );\n\t\t},\n\t} );\n\tconst disableMotion = useReducedMotion();\n\n\tlet children;\n\n\tconst backdrop = {\n\t\thidden: { scaleY: 0, opacity: 0 },\n\t\tshow: {\n\t\t\tscaleY: 1,\n\t\t\topacity: 1,\n\t\t\ttransition: {\n\t\t\t\ttype: 'tween',\n\t\t\t\tduration: 0.2,\n\t\t\t\tdelay: 0.1,\n\t\t\t\tdelayChildren: 0.2,\n\t\t\t},\n\t\t},\n\t\texit: {\n\t\t\tscaleY: 1,\n\t\t\topacity: 0,\n\t\t\ttransition: {\n\t\t\t\tduration: 0.3,\n\t\t\t\tdelayChildren: 0,\n\t\t\t},\n\t\t},\n\t};\n\n\tconst foreground = {\n\t\thidden: { opacity: 0, scale: 0.75 },\n\t\tshow: { opacity: 1, scale: 1 },\n\t\texit: { opacity: 0, scale: 0.9 },\n\t};\n\n\tif ( isDraggingOverElement ) {\n\t\tchildren = (\n\t\t\t<motion.div\n\t\t\t\tvariants={ backdrop }\n\t\t\t\tinitial={ disableMotion ? 'show' : 'hidden' }\n\t\t\t\tanimate=\"show\"\n\t\t\t\texit={ disableMotion ? 'show' : 'exit' }\n\t\t\t\tclassName=\"components-drop-zone__content\"\n\t\t\t>\n\t\t\t\t<motion.div variants={ foreground }>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\tclassName=\"components-drop-zone__content-icon\"\n\t\t\t\t\t/>\n\t\t\t\t\t<span className=\"components-drop-zone__content-text\">\n\t\t\t\t\t\t{ label ? label : __( 'Drop files to upload' ) }\n\t\t\t\t\t</span>\n\t\t\t\t</motion.div>\n\t\t\t</motion.div>\n\t\t);\n\t}\n\n\tconst classes = classnames( 'components-drop-zone', className, {\n\t\t'is-active':\n\t\t\t( isDraggingOverDocument || isDraggingOverElement ) &&\n\t\t\t( ( type === 'file' && onFilesDrop ) ||\n\t\t\t\t( type === 'html' && onHTMLDrop ) ||\n\t\t\t\t( type === 'default' && onDrop ) ),\n\t\t'is-dragging-over-document': isDraggingOverDocument,\n\t\t'is-dragging-over-element': isDraggingOverElement,\n\t\t[ `is-dragging-${ type }` ]: !! type,\n\t} );\n\n\treturn (\n\t\t<div { ...restProps } ref={ ref } className={ classes }>\n\t\t\t{ disableMotion ? (\n\t\t\t\tchildren\n\t\t\t) : (\n\t\t\t\t<AnimatePresence>{ children }</AnimatePresence>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default DropZoneComponent;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/drop-zone/index.tsx"],"names":["DropZoneComponent","className","label","onFilesDrop","onHTMLDrop","onDrop","restProps","isDraggingOverDocument","setIsDraggingOverDocument","isDraggingOverElement","setIsDraggingOverElement","type","setType","ref","event","files","dataTransfer","html","getData","length","onDragStart","_type","types","includes","onDragEnd","undefined","onDragEnter","onDragLeave","disableMotion","children","backdrop","hidden","scaleY","opacity","show","transition","duration","delay","delayChildren","exit","foreground","scale","pointerEvents","upload","classes"],"mappings":";;;;;;;;;;AASA;;;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AAQA;;AApBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,iBAAT,OAOqD;AAAA,MAPzB;AAClCC,IAA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AhB;AAWA,SACC,8DAAUL,SAAV;AAAsB,IAAA,GAAG,EAAGO,GAA5B;AAAkC,IAAA,SAAS,EAAG+B;AAA9C,MACGhB,aAAa,GACdC,QADc,GAGd,4BAAC,oCAAD,QAAmBA,QAAnB,CAJF,CADD;AASA;;eAEc7B,iB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { upload, Icon } from '@wordpress/icons';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\nimport {\n\t__experimentalUseDropZone as useDropZone,\n\tuseReducedMotion,\n} from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '../animation';\nimport type { DropType, DropZoneProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\n/**\n * `DropZone` is a component creating a drop zone area taking the full size of its parent element. It supports dropping files, HTML content or any other HTML drop event.\n *\n * ```jsx\n * import { DropZone } from '@wordpress/components';\n * import { useState } from '@wordpress/element';\n *\n * const MyDropZone = () => {\n * const [ hasDropped, setHasDropped ] = useState( false );\n *\n * return (\n * <div>\n * { hasDropped ? 'Dropped!' : 'Drop something here' }\n * <DropZone\n * onFilesDrop={ () => setHasDropped( true ) }\n * onHTMLDrop={ () => setHasDropped( true ) }\n * onDrop={ () => setHasDropped( true ) }\n * />\n * </div>\n * );\n * }\n * ```\n */\nexport function DropZoneComponent( {\n\tclassName,\n\tlabel,\n\tonFilesDrop,\n\tonHTMLDrop,\n\tonDrop,\n\t...restProps\n}: WordPressComponentProps< DropZoneProps, 'div', false > ) {\n\tconst [ isDraggingOverDocument, setIsDraggingOverDocument ] =\n\t\tuseState< boolean >();\n\tconst [ isDraggingOverElement, setIsDraggingOverElement ] =\n\t\tuseState< boolean >();\n\tconst [ type, setType ] = useState< DropType >();\n\tconst ref = useDropZone( {\n\t\tonDrop( event ) {\n\t\t\tconst files = event.dataTransfer\n\t\t\t\t? getFilesFromDataTransfer( event.dataTransfer )\n\t\t\t\t: [];\n\t\t\tconst html = event.dataTransfer?.getData( 'text/html' );\n\n\t\t\t/**\n\t\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t\t */\n\t\t\tif ( html && onHTMLDrop ) {\n\t\t\t\tonHTMLDrop( html );\n\t\t\t} else if ( files.length && onFilesDrop ) {\n\t\t\t\tonFilesDrop( files );\n\t\t\t} else if ( onDrop ) {\n\t\t\t\tonDrop( event );\n\t\t\t}\n\t\t},\n\t\tonDragStart( event ) {\n\t\t\tsetIsDraggingOverDocument( true );\n\n\t\t\tlet _type: DropType = 'default';\n\n\t\t\t/**\n\t\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t\t */\n\t\t\tif ( event.dataTransfer?.types.includes( 'text/html' ) ) {\n\t\t\t\t_type = 'html';\n\t\t\t} else if (\n\t\t\t\t// Check for the types because sometimes the files themselves\n\t\t\t\t// are only available on drop.\n\t\t\t\tevent.dataTransfer?.types.includes( 'Files' ) ||\n\t\t\t\t( event.dataTransfer\n\t\t\t\t\t? getFilesFromDataTransfer( event.dataTransfer )\n\t\t\t\t\t: []\n\t\t\t\t).length > 0\n\t\t\t) {\n\t\t\t\t_type = 'file';\n\t\t\t}\n\n\t\t\tsetType( _type );\n\t\t},\n\t\tonDragEnd() {\n\t\t\tsetIsDraggingOverDocument( false );\n\t\t\tsetType( undefined );\n\t\t},\n\t\tonDragEnter() {\n\t\t\tsetIsDraggingOverElement( true );\n\t\t},\n\t\tonDragLeave() {\n\t\t\tsetIsDraggingOverElement( false );\n\t\t},\n\t} );\n\tconst disableMotion = useReducedMotion();\n\n\tlet children;\n\tconst backdrop = {\n\t\thidden: { scaleY: 0, opacity: 0 },\n\t\tshow: {\n\t\t\tscaleY: 1,\n\t\t\topacity: 1,\n\t\t\ttransition: {\n\t\t\t\ttype: 'tween',\n\t\t\t\tduration: 0.2,\n\t\t\t\tdelay: 0.1,\n\t\t\t\tdelayChildren: 0.2,\n\t\t\t},\n\t\t},\n\t\texit: {\n\t\t\tscaleY: 1,\n\t\t\topacity: 0,\n\t\t\ttransition: {\n\t\t\t\tduration: 0.3,\n\t\t\t\tdelayChildren: 0,\n\t\t\t},\n\t\t},\n\t};\n\n\tconst foreground = {\n\t\thidden: { opacity: 0, scale: 0.75 },\n\t\tshow: { opacity: 1, scale: 1 },\n\t\texit: { opacity: 0, scale: 0.9 },\n\t};\n\n\tif ( isDraggingOverElement ) {\n\t\tchildren = (\n\t\t\t<motion.div\n\t\t\t\tvariants={ backdrop }\n\t\t\t\tinitial={ disableMotion ? 'show' : 'hidden' }\n\t\t\t\tanimate=\"show\"\n\t\t\t\texit={ disableMotion ? 'show' : 'exit' }\n\t\t\t\tclassName=\"components-drop-zone__content\"\n\t\t\t\t// Without this, when this div is shown,\n\t\t\t\t// Safari calls a onDropZoneLeave causing a loop because of this bug\n\t\t\t\t// https://bugs.webkit.org/show_bug.cgi?id=66547\n\t\t\t\tstyle={ { pointerEvents: 'none' } }\n\t\t\t>\n\t\t\t\t<motion.div variants={ foreground }>\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\tclassName=\"components-drop-zone__content-icon\"\n\t\t\t\t\t/>\n\t\t\t\t\t<span className=\"components-drop-zone__content-text\">\n\t\t\t\t\t\t{ label ? label : __( 'Drop files to upload' ) }\n\t\t\t\t\t</span>\n\t\t\t\t</motion.div>\n\t\t\t</motion.div>\n\t\t);\n\t}\n\n\tconst classes = classnames( 'components-drop-zone', className, {\n\t\t'is-active':\n\t\t\t( isDraggingOverDocument || isDraggingOverElement ) &&\n\t\t\t( ( type === 'file' && onFilesDrop ) ||\n\t\t\t\t( type === 'html' && onHTMLDrop ) ||\n\t\t\t\t( type === 'default' && onDrop ) ),\n\t\t'is-dragging-over-document': isDraggingOverDocument,\n\t\t'is-dragging-over-element': isDraggingOverElement,\n\t\t[ `is-dragging-${ type }` ]: !! type,\n\t} );\n\n\treturn (\n\t\t<div { ...restProps } ref={ ref } className={ classes }>\n\t\t\t{ disableMotion ? (\n\t\t\t\tchildren\n\t\t\t) : (\n\t\t\t\t<AnimatePresence>{ children }</AnimatePresence>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nexport default DropZoneComponent;\n"]}
@@ -93,7 +93,7 @@ function withFilters(hookName) {
93
93
  * mounted instance. This occurs a maximum of once per animation frame.
94
94
  */
95
95
 
96
- const throttledForceUpdate = (0, _lodash.debounce)(() => {
96
+ const throttledForceUpdate = (0, _compose.debounce)(() => {
97
97
  // Recreate the filtered component, only after delay so that it's
98
98
  // computed once, even if many filters added.
99
99
  FilteredComponent = (0, _hooks.applyFilters)(hookName, OriginalComponent); // Force each instance to render.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/higher-order/with-filters/index.js"],"names":["ANIMATION_FRAME_PERIOD","withFilters","hookName","OriginalComponent","namespace","FilteredComponent","ensureFilteredComponent","undefined","FilteredComponentRenderer","Component","constructor","arguments","componentDidMount","instances","push","length","onHooksUpdated","componentWillUnmount","render","props","throttledForceUpdate","forEach","instance","forceUpdate","updatedHookName"],"mappings":";;;;;;;AAQA;;AALA;;AAMA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKA,MAAMA,sBAAsB,GAAG,EAA/B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASC,WAAT,CAAsBC,QAAtB,EAAiC;AAC/C,SAAO,yCAA8BC,iBAAF,IAAyB;AAC3D,UAAMC,SAAS,GAAG,uBAAuBF,QAAzC;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;;AACE,QAAIG,iBAAJ;AAEA;AACF;AACA;AACA;;AACE,aAASC,uBAAT,GAAmC;AAClC,UAAKD,iBAAiB,KAAKE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S1BvB,sBAT0B,CAA7B;AAWA;AACF;AACA;AACA;AACA;AACA;AACA;;AACE,aAASgB,cAAT,CAAyBQ,eAAzB,EAA2C;AAC1C,UAAKA,eAAe,KAAKtB,QAAzB,EAAoC;AACnCkB,QAAAA,oBAAoB;AACpB;AACD;;AAED,WAAOZ,yBAAP;AACA,GA1FM,EA0FJ,aA1FI,CAAP;AA2FA","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce, without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { addAction, applyFilters, removeAction } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\n\nconst ANIMATION_FRAME_PERIOD = 16;\n\n/**\n * Creates a higher-order component which adds filtering capability to the\n * wrapped component. Filters get applied when the original component is about\n * to be mounted. When a filter is added or removed that matches the hook name,\n * the wrapped component re-renders.\n *\n * @param {string} hookName Hook name exposed to be used by filters.\n *\n * @return {Function} Higher-order component factory.\n */\nexport default function withFilters( hookName ) {\n\treturn createHigherOrderComponent( ( OriginalComponent ) => {\n\t\tconst namespace = 'core/with-filters/' + hookName;\n\n\t\t/**\n\t\t * The component definition with current filters applied. Each instance\n\t\t * reuse this shared reference as an optimization to avoid excessive\n\t\t * calls to `applyFilters` when many instances exist.\n\t\t *\n\t\t * @type {?Component}\n\t\t */\n\t\tlet FilteredComponent;\n\n\t\t/**\n\t\t * Initializes the FilteredComponent variable once, if not already\n\t\t * assigned. Subsequent calls are effectively a noop.\n\t\t */\n\t\tfunction ensureFilteredComponent() {\n\t\t\tif ( FilteredComponent === undefined ) {\n\t\t\t\tFilteredComponent = applyFilters( hookName, OriginalComponent );\n\t\t\t}\n\t\t}\n\n\t\tclass FilteredComponentRenderer extends Component {\n\t\t\tconstructor() {\n\t\t\t\tsuper( ...arguments );\n\n\t\t\t\tensureFilteredComponent();\n\t\t\t}\n\n\t\t\tcomponentDidMount() {\n\t\t\t\tFilteredComponentRenderer.instances.push( this );\n\n\t\t\t\t// If there were previously no mounted instances for components\n\t\t\t\t// filtered on this hook, add the hook handler.\n\t\t\t\tif ( FilteredComponentRenderer.instances.length === 1 ) {\n\t\t\t\t\taddAction( 'hookRemoved', namespace, onHooksUpdated );\n\t\t\t\t\taddAction( 'hookAdded', namespace, onHooksUpdated );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcomponentWillUnmount() {\n\t\t\t\tFilteredComponentRenderer.instances = without(\n\t\t\t\t\tFilteredComponentRenderer.instances,\n\t\t\t\t\tthis\n\t\t\t\t);\n\n\t\t\t\t// If this was the last of the mounted components filtered on\n\t\t\t\t// this hook, remove the hook handler.\n\t\t\t\tif ( FilteredComponentRenderer.instances.length === 0 ) {\n\t\t\t\t\tremoveAction( 'hookRemoved', namespace );\n\t\t\t\t\tremoveAction( 'hookAdded', namespace );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\treturn <FilteredComponent { ...this.props } />;\n\t\t\t}\n\t\t}\n\n\t\tFilteredComponentRenderer.instances = [];\n\n\t\t/**\n\t\t * Updates the FilteredComponent definition, forcing a render for each\n\t\t * mounted instance. This occurs a maximum of once per animation frame.\n\t\t */\n\t\tconst throttledForceUpdate = debounce( () => {\n\t\t\t// Recreate the filtered component, only after delay so that it's\n\t\t\t// computed once, even if many filters added.\n\t\t\tFilteredComponent = applyFilters( hookName, OriginalComponent );\n\n\t\t\t// Force each instance to render.\n\t\t\tFilteredComponentRenderer.instances.forEach( ( instance ) => {\n\t\t\t\tinstance.forceUpdate();\n\t\t\t} );\n\t\t}, ANIMATION_FRAME_PERIOD );\n\n\t\t/**\n\t\t * When a filter is added or removed for the matching hook name, each\n\t\t * mounted instance should re-render with the new filters having been\n\t\t * applied to the original component.\n\t\t *\n\t\t * @param {string} updatedHookName Name of the hook that was updated.\n\t\t */\n\t\tfunction onHooksUpdated( updatedHookName ) {\n\t\t\tif ( updatedHookName === hookName ) {\n\t\t\t\tthrottledForceUpdate();\n\t\t\t}\n\t\t}\n\n\t\treturn FilteredComponentRenderer;\n\t}, 'withFilters' );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/higher-order/with-filters/index.js"],"names":["ANIMATION_FRAME_PERIOD","withFilters","hookName","OriginalComponent","namespace","FilteredComponent","ensureFilteredComponent","undefined","FilteredComponentRenderer","Component","constructor","arguments","componentDidMount","instances","push","length","onHooksUpdated","componentWillUnmount","render","props","throttledForceUpdate","forEach","instance","forceUpdate","updatedHookName"],"mappings":";;;;;;;AAQA;;AALA;;AAMA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKA,MAAMA,sBAAsB,GAAG,EAA/B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASC,WAAT,CAAsBC,QAAtB,EAAiC;AAC/C,SAAO,yCAA8BC,iBAAF,IAAyB;AAC3D,UAAMC,SAAS,GAAG,uBAAuBF,QAAzC;AAEA;AACF;AACA;AACA;AACA;AACA;AACA;;AACE,QAAIG,iBAAJ;AAEA;AACF;AACA;AACA;;AACE,aAASC,uBAAT,GAAmC;AAClC,UAAKD,iBAAiB,KAAKE,SAA3B,EAAuC;AACtCF,QAAAA,iBAAiB,GAAG,yBAAcH,QAAd,EAAwBC,iBAAxB,CAApB;AACA;AACD;;AAED,UAAMK,yBAAN,SAAwCC,kBAAxC,CAAkD;AACjDC,MAAAA,WAAW,GAAG;AACb,cAAO,GAAGC,SAAV;AAEAL,QAAAA,uBAAuB;AACvB;;AAEDM,MAAAA,iBAAiB,GAAG;AACnBJ,QAAAA,yBAAyB,CAACK,SAA1B,CAAoCC,IAApC,CAA0C,IAA1C,EADmB,CAGnB;AACA;;AACA,YAAKN,yBAAyB,CAACK,SAA1B,CAAoCE,MAApC,KAA+C,CAApD,EAAwD;AACvD,gCAAW,aAAX,EAA0BX,SAA1B,EAAqCY,cAArC;AACA,gCAAW,WAAX,EAAwBZ,SAAxB,EAAmCY,cAAnC;AACA;AACD;;AAEDC,MAAAA,oBAAoB,GAAG;AACtBT,QAAAA,yBAAyB,CAACK,SAA1B,GAAsC,qBACrCL,yBAAyB,CAACK,SADW,EAErC,IAFqC,CAAtC,CADsB,CAMtB;AACA;;AACA,YAAKL,yBAAyB,CAACK,SAA1B,CAAoCE,MAApC,KAA+C,CAApD,EAAwD;AACvD,mCAAc,aAAd,EAA6BX,SAA7B;AACA,mCAAc,WAAd,EAA2BA,SAA3B;AACA;AACD;;AAEDc,MAAAA,MAAM,GAAG;AACR,eAAO,4BAAC,iBAAD,EAAwB,KAAKC,KAA7B,CAAP;AACA;;AAlCgD;;AAqClDX,IAAAA,yBAAyB,CAACK,SAA1B,GAAsC,EAAtC;AAEA;AACF;AACA;AACA;;AACE,UAAMO,oBAAoB,GAAG,uBAAU,MAAM;AAC5C;AACA;AACAf,MAAAA,iBAAiB,GAAG,yBAAcH,QAAd,EAAwBC,iBAAxB,CAApB,CAH4C,CAK5C;;AACAK,MAAAA,yBAAyB,CAACK,SAA1B,CAAoCQ,OAApC,CAA+CC,QAAF,IAAgB;AAC5DA,QAAAA,QAAQ,CAACC,WAAT;AACA,OAFD;AAGA,KAT4B,EAS1BvB,sBAT0B,CAA7B;AAWA;AACF;AACA;AACA;AACA;AACA;AACA;;AACE,aAASgB,cAAT,CAAyBQ,eAAzB,EAA2C;AAC1C,UAAKA,eAAe,KAAKtB,QAAzB,EAAoC;AACnCkB,QAAAA,oBAAoB;AACpB;AACD;;AAED,WAAOZ,yBAAP;AACA,GA1FM,EA0FJ,aA1FI,CAAP;AA2FA","sourcesContent":["/**\n * External dependencies\n */\nimport { without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { addAction, applyFilters, removeAction } from '@wordpress/hooks';\nimport { createHigherOrderComponent, debounce } from '@wordpress/compose';\n\nconst ANIMATION_FRAME_PERIOD = 16;\n\n/**\n * Creates a higher-order component which adds filtering capability to the\n * wrapped component. Filters get applied when the original component is about\n * to be mounted. When a filter is added or removed that matches the hook name,\n * the wrapped component re-renders.\n *\n * @param {string} hookName Hook name exposed to be used by filters.\n *\n * @return {Function} Higher-order component factory.\n */\nexport default function withFilters( hookName ) {\n\treturn createHigherOrderComponent( ( OriginalComponent ) => {\n\t\tconst namespace = 'core/with-filters/' + hookName;\n\n\t\t/**\n\t\t * The component definition with current filters applied. Each instance\n\t\t * reuse this shared reference as an optimization to avoid excessive\n\t\t * calls to `applyFilters` when many instances exist.\n\t\t *\n\t\t * @type {?Component}\n\t\t */\n\t\tlet FilteredComponent;\n\n\t\t/**\n\t\t * Initializes the FilteredComponent variable once, if not already\n\t\t * assigned. Subsequent calls are effectively a noop.\n\t\t */\n\t\tfunction ensureFilteredComponent() {\n\t\t\tif ( FilteredComponent === undefined ) {\n\t\t\t\tFilteredComponent = applyFilters( hookName, OriginalComponent );\n\t\t\t}\n\t\t}\n\n\t\tclass FilteredComponentRenderer extends Component {\n\t\t\tconstructor() {\n\t\t\t\tsuper( ...arguments );\n\n\t\t\t\tensureFilteredComponent();\n\t\t\t}\n\n\t\t\tcomponentDidMount() {\n\t\t\t\tFilteredComponentRenderer.instances.push( this );\n\n\t\t\t\t// If there were previously no mounted instances for components\n\t\t\t\t// filtered on this hook, add the hook handler.\n\t\t\t\tif ( FilteredComponentRenderer.instances.length === 1 ) {\n\t\t\t\t\taddAction( 'hookRemoved', namespace, onHooksUpdated );\n\t\t\t\t\taddAction( 'hookAdded', namespace, onHooksUpdated );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tcomponentWillUnmount() {\n\t\t\t\tFilteredComponentRenderer.instances = without(\n\t\t\t\t\tFilteredComponentRenderer.instances,\n\t\t\t\t\tthis\n\t\t\t\t);\n\n\t\t\t\t// If this was the last of the mounted components filtered on\n\t\t\t\t// this hook, remove the hook handler.\n\t\t\t\tif ( FilteredComponentRenderer.instances.length === 0 ) {\n\t\t\t\t\tremoveAction( 'hookRemoved', namespace );\n\t\t\t\t\tremoveAction( 'hookAdded', namespace );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\trender() {\n\t\t\t\treturn <FilteredComponent { ...this.props } />;\n\t\t\t}\n\t\t}\n\n\t\tFilteredComponentRenderer.instances = [];\n\n\t\t/**\n\t\t * Updates the FilteredComponent definition, forcing a render for each\n\t\t * mounted instance. This occurs a maximum of once per animation frame.\n\t\t */\n\t\tconst throttledForceUpdate = debounce( () => {\n\t\t\t// Recreate the filtered component, only after delay so that it's\n\t\t\t// computed once, even if many filters added.\n\t\t\tFilteredComponent = applyFilters( hookName, OriginalComponent );\n\n\t\t\t// Force each instance to render.\n\t\t\tFilteredComponentRenderer.instances.forEach( ( instance ) => {\n\t\t\t\tinstance.forceUpdate();\n\t\t\t} );\n\t\t}, ANIMATION_FRAME_PERIOD );\n\n\t\t/**\n\t\t * When a filter is added or removed for the matching hook name, each\n\t\t * mounted instance should re-render with the new filters having been\n\t\t * applied to the original component.\n\t\t *\n\t\t * @param {string} updatedHookName Name of the hook that was updated.\n\t\t */\n\t\tfunction onHooksUpdated( updatedHookName ) {\n\t\t\tif ( updatedHookName === hookName ) {\n\t\t\t\tthrottledForceUpdate();\n\t\t\t}\n\t\t}\n\n\t\treturn FilteredComponentRenderer;\n\t}, 'withFilters' );\n}\n"]}
@@ -13,10 +13,10 @@ var _native = require("@react-navigation/native");
13
13
 
14
14
  var _reactNative = require("react-native");
15
15
 
16
- var _lodash = require("lodash");
17
-
18
16
  var _components = require("@wordpress/components");
19
17
 
18
+ var _compose = require("@wordpress/compose");
19
+
20
20
  var _bottomSheetNavigationContext = require("./bottom-sheet-navigation-context");
21
21
 
22
22
  var _styles = _interopRequireDefault(require("./styles.scss"));
@@ -55,7 +55,7 @@ const BottomSheetNavigationScreen = _ref => {
55
55
  const {
56
56
  setHeight
57
57
  } = (0, _element.useContext)(_bottomSheetNavigationContext.BottomSheetNavigationContext);
58
- const setHeightDebounce = (0, _element.useCallback)((0, _lodash.debounce)(setHeight, 10), [setHeight]);
58
+ const setHeightDebounce = (0, _element.useCallback)((0, _compose.debounce)(setHeight, 10), [setHeight]);
59
59
  (0, _native.useFocusEffect)((0, _element.useCallback)(() => {
60
60
  onHandleHardwareButtonPress(() => {
61
61
  if (navigation.canGoBack()) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js"],"names":["BottomSheetNavigationScreen","children","fullScreen","isScrollable","isNested","name","navigation","heightRef","maxHeight","isFocused","onHandleHardwareButtonPress","shouldEnableBottomSheetMaxHeight","setIsFullScreen","listProps","safeAreaBottomInset","BottomSheetContext","setHeight","BottomSheetNavigationContext","setHeightDebounce","canGoBack","goBack","current","onLayout","nativeEvent","height","layout","styles","scrollableContent","paddingBottom"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AAKA;;AACA;;AAKA;;AAOA;;AACA;;AAtBA;AACA;AACA;;AASA;AACA;AACA;;AAKA;AACA;AACA;AAIA,MAAMA,2BAA2B,GAAG,QAM7B;AAAA,MAN+B;AACrCC,IAAAA,QADqC;AAErCC,IAAAA,UAFqC;AAGrCC,IAAAA,YAHqC;AAIrCC,IAAAA,QAJqC;AAKrCC,IAAAA;AALqC,GAM/B;AACN,QAAMC,UAAU,GAAG,4BAAnB;AACA,QAAMC,SAAS,GAAG,qBAAQ;AAAEC,IAAAA,SAAS,EAAE;AAAb,GAAR,CAAlB;AACA,QAAMC,SAAS,GAAG,2BAAlB;AACA,QAAM;AACLC,IAAAA,2BADK;AAELC,IAAAA,gCAFK;AAGLC,IAAAA,eAHK;AAILC,IAAAA,SAJK;AAKLC,IAAAA;AALK,MAMF,yBAAYC,8BAAZ,CANJ;AAQA,QAAM;AAAEC,IAAAA;AAAF,MAAgB,yBAAYC,0DAAZ,CAAtB;AAEA,QAAMC,iBAAiB,GAAG,0BAAa,sBAAUF,SAAV,EAAqB,EAArB,CAAb,EAAwC,CACjEA,SADiE,CAAxC,CAA1B;AAIA,8BACC,0BAAa,MAAM;AAClBN,IAAAA,2BAA2B,CAAE,MAAM;AAClC,UAAKJ,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AAFtC,OAIGJ,QAJH,CADM,GAQN,4BAAC,uBAAD,EAAiBY,SAAjB,EACC,4BAAC,+BAAD;AAAoB,MAAA,UAAU,EAAG;AAAjC,OACC,4BAAC,iBAAD;AACC,MAAA,QAAQ,EAAGS,QADZ;AAEC,MAAA,MAAM,EAAI,qBAAqBjB,IAAM;AAFtC,OAIGJ,QAJH,EAKG,CAAEG,QAAF,IACD,4BAAC,iBAAD;AACC,MAAA,KAAK,EAAG;AACPoB,QAAAA,MAAM,EACLV,mBAAmB,IACnBY,gBAAOC,iBAAP,CAAyBC;AAHnB;AADT,MANF,CADD,CADD,CARD;AA4BA,GA7BM,EA6BJ,CACF3B,QADE,EAEFQ,SAFE,EAGFK,mBAHE,EAIFD,SAJE,EAKFR,IALE,EAMFF,YANE,EAOFC,QAPE,EAQFkB,QARE,CA7BI,CAAP;AAuCA,CApHD;;eAsHetB,2B","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tuseIsFocused,\n\tuseNavigation,\n\tuseFocusEffect,\n} from '@react-navigation/native';\nimport { View, ScrollView, TouchableHighlight } from 'react-native';\nimport { debounce } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { BottomSheetContext } from '@wordpress/components';\n\nimport { useRef, useCallback, useContext, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { BottomSheetNavigationContext } from './bottom-sheet-navigation-context';\nimport styles from './styles.scss';\n\nconst BottomSheetNavigationScreen = ( {\n\tchildren,\n\tfullScreen,\n\tisScrollable,\n\tisNested,\n\tname,\n} ) => {\n\tconst navigation = useNavigation();\n\tconst heightRef = useRef( { maxHeight: 0 } );\n\tconst isFocused = useIsFocused();\n\tconst {\n\t\tonHandleHardwareButtonPress,\n\t\tshouldEnableBottomSheetMaxHeight,\n\t\tsetIsFullScreen,\n\t\tlistProps,\n\t\tsafeAreaBottomInset,\n\t} = useContext( BottomSheetContext );\n\n\tconst { setHeight } = useContext( BottomSheetNavigationContext );\n\n\tconst setHeightDebounce = useCallback( debounce( setHeight, 10 ), [\n\t\tsetHeight,\n\t] );\n\n\tuseFocusEffect(\n\t\tuseCallback( () => {\n\t\t\tonHandleHardwareButtonPress( () => {\n\t\t\t\tif ( navigation.canGoBack() ) {\n\t\t\t\t\tshouldEnableBottomSheetMaxHeight( true );\n\t\t\t\t\tnavigation.goBack();\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tonHandleHardwareButtonPress( null );\n\t\t\t\treturn false;\n\t\t\t} );\n\t\t\t/**\n\t\t\t * TODO: onHandleHardwareButtonPress stores a single value, which means\n\t\t\t * future invocations from sibling screens can replace the callback for\n\t\t\t * the currently active screen. Currently, the empty dependency array\n\t\t\t * passed to useCallback here is what prevents erroneous callback\n\t\t\t * replacements, but leveraging memoization to achieve this is brittle and\n\t\t\t * explicitly discouraged in the React documentation.\n\t\t\t * https://reactjs.org/docs/hooks-reference.html#usememo\n\t\t\t *\n\t\t\t * Ideally, we refactor onHandleHardwareButtonPress to manage multiple\n\t\t\t * callbacks triggered based upon which screen is currently active.\n\t\t\t *\n\t\t\t * Related: https://github.com/WordPress/gutenberg/pull/36328#discussion_r768897546\n\t\t\t */\n\t\t}, [] )\n\t);\n\n\tuseFocusEffect(\n\t\tuseCallback( () => {\n\t\t\tif ( fullScreen ) {\n\t\t\t\tsetHeight( '100%' );\n\t\t\t\tsetIsFullScreen( true );\n\t\t\t} else if ( heightRef.current.maxHeight !== 0 ) {\n\t\t\t\tsetIsFullScreen( false );\n\t\t\t\tsetHeight( heightRef.current.maxHeight );\n\t\t\t}\n\t\t\treturn () => {};\n\t\t}, [ setHeight ] )\n\t);\n\n\tconst onLayout = ( { nativeEvent } ) => {\n\t\tif ( fullScreen ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { height } = nativeEvent.layout;\n\n\t\tif ( heightRef.current.maxHeight !== height && isFocused ) {\n\t\t\theightRef.current.maxHeight = height;\n\t\t\tsetHeightDebounce( height );\n\t\t}\n\t};\n\n\treturn useMemo( () => {\n\t\treturn isScrollable || isNested ? (\n\t\t\t<View\n\t\t\t\tonLayout={ onLayout }\n\t\t\t\ttestID={ `navigation-screen-${ name }` }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</View>\n\t\t) : (\n\t\t\t<ScrollView { ...listProps }>\n\t\t\t\t<TouchableHighlight accessible={ false }>\n\t\t\t\t\t<View\n\t\t\t\t\t\tonLayout={ onLayout }\n\t\t\t\t\t\ttestID={ `navigation-screen-${ name }` }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t{ ! isNested && (\n\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\theight:\n\t\t\t\t\t\t\t\t\t\tsafeAreaBottomInset ||\n\t\t\t\t\t\t\t\t\t\tstyles.scrollableContent.paddingBottom,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</View>\n\t\t\t\t</TouchableHighlight>\n\t\t\t</ScrollView>\n\t\t);\n\t}, [\n\t\tchildren,\n\t\tisFocused,\n\t\tsafeAreaBottomInset,\n\t\tlistProps,\n\t\tname,\n\t\tisScrollable,\n\t\tisNested,\n\t\tonLayout,\n\t] );\n};\n\nexport default BottomSheetNavigationScreen;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/mobile/bottom-sheet/bottom-sheet-navigation/navigation-screen.native.js"],"names":["BottomSheetNavigationScreen","children","fullScreen","isScrollable","isNested","name","navigation","heightRef","maxHeight","isFocused","onHandleHardwareButtonPress","shouldEnableBottomSheetMaxHeight","setIsFullScreen","listProps","safeAreaBottomInset","BottomSheetContext","setHeight","BottomSheetNavigationContext","setHeightDebounce","canGoBack","goBack","current","onLayout","nativeEvent","height","layout","styles","scrollableContent","paddingBottom"],"mappings":";;;;;;;;;AAeA;;AAZA;;AAKA;;AAKA;;AACA;;AAMA;;AACA;;AArBA;AACA;AACA;;AAQA;AACA;AACA;;AA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CA,CApHD;;eAsHetB,2B","sourcesContent":["/**\n * External dependencies\n */\nimport {\n\tuseIsFocused,\n\tuseNavigation,\n\tuseFocusEffect,\n} from '@react-navigation/native';\nimport { View, ScrollView, TouchableHighlight } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { BottomSheetContext } from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport { useRef, useCallback, useContext, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { BottomSheetNavigationContext } from './bottom-sheet-navigation-context';\nimport styles from './styles.scss';\n\nconst BottomSheetNavigationScreen = ( {\n\tchildren,\n\tfullScreen,\n\tisScrollable,\n\tisNested,\n\tname,\n} ) => {\n\tconst navigation = useNavigation();\n\tconst heightRef = useRef( { maxHeight: 0 } );\n\tconst isFocused = useIsFocused();\n\tconst {\n\t\tonHandleHardwareButtonPress,\n\t\tshouldEnableBottomSheetMaxHeight,\n\t\tsetIsFullScreen,\n\t\tlistProps,\n\t\tsafeAreaBottomInset,\n\t} = useContext( BottomSheetContext );\n\n\tconst { setHeight } = useContext( BottomSheetNavigationContext );\n\n\tconst setHeightDebounce = useCallback( debounce( setHeight, 10 ), [\n\t\tsetHeight,\n\t] );\n\n\tuseFocusEffect(\n\t\tuseCallback( () => {\n\t\t\tonHandleHardwareButtonPress( () => {\n\t\t\t\tif ( navigation.canGoBack() ) {\n\t\t\t\t\tshouldEnableBottomSheetMaxHeight( true );\n\t\t\t\t\tnavigation.goBack();\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tonHandleHardwareButtonPress( null );\n\t\t\t\treturn false;\n\t\t\t} );\n\t\t\t/**\n\t\t\t * TODO: onHandleHardwareButtonPress stores a single value, which means\n\t\t\t * future invocations from sibling screens can replace the callback for\n\t\t\t * the currently active screen. Currently, the empty dependency array\n\t\t\t * passed to useCallback here is what prevents erroneous callback\n\t\t\t * replacements, but leveraging memoization to achieve this is brittle and\n\t\t\t * explicitly discouraged in the React documentation.\n\t\t\t * https://reactjs.org/docs/hooks-reference.html#usememo\n\t\t\t *\n\t\t\t * Ideally, we refactor onHandleHardwareButtonPress to manage multiple\n\t\t\t * callbacks triggered based upon which screen is currently active.\n\t\t\t *\n\t\t\t * Related: https://github.com/WordPress/gutenberg/pull/36328#discussion_r768897546\n\t\t\t */\n\t\t}, [] )\n\t);\n\n\tuseFocusEffect(\n\t\tuseCallback( () => {\n\t\t\tif ( fullScreen ) {\n\t\t\t\tsetHeight( '100%' );\n\t\t\t\tsetIsFullScreen( true );\n\t\t\t} else if ( heightRef.current.maxHeight !== 0 ) {\n\t\t\t\tsetIsFullScreen( false );\n\t\t\t\tsetHeight( heightRef.current.maxHeight );\n\t\t\t}\n\t\t\treturn () => {};\n\t\t}, [ setHeight ] )\n\t);\n\n\tconst onLayout = ( { nativeEvent } ) => {\n\t\tif ( fullScreen ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { height } = nativeEvent.layout;\n\n\t\tif ( heightRef.current.maxHeight !== height && isFocused ) {\n\t\t\theightRef.current.maxHeight = height;\n\t\t\tsetHeightDebounce( height );\n\t\t}\n\t};\n\n\treturn useMemo( () => {\n\t\treturn isScrollable || isNested ? (\n\t\t\t<View\n\t\t\t\tonLayout={ onLayout }\n\t\t\t\ttestID={ `navigation-screen-${ name }` }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</View>\n\t\t) : (\n\t\t\t<ScrollView { ...listProps }>\n\t\t\t\t<TouchableHighlight accessible={ false }>\n\t\t\t\t\t<View\n\t\t\t\t\t\tonLayout={ onLayout }\n\t\t\t\t\t\ttestID={ `navigation-screen-${ name }` }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t{ ! isNested && (\n\t\t\t\t\t\t\t<View\n\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\theight:\n\t\t\t\t\t\t\t\t\t\tsafeAreaBottomInset ||\n\t\t\t\t\t\t\t\t\t\tstyles.scrollableContent.paddingBottom,\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</View>\n\t\t\t\t</TouchableHighlight>\n\t\t\t</ScrollView>\n\t\t);\n\t}, [\n\t\tchildren,\n\t\tisFocused,\n\t\tsafeAreaBottomInset,\n\t\tlistProps,\n\t\tname,\n\t\tisScrollable,\n\t\tisNested,\n\t\tonLayout,\n\t] );\n};\n\nexport default BottomSheetNavigationScreen;\n"]}
@@ -13,10 +13,10 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
13
13
 
14
14
  var _reactNative = require("react-native");
15
15
 
16
- var _lodash = require("lodash");
17
-
18
16
  var _components = require("@wordpress/components");
19
17
 
18
+ var _compose = require("@wordpress/compose");
19
+
20
20
  var _data = require("@wordpress/data");
21
21
 
22
22
  var _styles = _interopRequireDefault(require("./styles.scss"));
@@ -108,7 +108,7 @@ function LinkPickerResults(_ref) {
108
108
  };
109
109
 
110
110
  return {
111
- fetchMoreSuggestions: (0, _lodash.debounce)(fetchMore, REQUEST_DEBOUNCE_DELAY)
111
+ fetchMoreSuggestions: (0, _compose.debounce)(fetchMore, REQUEST_DEBOUNCE_DELAY)
112
112
  };
113
113
  }, []); // Prevent setting state when unmounted.
114
114
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/mobile/link-picker/link-picker-results.native.js"],"names":["PER_PAGE","REQUEST_DEBOUNCE_DELAY","MINIMUM_QUERY_SIZE","meetsThreshold","query","length","LinkPickerResults","onLinkPicked","directEntry","links","setLinks","hasAllSuggestions","setHasAllSuggestions","nextPage","pendingRequest","clearRequest","current","fetchMoreSuggestions","select","getSettings","fetchLinkSuggestions","search","__experimentalFetchLinkSuggestions","page","type","perPage","fetchMore","currentSuggestions","request","suggestions","onEndReached","spinner","styles","listProps","item","url","contentContainerStyle","list"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AACA;;AAKA;;AAEA;;AAKA;;AAhBA;AACA;AACA;;AAIA;A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AAF,IAAuBR,cAAc,CAAEC,KAAF,CAArC,IACf,4BAAC,iBAAD;AAAM,IAAA,KAAK,EAAG4B,gBAAOD;AAArB,KACC,4BAAC,8BAAD;AAAmB,IAAA,SAAS;AAA5B,IADD,CADD;AAMA,SACC,4BAAC,+BAAD,QACG;AAAA,QAAE;AAAEE,MAAAA;AAAF,KAAF;AAAA,WACD,4BAAC,qBAAD;AACC,MAAA,IAAI,EAAGxB,KADR;AAEC,MAAA,yBAAyB,EAAC,QAF3B;AAGC,MAAA,UAAU,EAAG;AAAA,YAAE;AAAEyB,UAAAA;AAAF,SAAF;AAAA,eACZ,4BAAC,uBAAD,CAAa,sBAAb;AACC,UAAA,UAAU,EAAGA,IADd;AAEC,UAAA,YAAY,EAAG3B;AAFhB,UADY;AAAA,OAHd;AASC,MAAA,YAAY,EAAG;AAAA,YAAE;AAAE4B,UAAAA,GAAF;AAAOX,UAAAA;AAAP,SAAF;AAAA,eAAsB,GAAGW,GAAK,IAAIX,IAAM,EAAxC;AAAA,OAThB;AAUC,MAAA,YAAY,EAAGM,YAVhB;AAWC,MAAA,qBAAqB,EAAG,GAXzB;AAYC,MAAA,kBAAkB,EAAG9B,QAZtB;AAaC,MAAA,mBAAmB,EAAG+B;AAbvB,OAcME,SAdN;AAeC,MAAA,qBAAqB,EAAG,CACvB,GAAGA,SAAS,CAACG,qBADU,EAEvBJ,gBAAOK,IAFgB;AAfzB,OADC;AAAA,GADH,CADD;AA0BA","sourcesContent":["/**\n * External dependencies\n */\nimport { ActivityIndicator, FlatList, View } from 'react-native';\nimport { debounce } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { BottomSheet, BottomSheetConsumer } from '@wordpress/components';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport styles from './styles.scss';\n\nconst PER_PAGE = 20;\nconst REQUEST_DEBOUNCE_DELAY = 400;\nconst MINIMUM_QUERY_SIZE = 2;\nconst meetsThreshold = ( query ) => MINIMUM_QUERY_SIZE <= query.length;\n\nexport default function LinkPickerResults( {\n\tquery,\n\tonLinkPicked,\n\tdirectEntry,\n} ) {\n\tconst [ links, setLinks ] = useState( [ directEntry ] );\n\tconst [ hasAllSuggestions, setHasAllSuggestions ] = useState( false );\n\tconst nextPage = useRef( 1 );\n\tconst pendingRequest = useRef();\n\tconst clearRequest = () => {\n\t\tpendingRequest.current = null;\n\t};\n\n\t// A stable debounced function to fetch suggestions and append.\n\tconst { fetchMoreSuggestions } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( 'core/block-editor' );\n\t\tconst fetchLinkSuggestions = async ( { search } ) => {\n\t\t\tif ( meetsThreshold( search ) ) {\n\t\t\t\treturn await getSettings().__experimentalFetchLinkSuggestions(\n\t\t\t\t\tsearch,\n\t\t\t\t\t{ page: nextPage.current, type: 'post', perPage: PER_PAGE }\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t\tconst fetchMore = async ( {\n\t\t\tquery: search,\n\t\t\tlinks: currentSuggestions,\n\t\t} ) => {\n\t\t\t// Return early if we've already detected the end of data or we are\n\t\t\t// already awaiting a response.\n\t\t\tif ( hasAllSuggestions || pendingRequest.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst request = fetchLinkSuggestions( { search } );\n\t\t\tpendingRequest.current = request;\n\t\t\tconst suggestions = await request;\n\n\t\t\t// Only update links for the most recent request.\n\t\t\tif ( suggestions && request === pendingRequest.current ) {\n\t\t\t\t// Since we don't have the response header, we check if the results\n\t\t\t\t// are truncated to determine we've reached the end.\n\t\t\t\tif ( suggestions.length < PER_PAGE ) {\n\t\t\t\t\tsetHasAllSuggestions( true );\n\t\t\t\t}\n\t\t\t\tsetLinks( [ ...currentSuggestions, ...suggestions ] );\n\t\t\t\tnextPage.current++;\n\t\t\t}\n\n\t\t\tclearRequest();\n\t\t};\n\t\treturn {\n\t\t\tfetchMoreSuggestions: debounce( fetchMore, REQUEST_DEBOUNCE_DELAY ),\n\t\t};\n\t}, [] );\n\n\t// Prevent setting state when unmounted.\n\tuseEffect( () => clearRequest, [] );\n\n\t// Any time the query changes, we reset pagination.\n\tuseEffect( () => {\n\t\tclearRequest();\n\t\tnextPage.current = 1;\n\t\tsetHasAllSuggestions( false );\n\t\tsetLinks( [ directEntry ] );\n\t\tfetchMoreSuggestions( { query, links: [ directEntry ] } );\n\t}, [ query ] );\n\n\tconst onEndReached = () => fetchMoreSuggestions( { query, links } );\n\n\tconst spinner = ! hasAllSuggestions && meetsThreshold( query ) && (\n\t\t<View style={ styles.spinner }>\n\t\t\t<ActivityIndicator animating />\n\t\t</View>\n\t);\n\n\treturn (\n\t\t<BottomSheetConsumer>\n\t\t\t{ ( { listProps } ) => (\n\t\t\t\t<FlatList\n\t\t\t\t\tdata={ links }\n\t\t\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\t\t\trenderItem={ ( { item } ) => (\n\t\t\t\t\t\t<BottomSheet.LinkSuggestionItemCell\n\t\t\t\t\t\t\tsuggestion={ item }\n\t\t\t\t\t\t\tonLinkPicked={ onLinkPicked }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\tkeyExtractor={ ( { url, type } ) => `${ url }-${ type }` }\n\t\t\t\t\tonEndReached={ onEndReached }\n\t\t\t\t\tonEndReachedThreshold={ 0.1 }\n\t\t\t\t\tinitialNumToRender={ PER_PAGE }\n\t\t\t\t\tListFooterComponent={ spinner }\n\t\t\t\t\t{ ...listProps }\n\t\t\t\t\tcontentContainerStyle={ [\n\t\t\t\t\t\t...listProps.contentContainerStyle,\n\t\t\t\t\t\tstyles.list,\n\t\t\t\t\t] }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BottomSheetConsumer>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/mobile/link-picker/link-picker-results.native.js"],"names":["PER_PAGE","REQUEST_DEBOUNCE_DELAY","MINIMUM_QUERY_SIZE","meetsThreshold","query","length","LinkPickerResults","onLinkPicked","directEntry","links","setLinks","hasAllSuggestions","setHasAllSuggestions","nextPage","pendingRequest","clearRequest","current","fetchMoreSuggestions","select","getSettings","fetchLinkSuggestions","search","__experimentalFetchLinkSuggestions","page","type","perPage","fetchMore","currentSuggestions","request","suggestions","onEndReached","spinner","styles","listProps","item","url","contentContainerStyle","list"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AAKA;;AACA;;AAEA;;AAKA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,EAAjB;AACA,MAAMC,sBAAsB,GAAG,GAA/B;AACA,MAAMC,kBAAkB,GAAG,CAA3B;;AACA,MAAMC,cAAc,GAAKC,KAAF,IAAaF,kBAAkB,IAAIE,KAAK,CAACC,MAAhE;;AAEe,SAASC,iBAAT,OAIX;AAAA,MAJuC;AAC1CF,IAAAA,KAD0C;AAE1CG,IAAAA,YAF0C;AAG1CC,IAAAA;AAH0C,GAIvC;AACH,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAU,CAAEF,WAAF,CAAV,CAA5B;AACA,QAAM,CAAEG,iBAAF,EAAqBC,oBAArB,IAA8C,uBAAU,KAAV,CAApD;AACA,QAAMC,QAAQ,GAAG,qBAAQ,CAAR,CAAjB;AACA,QAAMC,cAAc,GAAG,sBAAvB;;AACA,QAAMC,YAAY,GAAG,MAAM;AAC1BD,IAAAA,cAAc,CAACE,OAAf,GAAyB,IAAzB;AACA,GAFD,CALG,CASH;;;AACA,QAAM;AAAEC,IAAAA;AAAF,MAA2B,qBAAaC,MAAF,IAAc;AACzD,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAE,mBAAF,CAA9B;;AACA,UAAME,oBAAoB,GAAG,eAAwB;AAAA,UAAhB;AAAEC,QAAAA;AAAF,OAAgB;;AACpD,UAAKlB,cAAc,CAAEkB,MAAF,CAAnB,EAAgC;AAC/B,eAAO,MAAMF,WAAW,GAAGG,kCAAd,CACZD,M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ndicator, FlatList, View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { BottomSheet, BottomSheetConsumer } from '@wordpress/components';\nimport { debounce } from '@wordpress/compose';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport styles from './styles.scss';\n\nconst PER_PAGE = 20;\nconst REQUEST_DEBOUNCE_DELAY = 400;\nconst MINIMUM_QUERY_SIZE = 2;\nconst meetsThreshold = ( query ) => MINIMUM_QUERY_SIZE <= query.length;\n\nexport default function LinkPickerResults( {\n\tquery,\n\tonLinkPicked,\n\tdirectEntry,\n} ) {\n\tconst [ links, setLinks ] = useState( [ directEntry ] );\n\tconst [ hasAllSuggestions, setHasAllSuggestions ] = useState( false );\n\tconst nextPage = useRef( 1 );\n\tconst pendingRequest = useRef();\n\tconst clearRequest = () => {\n\t\tpendingRequest.current = null;\n\t};\n\n\t// A stable debounced function to fetch suggestions and append.\n\tconst { fetchMoreSuggestions } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( 'core/block-editor' );\n\t\tconst fetchLinkSuggestions = async ( { search } ) => {\n\t\t\tif ( meetsThreshold( search ) ) {\n\t\t\t\treturn await getSettings().__experimentalFetchLinkSuggestions(\n\t\t\t\t\tsearch,\n\t\t\t\t\t{ page: nextPage.current, type: 'post', perPage: PER_PAGE }\n\t\t\t\t);\n\t\t\t}\n\t\t};\n\t\tconst fetchMore = async ( {\n\t\t\tquery: search,\n\t\t\tlinks: currentSuggestions,\n\t\t} ) => {\n\t\t\t// Return early if we've already detected the end of data or we are\n\t\t\t// already awaiting a response.\n\t\t\tif ( hasAllSuggestions || pendingRequest.current ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst request = fetchLinkSuggestions( { search } );\n\t\t\tpendingRequest.current = request;\n\t\t\tconst suggestions = await request;\n\n\t\t\t// Only update links for the most recent request.\n\t\t\tif ( suggestions && request === pendingRequest.current ) {\n\t\t\t\t// Since we don't have the response header, we check if the results\n\t\t\t\t// are truncated to determine we've reached the end.\n\t\t\t\tif ( suggestions.length < PER_PAGE ) {\n\t\t\t\t\tsetHasAllSuggestions( true );\n\t\t\t\t}\n\t\t\t\tsetLinks( [ ...currentSuggestions, ...suggestions ] );\n\t\t\t\tnextPage.current++;\n\t\t\t}\n\n\t\t\tclearRequest();\n\t\t};\n\t\treturn {\n\t\t\tfetchMoreSuggestions: debounce( fetchMore, REQUEST_DEBOUNCE_DELAY ),\n\t\t};\n\t}, [] );\n\n\t// Prevent setting state when unmounted.\n\tuseEffect( () => clearRequest, [] );\n\n\t// Any time the query changes, we reset pagination.\n\tuseEffect( () => {\n\t\tclearRequest();\n\t\tnextPage.current = 1;\n\t\tsetHasAllSuggestions( false );\n\t\tsetLinks( [ directEntry ] );\n\t\tfetchMoreSuggestions( { query, links: [ directEntry ] } );\n\t}, [ query ] );\n\n\tconst onEndReached = () => fetchMoreSuggestions( { query, links } );\n\n\tconst spinner = ! hasAllSuggestions && meetsThreshold( query ) && (\n\t\t<View style={ styles.spinner }>\n\t\t\t<ActivityIndicator animating />\n\t\t</View>\n\t);\n\n\treturn (\n\t\t<BottomSheetConsumer>\n\t\t\t{ ( { listProps } ) => (\n\t\t\t\t<FlatList\n\t\t\t\t\tdata={ links }\n\t\t\t\t\tkeyboardShouldPersistTaps=\"always\"\n\t\t\t\t\trenderItem={ ( { item } ) => (\n\t\t\t\t\t\t<BottomSheet.LinkSuggestionItemCell\n\t\t\t\t\t\t\tsuggestion={ item }\n\t\t\t\t\t\t\tonLinkPicked={ onLinkPicked }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\tkeyExtractor={ ( { url, type } ) => `${ url }-${ type }` }\n\t\t\t\t\tonEndReached={ onEndReached }\n\t\t\t\t\tonEndReachedThreshold={ 0.1 }\n\t\t\t\t\tinitialNumToRender={ PER_PAGE }\n\t\t\t\t\tListFooterComponent={ spinner }\n\t\t\t\t\t{ ...listProps }\n\t\t\t\t\tcontentContainerStyle={ [\n\t\t\t\t\t\t...listProps.contentContainerStyle,\n\t\t\t\t\t\tstyles.list,\n\t\t\t\t\t] }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BottomSheetConsumer>\n\t);\n}\n"]}
@@ -13,8 +13,6 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
13
13
 
14
14
  var _rangeControlStyles = require("./styles/range-control-styles");
15
15
 
16
- var _utils = require("./utils");
17
-
18
16
  /**
19
17
  * WordPress dependencies
20
18
  */
@@ -22,26 +20,14 @@ var _utils = require("./utils");
22
20
  /**
23
21
  * Internal dependencies
24
22
  */
25
- const noop = () => {};
26
-
27
23
  function InputRange(props, ref) {
28
24
  const {
29
25
  describedBy,
30
26
  label,
31
- onHideTooltip = noop,
32
- onMouseLeave = noop,
33
- onMouseMove = noop,
34
- onShowTooltip = noop,
35
27
  value,
36
28
  ...otherProps
37
29
  } = props;
38
- const hoverInteractions = (0, _utils.useDebouncedHoverInteraction)({
39
- onHide: onHideTooltip,
40
- onMouseLeave,
41
- onMouseMove,
42
- onShow: onShowTooltip
43
- });
44
- return (0, _element.createElement)(_rangeControlStyles.InputRange, (0, _extends2.default)({}, otherProps, hoverInteractions, {
30
+ return (0, _element.createElement)(_rangeControlStyles.InputRange, (0, _extends2.default)({}, otherProps, {
45
31
  "aria-describedby": describedBy,
46
32
  "aria-label": label,
47
33
  "aria-hidden": false,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/range-control/input-range.tsx"],"names":["noop","InputRange","props","ref","describedBy","label","onHideTooltip","onMouseLeave","onMouseMove","onShowTooltip","value","otherProps","hoverInteractions","onHide","onShow","ForwardedComponent"],"mappings":";;;;;;;;;AAGA;;;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;AAOA,MAAMA,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,SAASC,UAAT,CACCC,KADD,EAECC,GAFD,EAGE;AACD,QAAM;AACLC,IAAAA,WADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,aAAa,GAAGN,IAHX;AAILO,IAAAA,YAAY,GAAGP,IAJV;AAKLQ,IAAAA,WAAW,GAAGR,IALT;AAMLS,IAAAA,aAAa,GAAGT,IANX;AAOLU,IAAAA,KAPK;AAQL,OAAGC;AARE,MASFT,KATJ;AAWA,QAAMU,iBAAiB,GAAG,yCAA8B;AACvDC,IAAAA,MAAM,EAAEP,aAD+C;AAEvDC,IAAAA,YAFuD;AAGvDC,IAAAA,WAHuD;AAIvDM,IAAAA,MAAM,EAAEL;AAJ+C,GAA9B,CAA1B;AAOA,SACC,4BAAC,8BAAD,6BACME,UADN,EAEMC,iBAFN;AAGC,wBAAmBR,WAHpB;AAIC,kBAAaC,KAJd;AAKC,mBAAc,KALf;AAMC,IAAA,GAAG,EAAGF,GANP;AAOC,IAAA,QAAQ,EAAG,CAPZ;AAQC,IAAA,IAAI,EAAC,OARN;AASC,IAAA,KAAK,EAAGO;AATT,KADD;AAaA;;AAED,MAAMK,kBAAkB,GAAG,yBAAYd,UAAZ,CAA3B;eAEec,kB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InputRange as BaseInputRange } from './styles/range-control-styles';\nimport { useDebouncedHoverInteraction } from './utils';\n\nimport type { InputRangeProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nconst noop = () => {};\n\nfunction InputRange(\n\tprops: WordPressComponentProps< InputRangeProps, 'input' >,\n\tref: React.ForwardedRef< HTMLInputElement >\n) {\n\tconst {\n\t\tdescribedBy,\n\t\tlabel,\n\t\tonHideTooltip = noop,\n\t\tonMouseLeave = noop,\n\t\tonMouseMove = noop,\n\t\tonShowTooltip = noop,\n\t\tvalue,\n\t\t...otherProps\n\t} = props;\n\n\tconst hoverInteractions = useDebouncedHoverInteraction( {\n\t\tonHide: onHideTooltip,\n\t\tonMouseLeave,\n\t\tonMouseMove,\n\t\tonShow: onShowTooltip,\n\t} );\n\n\treturn (\n\t\t<BaseInputRange\n\t\t\t{ ...otherProps }\n\t\t\t{ ...hoverInteractions }\n\t\t\taria-describedby={ describedBy }\n\t\t\taria-label={ label }\n\t\t\taria-hidden={ false }\n\t\t\tref={ ref }\n\t\t\ttabIndex={ 0 }\n\t\t\ttype=\"range\"\n\t\t\tvalue={ value }\n\t\t/>\n\t);\n}\n\nconst ForwardedComponent = forwardRef( InputRange );\n\nexport default ForwardedComponent;\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/range-control/input-range.tsx"],"names":["InputRange","props","ref","describedBy","label","value","otherProps","ForwardedComponent"],"mappings":";;;;;;;;;AAGA;;;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAMA,SAASA,UAAT,CACCC,KADD,EAECC,GAFD,EAGE;AACD,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,KAAf;AAAsBC,IAAAA,KAAtB;AAA6B,OAAGC;AAAhC,MAA+CL,KAArD;AAEA,SACC,4BAAC,8BAAD,6BACMK,UADN;AAEC,wBAAmBH,WAFpB;AAGC,kBAAaC,KAHd;AAIC,mBAAc,KAJf;AAKC,IAAA,GAAG,EAAGF,GALP;AAMC,IAAA,QAAQ,EAAG,CANZ;AAOC,IAAA,IAAI,EAAC,OAPN;AAQC,IAAA,KAAK,EAAGG;AART,KADD;AAYA;;AAED,MAAME,kBAAkB,GAAG,yBAAYP,UAAZ,CAA3B;eAEeO,kB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { forwardRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { InputRange as BaseInputRange } from './styles/range-control-styles';\n\nimport type { InputRangeProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nfunction InputRange(\n\tprops: WordPressComponentProps< InputRangeProps, 'input' >,\n\tref: React.ForwardedRef< HTMLInputElement >\n) {\n\tconst { describedBy, label, value, ...otherProps } = props;\n\n\treturn (\n\t\t<BaseInputRange\n\t\t\t{ ...otherProps }\n\t\t\taria-describedby={ describedBy }\n\t\t\taria-label={ label }\n\t\t\taria-hidden={ false }\n\t\t\tref={ ref }\n\t\t\ttabIndex={ 0 }\n\t\t\ttype=\"range\"\n\t\t\tvalue={ value }\n\t\t/>\n\t);\n}\n\nconst ForwardedComponent = forwardRef( InputRange );\n\nexport default ForwardedComponent;\n"]}
@@ -66,7 +66,7 @@ function useTooltipPosition(_ref) {
66
66
  if (inputRef && inputRef.current) {
67
67
  setPosition(tooltipPosition);
68
68
  }
69
- }, [tooltipPosition]);
69
+ }, [tooltipPosition, inputRef]);
70
70
  (0, _element.useEffect)(() => {
71
71
  setTooltipPosition();
72
72
  }, [setTooltipPosition]);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/components/src/range-control/tooltip.tsx"],"names":["SimpleTooltip","props","className","inputRef","tooltipPosition","show","style","value","renderTooltipContent","v","zIndex","restProps","position","useTooltipPosition","classes","styles","setPosition","setTooltipPosition","current","window","addEventListener","removeEventListener"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAUA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAMe,SAASA,aAAT,CACdC,KADc,EAEb;AACD,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,QAFK;AAGLC,IAAAA,eAHK;AAILC,IAAAA,IAAI,GAAG,KAJF;AAKLC,IAAAA,KAAK,GAAG,EALH;AAMLC,IAAAA,KAAK,GAAG,CANH;AAOLC,IAAAA,oBAAoB,GAAKC,CAAF,IAASA,CAP3B;AAQLC,IAAAA,MAAM,GAAG,GARJ;AASL,OAAGC;AATE,MAUFV,KAVJ;AAWA,QAAMW,QAAQ,GAAGC,kBAAkB,CAAE;AAAEV,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAAF,CAAnC;AACA,QAAMU,OAAO,GAAG,yBAAY,2BAAZ,EAAyCZ,SAAzC,CAAhB;AACA,QAAMa,MAAM,GAAG,EACd,GAAGT,KADW;AAEdI,IAAAA;AAFc,GAAf;AAKA,SACC,4BAAC,2BAAD,6BACMC,SADN;AAEC,mBAAcN,IAFf;AAGC,IAAA,SAAS,EAAGS,OAHb;AAIC,IAAA,QAAQ,EAAGF,QAJZ;AAKC,IAAA,IAAI,EAAGP,IALR;AAMC,IAAA,IAAI,EAAC,SANN;AAOC,IAAA,KAAK,EAAGU;AAPT,MASGP,oBAAoB,CAAED,KAAF,CATvB,CADD;AAaA;;AAED,SAASM,kBAAT,OAA2E;AAAA,MAA9C;AAAEV,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA8C;AAC1E,QAAM,CAAEQ,QAAF,EAAYI,WAAZ,IAA4B,wBAAlC;AAEA,QAAMC,kBAAkB,GAAG,0BAAa,MAAM;AAC7C,QAAKd,QAAQ,IAAIA,QAAQ,CAACe,OAA1B,EAAoC;AACnCF,MAAAA,WAAW,CAAEZ,eAAF,CAAX;AACA;AACD,GAJ0B,EAIxB,CAAEA,eAAF,CAJwB,CAA3B;AAMA,0BAAW,MAAM;AAChBa,IAAAA,kBAAkB;AAClB,GAFD,EAEG,CAAEA,kBAAF,CAFH;AAIA,0BAAW,MAAM;AAChBE,IAAAA,MAAM,CAACC,gBAAP,CAAyB,QAAzB,EAAmCH,kBAAnC;AAEA,WAAO,MAAM;AACZE,MAAAA,MAAM,CAACE,mBAAP,CAA4B,QAA5B,EAAsCJ,kBAAtC;AACA,KAFD;AAGA,GAND;AAQA,SAAOL,QAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { Tooltip } from './styles/range-control-styles';\n\nimport type { TooltipProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nexport default function SimpleTooltip(\n\tprops: WordPressComponentProps< TooltipProps, 'span' >\n) {\n\tconst {\n\t\tclassName,\n\t\tinputRef,\n\t\ttooltipPosition,\n\t\tshow = false,\n\t\tstyle = {},\n\t\tvalue = 0,\n\t\trenderTooltipContent = ( v ) => v,\n\t\tzIndex = 100,\n\t\t...restProps\n\t} = props;\n\tconst position = useTooltipPosition( { inputRef, tooltipPosition } );\n\tconst classes = classnames( 'components-simple-tooltip', className );\n\tconst styles = {\n\t\t...style,\n\t\tzIndex,\n\t};\n\n\treturn (\n\t\t<Tooltip\n\t\t\t{ ...restProps }\n\t\t\taria-hidden={ show }\n\t\t\tclassName={ classes }\n\t\t\tposition={ position }\n\t\t\tshow={ show }\n\t\t\trole=\"tooltip\"\n\t\t\tstyle={ styles }\n\t\t>\n\t\t\t{ renderTooltipContent( value ) }\n\t\t</Tooltip>\n\t);\n}\n\nfunction useTooltipPosition( { inputRef, tooltipPosition }: TooltipProps ) {\n\tconst [ position, setPosition ] = useState< string >();\n\n\tconst setTooltipPosition = useCallback( () => {\n\t\tif ( inputRef && inputRef.current ) {\n\t\t\tsetPosition( tooltipPosition );\n\t\t}\n\t}, [ tooltipPosition ] );\n\n\tuseEffect( () => {\n\t\tsetTooltipPosition();\n\t}, [ setTooltipPosition ] );\n\n\tuseEffect( () => {\n\t\twindow.addEventListener( 'resize', setTooltipPosition );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( 'resize', setTooltipPosition );\n\t\t};\n\t} );\n\n\treturn position;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/components/src/range-control/tooltip.tsx"],"names":["SimpleTooltip","props","className","inputRef","tooltipPosition","show","style","value","renderTooltipContent","v","zIndex","restProps","position","useTooltipPosition","classes","styles","setPosition","setTooltipPosition","current","window","addEventListener","removeEventListener"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAUA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAMe,SAASA,aAAT,CACdC,KADc,EAEb;AACD,QAAM;AACLC,IAAAA,SADK;AAELC,IAAAA,QAFK;AAGLC,IAAAA,eAHK;AAILC,IAAAA,IAAI,GAAG,KAJF;AAKLC,IAAAA,KAAK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,kBAAtC;AACA,KAFD;AAGA,GAND;AAQA,SAAOL,QAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { Tooltip } from './styles/range-control-styles';\n\nimport type { TooltipProps } from './types';\nimport type { WordPressComponentProps } from '../ui/context';\n\nexport default function SimpleTooltip(\n\tprops: WordPressComponentProps< TooltipProps, 'span' >\n) {\n\tconst {\n\t\tclassName,\n\t\tinputRef,\n\t\ttooltipPosition,\n\t\tshow = false,\n\t\tstyle = {},\n\t\tvalue = 0,\n\t\trenderTooltipContent = ( v ) => v,\n\t\tzIndex = 100,\n\t\t...restProps\n\t} = props;\n\tconst position = useTooltipPosition( { inputRef, tooltipPosition } );\n\tconst classes = classnames( 'components-simple-tooltip', className );\n\tconst styles = {\n\t\t...style,\n\t\tzIndex,\n\t};\n\n\treturn (\n\t\t<Tooltip\n\t\t\t{ ...restProps }\n\t\t\taria-hidden={ show }\n\t\t\tclassName={ classes }\n\t\t\tposition={ position }\n\t\t\tshow={ show }\n\t\t\trole=\"tooltip\"\n\t\t\tstyle={ styles }\n\t\t>\n\t\t\t{ renderTooltipContent( value ) }\n\t\t</Tooltip>\n\t);\n}\n\nfunction useTooltipPosition( { inputRef, tooltipPosition }: TooltipProps ) {\n\tconst [ position, setPosition ] = useState< string >();\n\n\tconst setTooltipPosition = useCallback( () => {\n\t\tif ( inputRef && inputRef.current ) {\n\t\t\tsetPosition( tooltipPosition );\n\t\t}\n\t}, [ tooltipPosition, inputRef ] );\n\n\tuseEffect( () => {\n\t\tsetTooltipPosition();\n\t}, [ setTooltipPosition ] );\n\n\tuseEffect( () => {\n\t\twindow.addEventListener( 'resize', setTooltipPosition );\n\n\t\treturn () => {\n\t\t\twindow.removeEventListener( 'resize', setTooltipPosition );\n\t\t};\n\t} );\n\n\treturn position;\n}\n"]}