@wordpress/block-directory 4.16.0 → 4.17.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 (102) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/auto-block-uninstaller/index.js +1 -6
  3. package/build/components/auto-block-uninstaller/index.js.map +1 -1
  4. package/build/components/block-ratings/index.js +1 -5
  5. package/build/components/block-ratings/index.js.map +1 -1
  6. package/build/components/block-ratings/stars.js +2 -7
  7. package/build/components/block-ratings/stars.js.map +1 -1
  8. package/build/components/compact-list/index.js +2 -8
  9. package/build/components/compact-list/index.js.map +1 -1
  10. package/build/components/downloadable-block-icon/index.js +1 -4
  11. package/build/components/downloadable-block-icon/index.js.map +1 -1
  12. package/build/components/downloadable-block-list-item/index.js +7 -28
  13. package/build/components/downloadable-block-list-item/index.js.map +1 -1
  14. package/build/components/downloadable-block-notice/index.js +1 -8
  15. package/build/components/downloadable-block-notice/index.js.map +1 -1
  16. package/build/components/downloadable-blocks-list/index.js +3 -15
  17. package/build/components/downloadable-blocks-list/index.js.map +1 -1
  18. package/build/components/downloadable-blocks-panel/index.js +1 -25
  19. package/build/components/downloadable-blocks-panel/index.js.map +1 -1
  20. package/build/components/downloadable-blocks-panel/inserter-panel.js +2 -7
  21. package/build/components/downloadable-blocks-panel/inserter-panel.js.map +1 -1
  22. package/build/components/downloadable-blocks-panel/no-results.js +1 -6
  23. package/build/components/downloadable-blocks-panel/no-results.js.map +1 -1
  24. package/build/index.js +0 -2
  25. package/build/index.js.map +1 -1
  26. package/build/plugins/get-install-missing/index.js +13 -28
  27. package/build/plugins/get-install-missing/index.js.map +1 -1
  28. package/build/plugins/get-install-missing/install-button.js +2 -11
  29. package/build/plugins/get-install-missing/install-button.js.map +1 -1
  30. package/build/plugins/index.js +1 -10
  31. package/build/plugins/index.js.map +1 -1
  32. package/build/plugins/inserter-menu-downloadable-blocks-panel/index.js +1 -9
  33. package/build/plugins/inserter-menu-downloadable-blocks-panel/index.js.map +1 -1
  34. package/build/plugins/installed-blocks-pre-publish-panel/index.js +2 -13
  35. package/build/plugins/installed-blocks-pre-publish-panel/index.js.map +1 -1
  36. package/build/store/actions.js +26 -46
  37. package/build/store/actions.js.map +1 -1
  38. package/build/store/index.js +2 -11
  39. package/build/store/index.js.map +1 -1
  40. package/build/store/load-assets.js +6 -12
  41. package/build/store/load-assets.js.map +1 -1
  42. package/build/store/reducer.js +16 -25
  43. package/build/store/reducer.js.map +1 -1
  44. package/build/store/resolvers.js +1 -7
  45. package/build/store/resolvers.js.map +1 -1
  46. package/build/store/selectors.js +7 -20
  47. package/build/store/selectors.js.map +1 -1
  48. package/build/store/utils/get-plugin-url.js +0 -4
  49. package/build/store/utils/get-plugin-url.js.map +1 -1
  50. package/build/store/utils/has-block-type.js +0 -4
  51. package/build/store/utils/has-block-type.js.map +1 -1
  52. package/build-module/components/auto-block-uninstaller/index.js +1 -1
  53. package/build-module/components/auto-block-uninstaller/index.js.map +1 -1
  54. package/build-module/components/block-ratings/index.js +0 -1
  55. package/build-module/components/block-ratings/index.js.map +1 -1
  56. package/build-module/components/block-ratings/stars.js +1 -5
  57. package/build-module/components/block-ratings/stars.js.map +1 -1
  58. package/build-module/components/compact-list/index.js +2 -5
  59. package/build-module/components/compact-list/index.js.map +1 -1
  60. package/build-module/components/downloadable-block-icon/index.js +0 -3
  61. package/build-module/components/downloadable-block-icon/index.js.map +1 -1
  62. package/build-module/components/downloadable-block-list-item/index.js +9 -19
  63. package/build-module/components/downloadable-block-list-item/index.js.map +1 -1
  64. package/build-module/components/downloadable-block-notice/index.js +1 -4
  65. package/build-module/components/downloadable-block-notice/index.js.map +1 -1
  66. package/build-module/components/downloadable-blocks-list/index.js +3 -9
  67. package/build-module/components/downloadable-blocks-list/index.js.map +1 -1
  68. package/build-module/components/downloadable-blocks-panel/index.js +1 -13
  69. package/build-module/components/downloadable-blocks-panel/index.js.map +1 -1
  70. package/build-module/components/downloadable-blocks-panel/inserter-panel.js +1 -5
  71. package/build-module/components/downloadable-blocks-panel/inserter-panel.js.map +1 -1
  72. package/build-module/components/downloadable-blocks-panel/no-results.js +0 -3
  73. package/build-module/components/downloadable-blocks-panel/no-results.js.map +1 -1
  74. package/build-module/index.js.map +1 -1
  75. package/build-module/plugins/get-install-missing/index.js +13 -20
  76. package/build-module/plugins/get-install-missing/index.js.map +1 -1
  77. package/build-module/plugins/get-install-missing/install-button.js +2 -5
  78. package/build-module/plugins/get-install-missing/install-button.js.map +1 -1
  79. package/build-module/plugins/index.js +1 -4
  80. package/build-module/plugins/index.js.map +1 -1
  81. package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.js +1 -6
  82. package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.js.map +1 -1
  83. package/build-module/plugins/installed-blocks-pre-publish-panel/index.js +6 -8
  84. package/build-module/plugins/installed-blocks-pre-publish-panel/index.js.map +1 -1
  85. package/build-module/store/actions.js +28 -30
  86. package/build-module/store/actions.js.map +1 -1
  87. package/build-module/store/index.js +4 -4
  88. package/build-module/store/index.js.map +1 -1
  89. package/build-module/store/load-assets.js +7 -8
  90. package/build-module/store/load-assets.js.map +1 -1
  91. package/build-module/store/reducer.js +17 -17
  92. package/build-module/store/reducer.js.map +1 -1
  93. package/build-module/store/resolvers.js +2 -3
  94. package/build-module/store/resolvers.js.map +1 -1
  95. package/build-module/store/selectors.js +9 -11
  96. package/build-module/store/selectors.js.map +1 -1
  97. package/build-module/store/utils/get-plugin-url.js +0 -3
  98. package/build-module/store/utils/get-plugin-url.js.map +1 -1
  99. package/build-module/store/utils/has-block-type.js +0 -3
  100. package/build-module/store/utils/has-block-type.js.map +1 -1
  101. package/package.json +20 -20
  102. package/src/components/downloadable-block-list-item/test/index.js +1 -1
@@ -1,18 +1,13 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.getDownloadableBlocks = void 0;
9
-
10
8
  var _changeCase = require("change-case");
11
-
12
9
  var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
13
-
14
10
  var _actions = require("./actions");
15
-
16
11
  /**
17
12
  * External dependencies
18
13
  */
@@ -24,13 +19,13 @@ var _actions = require("./actions");
24
19
  /**
25
20
  * Internal dependencies
26
21
  */
22
+
27
23
  const getDownloadableBlocks = filterValue => async ({
28
24
  dispatch
29
25
  }) => {
30
26
  if (!filterValue) {
31
27
  return;
32
28
  }
33
-
34
29
  try {
35
30
  dispatch((0, _actions.fetchDownloadableBlocks)(filterValue));
36
31
  const results = await (0, _apiFetch.default)({
@@ -40,6 +35,5 @@ const getDownloadableBlocks = filterValue => async ({
40
35
  dispatch((0, _actions.receiveDownloadableBlocks)(blocks, filterValue));
41
36
  } catch {}
42
37
  };
43
-
44
38
  exports.getDownloadableBlocks = getDownloadableBlocks;
45
39
  //# sourceMappingURL=resolvers.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/store/resolvers.js"],"names":["getDownloadableBlocks","filterValue","dispatch","results","path","blocks","map","result","Object","fromEntries","entries","key","value"],"mappings":";;;;;;;;;AAGA;;AAKA;;AAKA;;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;AAGO,MAAMA,qBAAqB,GAC/BC,WAAF,IACA,OAAQ;AAAEC,EAAAA;AAAF,CAAR,KAA0B;AACzB,MAAK,CAAED,WAAP,EAAqB;AACpB;AACA;;AAED,MAAI;AACHC,IAAAA,QAAQ,CAAE,sCAAyBD,WAAzB,CAAF,CAAR;AACA,UAAME,OAAO,GAAG,MAAM,uBAAU;AAC/BC,MAAAA,IAAI,EAAG,qCAAqCH,WAAa;AAD1B,KAAV,CAAtB;AAGA,UAAMI,MAAM,GAAGF,OAAO,CAACG,GAAR,CAAeC,MAAF,IAC3BC,MAAM,CAACC,WAAP,CACCD,MAAM,CAACE,OAAP,CAAgBH,MAAhB,EAAyBD,GAAzB,CAA8B,CAAE,CAAEK,GAAF,EAAOC,KAAP,CAAF,KAAsB,CACnD,2BAAWD,GAAX,CADmD,EAEnDC,KAFmD,CAApD,CADD,CADc,CAAf;AASAV,IAAAA,QAAQ,CAAE,wCAA2BG,MAA3B,EAAmCJ,WAAnC,CAAF,CAAR;AACA,GAfD,CAeE,MAAM,CAAE;AACV,CAvBK","sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks =\n\t( filterValue ) =>\n\tasync ( { dispatch } ) => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\t\tconst results = await apiFetch( {\n\t\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t\t} );\n\t\t\tconst blocks = results.map( ( result ) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries( result ).map( ( [ key, value ] ) => [\n\t\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t] )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t\t} catch {}\n\t};\n"]}
1
+ {"version":3,"names":["_changeCase","require","_apiFetch","_interopRequireDefault","_actions","getDownloadableBlocks","filterValue","dispatch","fetchDownloadableBlocks","results","apiFetch","path","blocks","map","result","Object","fromEntries","entries","key","value","camelCase","receiveDownloadableBlocks","exports"],"sources":["@wordpress/block-directory/src/store/resolvers.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks =\n\t( filterValue ) =>\n\tasync ( { dispatch } ) => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\t\tconst results = await apiFetch( {\n\t\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t\t} );\n\t\t\tconst blocks = results.map( ( result ) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries( result ).map( ( [ key, value ] ) => [\n\t\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t] )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t\t} catch {}\n\t};\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGO,MAAMI,qBAAqB,GAC/BC,WAAW,IACb,OAAQ;EAAEC;AAAS,CAAC,KAAM;EACzB,IAAK,CAAED,WAAW,EAAG;IACpB;EACD;EAEA,IAAI;IACHC,QAAQ,CAAE,IAAAC,gCAAuB,EAAEF,WAAY,CAAE,CAAC;IAClD,MAAMG,OAAO,GAAG,MAAM,IAAAC,iBAAQ,EAAE;MAC/BC,IAAI,EAAG,qCAAqCL,WAAa;IAC1D,CAAE,CAAC;IACH,MAAMM,MAAM,GAAGH,OAAO,CAACI,GAAG,CAAIC,MAAM,IACnCC,MAAM,CAACC,WAAW,CACjBD,MAAM,CAACE,OAAO,CAAEH,MAAO,CAAC,CAACD,GAAG,CAAE,CAAE,CAAEK,GAAG,EAAEC,KAAK,CAAE,KAAM,CACnD,IAAAC,qBAAS,EAAEF,GAAI,CAAC,EAChBC,KAAK,CACJ,CACH,CACD,CAAC;IAEDZ,QAAQ,CAAE,IAAAc,kCAAyB,EAAET,MAAM,EAAEN,WAAY,CAAE,CAAC;EAC7D,CAAC,CAAC,MAAM,CAAC;AACV,CAAC;AAACgB,OAAA,CAAAjB,qBAAA,GAAAA,qBAAA"}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -12,13 +11,9 @@ exports.getInstalledBlockTypes = getInstalledBlockTypes;
12
11
  exports.getUnusedBlockTypes = exports.getNewBlockTypes = void 0;
13
12
  exports.isInstalling = isInstalling;
14
13
  exports.isRequestingDownloadableBlocks = isRequestingDownloadableBlocks;
15
-
16
14
  var _data = require("@wordpress/data");
17
-
18
15
  var _blockEditor = require("@wordpress/block-editor");
19
-
20
16
  var _hasBlockType = _interopRequireDefault(require("./utils/has-block-type"));
21
-
22
17
  /**
23
18
  * WordPress dependencies
24
19
  */
@@ -37,9 +32,9 @@ var _hasBlockType = _interopRequireDefault(require("./utils/has-block-type"));
37
32
  */
38
33
  function isRequestingDownloadableBlocks(state, filterValue) {
39
34
  var _state$downloadableBl;
40
-
41
35
  return (_state$downloadableBl = state.downloadableBlocks[filterValue]?.isRequesting) !== null && _state$downloadableBl !== void 0 ? _state$downloadableBl : false;
42
36
  }
37
+
43
38
  /**
44
39
  * Returns the available uninstalled blocks.
45
40
  *
@@ -48,13 +43,11 @@ function isRequestingDownloadableBlocks(state, filterValue) {
48
43
  *
49
44
  * @return {Array} Downloadable blocks.
50
45
  */
51
-
52
-
53
46
  function getDownloadableBlocks(state, filterValue) {
54
47
  var _state$downloadableBl2;
55
-
56
48
  return (_state$downloadableBl2 = state.downloadableBlocks[filterValue]?.results) !== null && _state$downloadableBl2 !== void 0 ? _state$downloadableBl2 : [];
57
49
  }
50
+
58
51
  /**
59
52
  * Returns the block types that have been installed on the server in this
60
53
  * session.
@@ -63,11 +56,10 @@ function getDownloadableBlocks(state, filterValue) {
63
56
  *
64
57
  * @return {Array} Block type items
65
58
  */
66
-
67
-
68
59
  function getInstalledBlockTypes(state) {
69
60
  return state.blockManagement.installedBlockTypes;
70
61
  }
62
+
71
63
  /**
72
64
  * Returns block types that have been installed on the server and used in the
73
65
  * current post.
@@ -76,13 +68,12 @@ function getInstalledBlockTypes(state) {
76
68
  *
77
69
  * @return {Array} Block type items.
78
70
  */
79
-
80
-
81
71
  const getNewBlockTypes = (0, _data.createRegistrySelector)(select => state => {
82
72
  const usedBlockTree = select(_blockEditor.store).getBlocks();
83
73
  const installedBlockTypes = getInstalledBlockTypes(state);
84
74
  return installedBlockTypes.filter(blockType => (0, _hasBlockType.default)(blockType, usedBlockTree));
85
75
  });
76
+
86
77
  /**
87
78
  * Returns the block types that have been installed on the server but are not
88
79
  * used in the current post.
@@ -91,13 +82,13 @@ const getNewBlockTypes = (0, _data.createRegistrySelector)(select => state => {
91
82
  *
92
83
  * @return {Array} Block type items.
93
84
  */
94
-
95
85
  exports.getNewBlockTypes = getNewBlockTypes;
96
86
  const getUnusedBlockTypes = (0, _data.createRegistrySelector)(select => state => {
97
87
  const usedBlockTree = select(_blockEditor.store).getBlocks();
98
88
  const installedBlockTypes = getInstalledBlockTypes(state);
99
89
  return installedBlockTypes.filter(blockType => !(0, _hasBlockType.default)(blockType, usedBlockTree));
100
90
  });
91
+
101
92
  /**
102
93
  * Returns true if a block plugin install is in progress.
103
94
  *
@@ -106,12 +97,11 @@ const getUnusedBlockTypes = (0, _data.createRegistrySelector)(select => state =>
106
97
  *
107
98
  * @return {boolean} Whether this block is currently being installed.
108
99
  */
109
-
110
100
  exports.getUnusedBlockTypes = getUnusedBlockTypes;
111
-
112
101
  function isInstalling(state, blockId) {
113
102
  return state.blockManagement.isInstalling[blockId] || false;
114
103
  }
104
+
115
105
  /**
116
106
  * Returns all block error notices.
117
107
  *
@@ -119,11 +109,10 @@ function isInstalling(state, blockId) {
119
109
  *
120
110
  * @return {Object} Object with error notices.
121
111
  */
122
-
123
-
124
112
  function getErrorNotices(state) {
125
113
  return state.errorNotices;
126
114
  }
115
+
127
116
  /**
128
117
  * Returns the error notice for a given block.
129
118
  *
@@ -132,8 +121,6 @@ function getErrorNotices(state) {
132
121
  *
133
122
  * @return {string|boolean} The error text, or false if no error.
134
123
  */
135
-
136
-
137
124
  function getErrorNoticeForBlock(state, blockId) {
138
125
  return state.errorNotices[blockId];
139
126
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/store/selectors.js"],"names":["isRequestingDownloadableBlocks","state","filterValue","downloadableBlocks","isRequesting","getDownloadableBlocks","results","getInstalledBlockTypes","blockManagement","installedBlockTypes","getNewBlockTypes","select","usedBlockTree","blockEditorStore","getBlocks","filter","blockType","getUnusedBlockTypes","isInstalling","blockId","getErrorNotices","errorNotices","getErrorNoticeForBlock"],"mappings":";;;;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,8BAAT,CAAyCC,KAAzC,EAAgDC,WAAhD,EAA8D;AAAA;;AACpE,kCAAOD,KAAK,CAACE,kBAAN,CAA0BD,WAA1B,GAAyCE,YAAhD,yEAAgE,KAAhE;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,qBAAT,CAAgCJ,KAAhC,EAAuCC,WAAvC,EAAqD;AAAA;;AAC3D,mCAAOD,KAAK,CAACE,kBAAN,CAA0BD,WAA1B,GAAyCI,OAAhD,2EAA2D,EAA3D;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,sBAAT,CAAiCN,KAAjC,EAAyC;AAC/C,SAAOA,KAAK,CAACO,eAAN,CAAsBC,mBAA7B;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,gBAAgB,GAAG,kCAC7BC,MAAF,IAAgBV,KAAF,IAAa;AAC1B,QAAMW,aAAa,GAAGD,MAAM,CAAEE,kBAAF,CAAN,CAA2BC,SAA3B,EAAtB;AACA,QAAML,mBAAmB,GAAGF,sBAAsB,CAAEN,KAAF,CAAlD;AAEA,SAAOQ,mBAAmB,CAACM,MAApB,CAA8BC,SAAF,IAClC,2BAAcA,SAAd,EAAyBJ,aAAzB,CADM,CAAP;AAGA,CAR8B,CAAzB;AAWP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMK,mBAAmB,GAAG,kCAChCN,MAAF,IAAgBV,KAAF,IAAa;AAC1B,QAAMW,aAAa,GAAGD,MAAM,CAAEE,kBAAF,CAAN,CAA2BC,SAA3B,EAAtB;AACA,QAAML,mBAAmB,GAAGF,sBAAsB,CAAEN,KAAF,CAAlD;AAEA,SAAOQ,mBAAmB,CAACM,MAApB,CACJC,SAAF,IAAiB,CAAE,2BAAcA,SAAd,EAAyBJ,aAAzB,CADb,CAAP;AAGA,CARiC,CAA5B;AAWP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASM,YAAT,CAAuBjB,KAAvB,EAA8BkB,OAA9B,EAAwC;AAC9C,SAAOlB,KAAK,CAACO,eAAN,CAAsBU,YAAtB,CAAoCC,OAApC,KAAiD,KAAxD;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,eAAT,CAA0BnB,KAA1B,EAAkC;AACxC,SAAOA,KAAK,CAACoB,YAAb;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,sBAAT,CAAiCrB,KAAjC,EAAwCkB,OAAxC,EAAkD;AACxD,SAAOlB,KAAK,CAACoB,YAAN,CAAoBF,OAApB,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport hasBlockType from './utils/has-block-type';\n\n/**\n * Returns true if application is requesting for downloadable blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {boolean} Whether a request is in progress for the blocks list.\n */\nexport function isRequestingDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.isRequesting ?? false;\n}\n\n/**\n * Returns the available uninstalled blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {Array} Downloadable blocks.\n */\nexport function getDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.results ?? [];\n}\n\n/**\n * Returns the block types that have been installed on the server in this\n * session.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items\n */\nexport function getInstalledBlockTypes( state ) {\n\treturn state.blockManagement.installedBlockTypes;\n}\n\n/**\n * Returns block types that have been installed on the server and used in the\n * current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getNewBlockTypes = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\treturn installedBlockTypes.filter( ( blockType ) =>\n\t\t\thasBlockType( blockType, usedBlockTree )\n\t\t);\n\t}\n);\n\n/**\n * Returns the block types that have been installed on the server but are not\n * used in the current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getUnusedBlockTypes = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\treturn installedBlockTypes.filter(\n\t\t\t( blockType ) => ! hasBlockType( blockType, usedBlockTree )\n\t\t);\n\t}\n);\n\n/**\n * Returns true if a block plugin install is in progress.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId Id of the block.\n *\n * @return {boolean} Whether this block is currently being installed.\n */\nexport function isInstalling( state, blockId ) {\n\treturn state.blockManagement.isInstalling[ blockId ] || false;\n}\n\n/**\n * Returns all block error notices.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Object with error notices.\n */\nexport function getErrorNotices( state ) {\n\treturn state.errorNotices;\n}\n\n/**\n * Returns the error notice for a given block.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {string|boolean} The error text, or false if no error.\n */\nexport function getErrorNoticeForBlock( state, blockId ) {\n\treturn state.errorNotices[ blockId ];\n}\n"]}
1
+ {"version":3,"names":["_data","require","_blockEditor","_hasBlockType","_interopRequireDefault","isRequestingDownloadableBlocks","state","filterValue","_state$downloadableBl","downloadableBlocks","isRequesting","getDownloadableBlocks","_state$downloadableBl2","results","getInstalledBlockTypes","blockManagement","installedBlockTypes","getNewBlockTypes","createRegistrySelector","select","usedBlockTree","blockEditorStore","getBlocks","filter","blockType","hasBlockType","exports","getUnusedBlockTypes","isInstalling","blockId","getErrorNotices","errorNotices","getErrorNoticeForBlock"],"sources":["@wordpress/block-directory/src/store/selectors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport hasBlockType from './utils/has-block-type';\n\n/**\n * Returns true if application is requesting for downloadable blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {boolean} Whether a request is in progress for the blocks list.\n */\nexport function isRequestingDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.isRequesting ?? false;\n}\n\n/**\n * Returns the available uninstalled blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {Array} Downloadable blocks.\n */\nexport function getDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.results ?? [];\n}\n\n/**\n * Returns the block types that have been installed on the server in this\n * session.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items\n */\nexport function getInstalledBlockTypes( state ) {\n\treturn state.blockManagement.installedBlockTypes;\n}\n\n/**\n * Returns block types that have been installed on the server and used in the\n * current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getNewBlockTypes = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\treturn installedBlockTypes.filter( ( blockType ) =>\n\t\t\thasBlockType( blockType, usedBlockTree )\n\t\t);\n\t}\n);\n\n/**\n * Returns the block types that have been installed on the server but are not\n * used in the current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getUnusedBlockTypes = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\treturn installedBlockTypes.filter(\n\t\t\t( blockType ) => ! hasBlockType( blockType, usedBlockTree )\n\t\t);\n\t}\n);\n\n/**\n * Returns true if a block plugin install is in progress.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId Id of the block.\n *\n * @return {boolean} Whether this block is currently being installed.\n */\nexport function isInstalling( state, blockId ) {\n\treturn state.blockManagement.isInstalling[ blockId ] || false;\n}\n\n/**\n * Returns all block error notices.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Object with error notices.\n */\nexport function getErrorNotices( state ) {\n\treturn state.errorNotices;\n}\n\n/**\n * Returns the error notice for a given block.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {string|boolean} The error text, or false if no error.\n */\nexport function getErrorNoticeForBlock( state, blockId ) {\n\treturn state.errorNotices[ blockId ];\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;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1B,MAAMc,aAAa,GAAGD,MAAM,CAAEE,kBAAiB,CAAC,CAACC,SAAS,CAAC,CAAC;EAC5D,MAAMN,mBAAmB,GAAGF,sBAAsB,CAAER,KAAM,CAAC;EAE3D,OAAOU,mBAAmB,CAACO,MAAM,CAC9BC,SAAS,IAAM,CAAE,IAAAC,qBAAY,EAAED,SAAS,EAAEJ,aAAc,CAC3D,CAAC;AACF,CACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAM,OAAA,CAAAC,mBAAA,GAAAA,mBAAA;AAQO,SAASC,YAAYA,CAAEtB,KAAK,EAAEuB,OAAO,EAAG;EAC9C,OAAOvB,KAAK,CAACS,eAAe,CAACa,YAAY,CAAEC,OAAO,CAAE,IAAI,KAAK;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAAExB,KAAK,EAAG;EACxC,OAAOA,KAAK,CAACyB,YAAY;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,sBAAsBA,CAAE1B,KAAK,EAAEuB,OAAO,EAAG;EACxD,OAAOvB,KAAK,CAACyB,YAAY,CAAEF,OAAO,CAAE;AACrC"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = getPluginUrl;
7
-
8
7
  /**
9
8
  * Get the plugin's direct API link out of a block-directory response.
10
9
  *
@@ -16,13 +15,10 @@ function getPluginUrl(block) {
16
15
  if (!block) {
17
16
  return false;
18
17
  }
19
-
20
18
  const link = block.links['wp:plugin'] || block.links.self;
21
-
22
19
  if (link && link.length) {
23
20
  return link[0].href;
24
21
  }
25
-
26
22
  return false;
27
23
  }
28
24
  //# sourceMappingURL=get-plugin-url.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/store/utils/get-plugin-url.js"],"names":["getPluginUrl","block","link","links","self","length","href"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,YAAT,CAAuBC,KAAvB,EAA+B;AAC7C,MAAK,CAAEA,KAAP,EAAe;AACd,WAAO,KAAP;AACA;;AACD,QAAMC,IAAI,GAAGD,KAAK,CAACE,KAAN,CAAa,WAAb,KAA8BF,KAAK,CAACE,KAAN,CAAYC,IAAvD;;AACA,MAAKF,IAAI,IAAIA,IAAI,CAACG,MAAlB,EAA2B;AAC1B,WAAOH,IAAI,CAAE,CAAF,CAAJ,CAAUI,IAAjB;AACA;;AACD,SAAO,KAAP;AACA","sourcesContent":["/**\n * Get the plugin's direct API link out of a block-directory response.\n *\n * @param {Object} block The block object\n *\n * @return {string} The plugin URL, if exists.\n */\nexport default function getPluginUrl( block ) {\n\tif ( ! block ) {\n\t\treturn false;\n\t}\n\tconst link = block.links[ 'wp:plugin' ] || block.links.self;\n\tif ( link && link.length ) {\n\t\treturn link[ 0 ].href;\n\t}\n\treturn false;\n}\n"]}
1
+ {"version":3,"names":["getPluginUrl","block","link","links","self","length","href"],"sources":["@wordpress/block-directory/src/store/utils/get-plugin-url.js"],"sourcesContent":["/**\n * Get the plugin's direct API link out of a block-directory response.\n *\n * @param {Object} block The block object\n *\n * @return {string} The plugin URL, if exists.\n */\nexport default function getPluginUrl( block ) {\n\tif ( ! block ) {\n\t\treturn false;\n\t}\n\tconst link = block.links[ 'wp:plugin' ] || block.links.self;\n\tif ( link && link.length ) {\n\t\treturn link[ 0 ].href;\n\t}\n\treturn false;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,YAAYA,CAAEC,KAAK,EAAG;EAC7C,IAAK,CAAEA,KAAK,EAAG;IACd,OAAO,KAAK;EACb;EACA,MAAMC,IAAI,GAAGD,KAAK,CAACE,KAAK,CAAE,WAAW,CAAE,IAAIF,KAAK,CAACE,KAAK,CAACC,IAAI;EAC3D,IAAKF,IAAI,IAAIA,IAAI,CAACG,MAAM,EAAG;IAC1B,OAAOH,IAAI,CAAE,CAAC,CAAE,CAACI,IAAI;EACtB;EACA,OAAO,KAAK;AACb"}
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = hasBlockType;
7
-
8
7
  /**
9
8
  * Check if a block list contains a specific block type. Recursively searches
10
9
  * through `innerBlocks` if they exist.
@@ -18,19 +17,16 @@ function hasBlockType(blockType, blocks = []) {
18
17
  if (!blocks.length) {
19
18
  return false;
20
19
  }
21
-
22
20
  if (blocks.some(({
23
21
  name
24
22
  }) => name === blockType.name)) {
25
23
  return true;
26
24
  }
27
-
28
25
  for (let i = 0; i < blocks.length; i++) {
29
26
  if (hasBlockType(blockType, blocks[i].innerBlocks)) {
30
27
  return true;
31
28
  }
32
29
  }
33
-
34
30
  return false;
35
31
  }
36
32
  //# sourceMappingURL=has-block-type.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/store/utils/has-block-type.js"],"names":["hasBlockType","blockType","blocks","length","some","name","i","innerBlocks"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,YAAT,CAAuBC,SAAvB,EAAkCC,MAAM,GAAG,EAA3C,EAAgD;AAC9D,MAAK,CAAEA,MAAM,CAACC,MAAd,EAAuB;AACtB,WAAO,KAAP;AACA;;AACD,MAAKD,MAAM,CAACE,IAAP,CAAa,CAAE;AAAEC,IAAAA;AAAF,GAAF,KAAgBA,IAAI,KAAKJ,SAAS,CAACI,IAAhD,CAAL,EAA8D;AAC7D,WAAO,IAAP;AACA;;AACD,OAAM,IAAIC,CAAC,GAAG,CAAd,EAAiBA,CAAC,GAAGJ,MAAM,CAACC,MAA5B,EAAoCG,CAAC,EAArC,EAA0C;AACzC,QAAKN,YAAY,CAAEC,SAAF,EAAaC,MAAM,CAAEI,CAAF,CAAN,CAAYC,WAAzB,CAAjB,EAA0D;AACzD,aAAO,IAAP;AACA;AACD;;AAED,SAAO,KAAP;AACA","sourcesContent":["/**\n * Check if a block list contains a specific block type. Recursively searches\n * through `innerBlocks` if they exist.\n *\n * @param {Object} blockType A block object to search for.\n * @param {Object[]} blocks The list of blocks to look through.\n *\n * @return {boolean} Whether the blockType is found.\n */\nexport default function hasBlockType( blockType, blocks = [] ) {\n\tif ( ! blocks.length ) {\n\t\treturn false;\n\t}\n\tif ( blocks.some( ( { name } ) => name === blockType.name ) ) {\n\t\treturn true;\n\t}\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( hasBlockType( blockType, blocks[ i ].innerBlocks ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n"]}
1
+ {"version":3,"names":["hasBlockType","blockType","blocks","length","some","name","i","innerBlocks"],"sources":["@wordpress/block-directory/src/store/utils/has-block-type.js"],"sourcesContent":["/**\n * Check if a block list contains a specific block type. Recursively searches\n * through `innerBlocks` if they exist.\n *\n * @param {Object} blockType A block object to search for.\n * @param {Object[]} blocks The list of blocks to look through.\n *\n * @return {boolean} Whether the blockType is found.\n */\nexport default function hasBlockType( blockType, blocks = [] ) {\n\tif ( ! blocks.length ) {\n\t\treturn false;\n\t}\n\tif ( blocks.some( ( { name } ) => name === blockType.name ) ) {\n\t\treturn true;\n\t}\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( hasBlockType( blockType, blocks[ i ].innerBlocks ) ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,YAAYA,CAAEC,SAAS,EAAEC,MAAM,GAAG,EAAE,EAAG;EAC9D,IAAK,CAAEA,MAAM,CAACC,MAAM,EAAG;IACtB,OAAO,KAAK;EACb;EACA,IAAKD,MAAM,CAACE,IAAI,CAAE,CAAE;IAAEC;EAAK,CAAC,KAAMA,IAAI,KAAKJ,SAAS,CAACI,IAAK,CAAC,EAAG;IAC7D,OAAO,IAAI;EACZ;EACA,KAAM,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGJ,MAAM,CAACC,MAAM,EAAEG,CAAC,EAAE,EAAG;IACzC,IAAKN,YAAY,CAAEC,SAAS,EAAEC,MAAM,CAAEI,CAAC,CAAE,CAACC,WAAY,CAAC,EAAG;MACzD,OAAO,IAAI;IACZ;EACD;EAEA,OAAO,KAAK;AACb"}
@@ -5,10 +5,10 @@ import { unregisterBlockType } from '@wordpress/blocks';
5
5
  import { useDispatch, useSelect } from '@wordpress/data';
6
6
  import { useEffect } from '@wordpress/element';
7
7
  import { store as editorStore } from '@wordpress/editor';
8
+
8
9
  /**
9
10
  * Internal dependencies
10
11
  */
11
-
12
12
  import { store as blockDirectoryStore } from '../../store';
13
13
  export default function AutoBlockUninstaller() {
14
14
  const {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/auto-block-uninstaller/index.js"],"names":["unregisterBlockType","useDispatch","useSelect","useEffect","store","editorStore","blockDirectoryStore","AutoBlockUninstaller","uninstallBlockType","shouldRemoveBlockTypes","select","isAutosavingPost","isSavingPost","unusedBlockTypes","getUnusedBlockTypes","length","forEach","blockType","name"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,mBAAT,QAAoC,mBAApC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,mBAAlB,QAA6C,aAA7C;AAEA,eAAe,SAASC,oBAAT,GAAgC;AAC9C,QAAM;AAAEC,IAAAA;AAAF,MAAyBP,WAAW,CAAEK,mBAAF,CAA1C;AAEA,QAAMG,sBAAsB,GAAGP,SAAS,CAAIQ,MAAF,IAAc;AACvD,UAAM;AAAEC,MAAAA,gBAAF;AAAoBC,MAAAA;AAApB,QAAqCF,MAAM,CAAEL,WAAF,CAAjD;AACA,WAAOO,YAAY,MAAM,CAAED,gBAAgB,EAA3C;AACA,GAHuC,EAGrC,EAHqC,CAAxC;AAKA,QAAME,gBAAgB,GAAGX,SAAS,CAC/BQ,MAAF,IAAcA,MAAM,CAAEJ,mBAAF,CAAN,CAA8BQ,mBAA9B,EADmB,EAEjC,EAFiC,CAAlC;AAKAX,EAAAA,SAAS,CAAE,MAAM;AAChB,QAAKM,sBAAsB,IAAII,gBAAgB,CAACE,MAAhD,EAAyD;AACxDF,MAAAA,gBAAgB,CAACG,OAAjB,CAA4BC,SAAF,IAAiB;AAC1CT,QAAAA,kBAAkB,CAAES,SAAF,CAAlB;AACAjB,QAAAA,mBAAmB,CAAEiB,SAAS,CAACC,IAAZ,CAAnB;AACA,OAHD;AAIA;AACD,GAPQ,EAON,CAAET,sBAAF,CAPM,CAAT;AASA,SAAO,IAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { unregisterBlockType } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function AutoBlockUninstaller() {\n\tconst { uninstallBlockType } = useDispatch( blockDirectoryStore );\n\n\tconst shouldRemoveBlockTypes = useSelect( ( select ) => {\n\t\tconst { isAutosavingPost, isSavingPost } = select( editorStore );\n\t\treturn isSavingPost() && ! isAutosavingPost();\n\t}, [] );\n\n\tconst unusedBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getUnusedBlockTypes(),\n\t\t[]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( shouldRemoveBlockTypes && unusedBlockTypes.length ) {\n\t\t\tunusedBlockTypes.forEach( ( blockType ) => {\n\t\t\t\tuninstallBlockType( blockType );\n\t\t\t\tunregisterBlockType( blockType.name );\n\t\t\t} );\n\t\t}\n\t}, [ shouldRemoveBlockTypes ] );\n\n\treturn null;\n}\n"]}
1
+ {"version":3,"names":["unregisterBlockType","useDispatch","useSelect","useEffect","store","editorStore","blockDirectoryStore","AutoBlockUninstaller","uninstallBlockType","shouldRemoveBlockTypes","select","isAutosavingPost","isSavingPost","unusedBlockTypes","getUnusedBlockTypes","length","forEach","blockType","name"],"sources":["@wordpress/block-directory/src/components/auto-block-uninstaller/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { unregisterBlockType } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function AutoBlockUninstaller() {\n\tconst { uninstallBlockType } = useDispatch( blockDirectoryStore );\n\n\tconst shouldRemoveBlockTypes = useSelect( ( select ) => {\n\t\tconst { isAutosavingPost, isSavingPost } = select( editorStore );\n\t\treturn isSavingPost() && ! isAutosavingPost();\n\t}, [] );\n\n\tconst unusedBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getUnusedBlockTypes(),\n\t\t[]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( shouldRemoveBlockTypes && unusedBlockTypes.length ) {\n\t\t\tunusedBlockTypes.forEach( ( blockType ) => {\n\t\t\t\tuninstallBlockType( blockType );\n\t\t\t\tunregisterBlockType( blockType.name );\n\t\t\t} );\n\t\t}\n\t}, [ shouldRemoveBlockTypes ] );\n\n\treturn null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,mBAAmB,QAAQ,mBAAmB;AACvD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,mBAAmB,QAAQ,aAAa;AAE1D,eAAe,SAASC,oBAAoBA,CAAA,EAAG;EAC9C,MAAM;IAAEC;EAAmB,CAAC,GAAGP,WAAW,CAAEK,mBAAoB,CAAC;EAEjE,MAAMG,sBAAsB,GAAGP,SAAS,CAAIQ,MAAM,IAAM;IACvD,MAAM;MAAEC,gBAAgB;MAAEC;IAAa,CAAC,GAAGF,MAAM,CAAEL,WAAY,CAAC;IAChE,OAAOO,YAAY,CAAC,CAAC,IAAI,CAAED,gBAAgB,CAAC,CAAC;EAC9C,CAAC,EAAE,EAAG,CAAC;EAEP,MAAME,gBAAgB,GAAGX,SAAS,CAC/BQ,MAAM,IAAMA,MAAM,CAAEJ,mBAAoB,CAAC,CAACQ,mBAAmB,CAAC,CAAC,EACjE,EACD,CAAC;EAEDX,SAAS,CAAE,MAAM;IAChB,IAAKM,sBAAsB,IAAII,gBAAgB,CAACE,MAAM,EAAG;MACxDF,gBAAgB,CAACG,OAAO,CAAIC,SAAS,IAAM;QAC1CT,kBAAkB,CAAES,SAAU,CAAC;QAC/BjB,mBAAmB,CAAEiB,SAAS,CAACC,IAAK,CAAC;MACtC,CAAE,CAAC;IACJ;EACD,CAAC,EAAE,CAAET,sBAAsB,CAAG,CAAC;EAE/B,OAAO,IAAI;AACZ"}
@@ -1,5 +1,4 @@
1
1
  import { createElement } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * Internal dependencies
5
4
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/block-ratings/index.js"],"names":["Stars","BlockRatings","rating"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,KAAP,MAAkB,SAAlB;AAEA,OAAO,MAAMC,YAAY,GAAG,CAAE;AAAEC,EAAAA;AAAF,CAAF,KAC3B;AAAM,EAAA,SAAS,EAAC;AAAhB,GACC,cAAC,KAAD;AAAO,EAAA,MAAM,EAAGA;AAAhB,EADD,CADM;AAMP,eAAeD,YAAf","sourcesContent":["/**\n * Internal dependencies\n */\nimport Stars from './stars';\n\nexport const BlockRatings = ( { rating } ) => (\n\t<span className=\"block-directory-block-ratings\">\n\t\t<Stars rating={ rating } />\n\t</span>\n);\n\nexport default BlockRatings;\n"]}
1
+ {"version":3,"names":["Stars","BlockRatings","rating","createElement","className"],"sources":["@wordpress/block-directory/src/components/block-ratings/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport Stars from './stars';\n\nexport const BlockRatings = ( { rating } ) => (\n\t<span className=\"block-directory-block-ratings\">\n\t\t<Stars rating={ rating } />\n\t</span>\n);\n\nexport default BlockRatings;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,KAAK,MAAM,SAAS;AAE3B,OAAO,MAAMC,YAAY,GAAGA,CAAE;EAAEC;AAAO,CAAC,KACvCC,aAAA;EAAMC,SAAS,EAAC;AAA+B,GAC9CD,aAAA,CAACH,KAAK;EAACE,MAAM,EAAGA;AAAQ,CAAE,CACrB,CACN;AAED,eAAeD,YAAY"}
@@ -1,11 +1,9 @@
1
1
  import { createElement } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * WordPress dependencies
5
4
  */
6
5
  import { __, sprintf } from '@wordpress/i18n';
7
6
  import { Icon, starEmpty, starFilled, starHalf } from '@wordpress/icons';
8
-
9
7
  function Stars({
10
8
  rating
11
9
  }) {
@@ -14,8 +12,7 @@ function Stars({
14
12
  const halfStarCount = Math.ceil(rating - fullStarCount);
15
13
  const emptyStarCount = 5 - (fullStarCount + halfStarCount);
16
14
  return createElement("span", {
17
- "aria-label": sprintf(
18
- /* translators: %s: number of stars. */
15
+ "aria-label": sprintf( /* translators: %s: number of stars. */
19
16
  __('%s out of 5 stars'), stars)
20
17
  }, Array.from({
21
18
  length: fullStarCount
@@ -40,6 +37,5 @@ function Stars({
40
37
  size: 16
41
38
  })));
42
39
  }
43
-
44
40
  export default Stars;
45
41
  //# sourceMappingURL=stars.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/block-ratings/stars.js"],"names":["__","sprintf","Icon","starEmpty","starFilled","starHalf","Stars","rating","stars","Math","round","fullStarCount","floor","halfStarCount","ceil","emptyStarCount","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IAAAA,MAAM,EAAEH;AAAV,GAAZ,EAAyCI,GAAzC,CAA8C,CAAEC,CAAF,EAAKC,CAAL,KAC/C,cAAC,IAAD;AACC,IAAA,GAAG,EAAI,eAAeA,CAAG,EAD1B;AAEC,IAAA,SAAS,EAAC,2CAFX;AAGC,IAAA,IAAI,EAAGlB,SAHR;AAIC,IAAA,IAAI,EAAG;AAJR,IADC,CAvBH,CADD;AAkCA;;AAED,eAAeG,KAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Icon, starEmpty, starFilled, starHalf } from '@wordpress/icons';\n\nfunction Stars( { rating } ) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tconst fullStarCount = Math.floor( rating );\n\tconst halfStarCount = Math.ceil( rating - fullStarCount );\n\tconst emptyStarCount = 5 - ( fullStarCount + halfStarCount );\n\n\treturn (\n\t\t<span\n\t\t\taria-label={ sprintf(\n\t\t\t\t/* translators: %s: number of stars. */\n\t\t\t\t__( '%s out of 5 stars' ),\n\t\t\t\tstars\n\t\t\t) }\n\t\t>\n\t\t\t{ Array.from( { length: fullStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `full_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-full\"\n\t\t\t\t\ticon={ starFilled }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: halfStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `half_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-half-full\"\n\t\t\t\t\ticon={ starHalf }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: emptyStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `empty_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-empty\"\n\t\t\t\t\ticon={ starEmpty }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</span>\n\t);\n}\n\nexport default Stars;\n"]}
1
+ {"version":3,"names":["__","sprintf","Icon","starEmpty","starFilled","starHalf","Stars","rating","stars","Math","round","fullStarCount","floor","halfStarCount","ceil","emptyStarCount","createElement","Array","from","length","map","_","i","key","className","icon","size"],"sources":["@wordpress/block-directory/src/components/block-ratings/stars.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Icon, starEmpty, starFilled, starHalf } from '@wordpress/icons';\n\nfunction Stars( { rating } ) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tconst fullStarCount = Math.floor( rating );\n\tconst halfStarCount = Math.ceil( rating - fullStarCount );\n\tconst emptyStarCount = 5 - ( fullStarCount + halfStarCount );\n\n\treturn (\n\t\t<span\n\t\t\taria-label={ sprintf(\n\t\t\t\t/* translators: %s: number of stars. */\n\t\t\t\t__( '%s out of 5 stars' ),\n\t\t\t\tstars\n\t\t\t) }\n\t\t>\n\t\t\t{ Array.from( { length: fullStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `full_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-full\"\n\t\t\t\t\ticon={ starFilled }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: halfStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `half_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-half-full\"\n\t\t\t\t\ticon={ starHalf }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: emptyStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `empty_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-empty\"\n\t\t\t\t\ticon={ starEmpty }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</span>\n\t);\n}\n\nexport default Stars;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,IAAI,EAAEC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,kBAAkB;AAExE,SAASC,KAAKA,CAAE;EAAEC;AAAO,CAAC,EAAG;EAC5B,MAAMC,KAAK,GAAGC,IAAI,CAACC,KAAK,CAAEH,MAAM,GAAG,GAAI,CAAC,GAAG,GAAG;EAE9C,MAAMI,aAAa,GAAGF,IAAI,CAACG,KAAK,CAAEL,MAAO,CAAC;EAC1C,MAAMM,aAAa,GAAGJ,IAAI,CAACK,IAAI,CAAEP,MAAM,GAAGI,aAAc,CAAC;EACzD,MAAMI,cAAc,GAAG,CAAC,IAAKJ,aAAa,GAAGE,aAAa,CAAE;EAE5D,OACCG,aAAA;IACC,cAAaf,OAAO,EACnB;IACAD,EAAE,CAAE,mBAAoB,CAAC,EACzBQ,KACD;EAAG,GAEDS,KAAK,CAACC,IAAI,CAAE;IAAEC,MAAM,EAAER;EAAc,CAAE,CAAC,CAACS,GAAG,CAAE,CAAEC,CAAC,EAAEC,CAAC,KACpDN,aAAA,CAACd,IAAI;IACJqB,GAAG,EAAI,cAAcD,CAAG,EAAG;IAC3BE,SAAS,EAAC,0CAA0C;IACpDC,IAAI,EAAGrB,UAAY;IACnBsB,IAAI,EAAG;EAAI,CACX,CACA,CAAC,EACDT,KAAK,CAACC,IAAI,CAAE;IAAEC,MAAM,EAAEN;EAAc,CAAE,CAAC,CAACO,GAAG,CAAE,CAAEC,CAAC,EAAEC,CAAC,KACpDN,aAAA,CAACd,IAAI;IACJqB,GAAG,EAAI,cAAcD,CAAG,EAAG;IAC3BE,SAAS,EAAC,+CAA+C;IACzDC,IAAI,EAAGpB,QAAU;IACjBqB,IAAI,EAAG;EAAI,CACX,CACA,CAAC,EACDT,KAAK,CAACC,IAAI,CAAE;IAAEC,MAAM,EAAEJ;EAAe,CAAE,CAAC,CAACK,GAAG,CAAE,CAAEC,CAAC,EAAEC,CAAC,KACrDN,aAAA,CAACd,IAAI;IACJqB,GAAG,EAAI,eAAeD,CAAG,EAAG;IAC5BE,SAAS,EAAC,2CAA2C;IACrDC,IAAI,EAAGtB,SAAW;IAClBuB,IAAI,EAAG;EAAI,CACX,CACA,CACG,CAAC;AAET;AAEA,eAAepB,KAAK"}
@@ -1,13 +1,12 @@
1
1
  import { createElement } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * WordPress dependencies
5
4
  */
6
5
  import { __, sprintf } from '@wordpress/i18n';
6
+
7
7
  /**
8
8
  * Internal dependencies
9
9
  */
10
-
11
10
  import DownloadableBlockIcon from '../downloadable-block-icon';
12
11
  export default function CompactList({
13
12
  items
@@ -15,7 +14,6 @@ export default function CompactList({
15
14
  if (!items.length) {
16
15
  return null;
17
16
  }
18
-
19
17
  return createElement("ul", {
20
18
  className: "block-directory-compact-list"
21
19
  }, items.map(({
@@ -35,8 +33,7 @@ export default function CompactList({
35
33
  className: "block-directory-compact-list__item-title"
36
34
  }, title), createElement("div", {
37
35
  className: "block-directory-compact-list__item-author"
38
- }, sprintf(
39
- /* translators: %s: Name of the block author. */
36
+ }, sprintf( /* translators: %s: Name of the block author. */
40
37
  __('By %s'), author))))));
41
38
  }
42
39
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/compact-list/index.js"],"names":["__","sprintf","DownloadableBlockIcon","CompactList","items","length","map","icon","id","title","author"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AAEA,eAAe,SAASC,WAAT,CAAsB;AAAEC,EAAAA;AAAF,CAAtB,EAAkC;AAChD,MAAK,CAAEA,KAAK,CAACC,MAAb,EAAsB;AACrB,WAAO,IAAP;AACA;;AAED,SACC;AAAI,IAAA,SAAS,EAAC;AAAd,KACGD,KAAK,CAACE,GAAN,CAAW,CAAE;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,EAAR;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA;AAAnB,GAAF,KACZ;AAAI,IAAA,GAAG,EAAGF,EAAV;AAAe,IAAA,SAAS,EAAC;AAAzB,KACC,cAAC,qBAAD;AAAuB,IAAA,IAAI,EAAGD,IAA9B;AAAqC,IAAA,KAAK,EAAGE;AAA7C,IADD,EAGC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGA,KADH,CADD,EAIC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGR,OAAO;AACR;AACAD,EAAAA,EAAE,CAAE,OAAF,CAFM,EAGRU,MAHQ,CADV,CAJD,CAHD,CADC,CADH,CADD;AAsBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlockIcon from '../downloadable-block-icon';\n\nexport default function CompactList( { items } ) {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ul className=\"block-directory-compact-list\">\n\t\t\t{ items.map( ( { icon, id, title, author } ) => (\n\t\t\t\t<li key={ id } className=\"block-directory-compact-list__item\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\n\t\t\t\t\t<div className=\"block-directory-compact-list__item-details\">\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-title\">\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-author\">\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: Name of the block author. */\n\t\t\t\t\t\t\t\t__( 'By %s' ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n"]}
1
+ {"version":3,"names":["__","sprintf","DownloadableBlockIcon","CompactList","items","length","createElement","className","map","icon","id","title","author","key"],"sources":["@wordpress/block-directory/src/components/compact-list/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlockIcon from '../downloadable-block-icon';\n\nexport default function CompactList( { items } ) {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ul className=\"block-directory-compact-list\">\n\t\t\t{ items.map( ( { icon, id, title, author } ) => (\n\t\t\t\t<li key={ id } className=\"block-directory-compact-list__item\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\n\t\t\t\t\t<div className=\"block-directory-compact-list__item-details\">\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-title\">\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-author\">\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: Name of the block author. */\n\t\t\t\t\t\t\t\t__( 'By %s' ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,4BAA4B;AAE9D,eAAe,SAASC,WAAWA,CAAE;EAAEC;AAAM,CAAC,EAAG;EAChD,IAAK,CAAEA,KAAK,CAACC,MAAM,EAAG;IACrB,OAAO,IAAI;EACZ;EAEA,OACCC,aAAA;IAAIC,SAAS,EAAC;EAA8B,GACzCH,KAAK,CAACI,GAAG,CAAE,CAAE;IAAEC,IAAI;IAAEC,EAAE;IAAEC,KAAK;IAAEC;EAAO,CAAC,KACzCN,aAAA;IAAIO,GAAG,EAAGH,EAAI;IAACH,SAAS,EAAC;EAAoC,GAC5DD,aAAA,CAACJ,qBAAqB;IAACO,IAAI,EAAGA,IAAM;IAACE,KAAK,EAAGA;EAAO,CAAE,CAAC,EAEvDL,aAAA;IAAKC,SAAS,EAAC;EAA4C,GAC1DD,aAAA;IAAKC,SAAS,EAAC;EAA0C,GACtDI,KACE,CAAC,EACNL,aAAA;IAAKC,SAAS,EAAC;EAA2C,GACvDN,OAAO,EACR;EACAD,EAAE,CAAE,OAAQ,CAAC,EACbY,MACD,CACI,CACD,CACF,CACH,CACC,CAAC;AAEP"}
@@ -1,10 +1,8 @@
1
1
  import { createElement } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * WordPress dependencies
5
4
  */
6
5
  import { BlockIcon } from '@wordpress/block-editor';
7
-
8
6
  function DownloadableBlockIcon({
9
7
  icon
10
8
  }) {
@@ -19,6 +17,5 @@ function DownloadableBlockIcon({
19
17
  showColors: true
20
18
  });
21
19
  }
22
-
23
20
  export default DownloadableBlockIcon;
24
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-block-icon/index.js"],"names":["BlockIcon","DownloadableBlockIcon","icon","className","match"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,yBAA1B;;AAEA,SAASC,qBAAT,CAAgC;AAAEC,EAAAA;AAAF,CAAhC,EAA2C;AAC1C,QAAMC,SAAS,GAAG,yCAAlB;AACA,SAAOD,IAAI,CAACE,KAAL,CAAY,oCAAZ,MAAuD,IAAvD,GACN;AAAK,IAAA,SAAS,EAAGD,SAAjB;AAA6B,IAAA,GAAG,EAAGD,IAAnC;AAA0C,IAAA,GAAG,EAAC;AAA9C,IADM,GAGN,cAAC,SAAD;AAAW,IAAA,SAAS,EAAGC,SAAvB;AAAmC,IAAA,IAAI,EAAGD,IAA1C;AAAiD,IAAA,UAAU;AAA3D,IAHD;AAKA;;AAED,eAAeD,qBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BlockIcon } from '@wordpress/block-editor';\n\nfunction DownloadableBlockIcon( { icon } ) {\n\tconst className = 'block-directory-downloadable-block-icon';\n\treturn icon.match( /\\.(jpeg|jpg|gif|png|svg)(?:\\?.*)?$/ ) !== null ? (\n\t\t<img className={ className } src={ icon } alt=\"\" />\n\t) : (\n\t\t<BlockIcon className={ className } icon={ icon } showColors />\n\t);\n}\n\nexport default DownloadableBlockIcon;\n"]}
1
+ {"version":3,"names":["BlockIcon","DownloadableBlockIcon","icon","className","match","createElement","src","alt","showColors"],"sources":["@wordpress/block-directory/src/components/downloadable-block-icon/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BlockIcon } from '@wordpress/block-editor';\n\nfunction DownloadableBlockIcon( { icon } ) {\n\tconst className = 'block-directory-downloadable-block-icon';\n\treturn icon.match( /\\.(jpeg|jpg|gif|png|svg)(?:\\?.*)?$/ ) !== null ? (\n\t\t<img className={ className } src={ icon } alt=\"\" />\n\t) : (\n\t\t<BlockIcon className={ className } icon={ icon } showColors />\n\t);\n}\n\nexport default DownloadableBlockIcon;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,yBAAyB;AAEnD,SAASC,qBAAqBA,CAAE;EAAEC;AAAK,CAAC,EAAG;EAC1C,MAAMC,SAAS,GAAG,yCAAyC;EAC3D,OAAOD,IAAI,CAACE,KAAK,CAAE,oCAAqC,CAAC,KAAK,IAAI,GACjEC,aAAA;IAAKF,SAAS,EAAGA,SAAW;IAACG,GAAG,EAAGJ,IAAM;IAACK,GAAG,EAAC;EAAE,CAAE,CAAC,GAEnDF,aAAA,CAACL,SAAS;IAACG,SAAS,EAAGA,SAAW;IAACD,IAAI,EAAGA,IAAM;IAACM,UAAU;EAAA,CAAE,CAC7D;AACF;AAEA,eAAeP,qBAAqB"}
@@ -1,5 +1,4 @@
1
1
  import { createElement, Fragment } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * WordPress dependencies
5
4
  */
@@ -9,15 +8,16 @@ import { createInterpolateElement } from '@wordpress/element';
9
8
  import { decodeEntities } from '@wordpress/html-entities';
10
9
  import { getBlockType } from '@wordpress/blocks';
11
10
  import { useSelect } from '@wordpress/data';
11
+
12
12
  /**
13
13
  * Internal dependencies
14
14
  */
15
-
16
15
  import BlockRatings from '../block-ratings';
17
16
  import DownloadableBlockIcon from '../downloadable-block-icon';
18
17
  import DownloadableBlockNotice from '../downloadable-block-notice';
19
- import { store as blockDirectoryStore } from '../../store'; // Return the appropriate block item label, given the block data and status.
18
+ import { store as blockDirectoryStore } from '../../store';
20
19
 
20
+ // Return the appropriate block item label, given the block data and status.
21
21
  function getDownloadableBlockLabel({
22
22
  title,
23
23
  rating,
@@ -28,33 +28,27 @@ function getDownloadableBlockLabel({
28
28
  isInstalling
29
29
  }) {
30
30
  const stars = Math.round(rating / 0.5) * 0.5;
31
-
32
31
  if (!isInstalled && hasNotice) {
33
32
  /* translators: %1$s: block title */
34
33
  return sprintf('Retry installing %s.', decodeEntities(title));
35
34
  }
36
-
37
35
  if (isInstalled) {
38
36
  /* translators: %1$s: block title */
39
37
  return sprintf('Add %s.', decodeEntities(title));
40
38
  }
41
-
42
39
  if (isInstalling) {
43
40
  /* translators: %1$s: block title */
44
41
  return sprintf('Installing %s.', decodeEntities(title));
45
- } // No ratings yet, just use the title.
46
-
42
+ }
47
43
 
44
+ // No ratings yet, just use the title.
48
45
  if (ratingCount < 1) {
49
46
  /* translators: %1$s: block title */
50
47
  return sprintf('Install %s.', decodeEntities(title));
51
48
  }
52
-
53
- return sprintf(
54
- /* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */
49
+ return sprintf( /* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */
55
50
  _n('Install %1$s. %2$s stars with %3$s review.', 'Install %1$s. %2$s stars with %3$s reviews.', ratingCount), decodeEntities(title), stars, ratingCount);
56
51
  }
57
-
58
52
  function DownloadableBlockListItem({
59
53
  composite,
60
54
  item,
@@ -66,8 +60,8 @@ function DownloadableBlockListItem({
66
60
  icon,
67
61
  rating,
68
62
  title
69
- } = item; // getBlockType returns a block object if this block exists, or null if not.
70
-
63
+ } = item;
64
+ // getBlockType returns a block object if this block exists, or null if not.
71
65
  const isInstalled = !!getBlockType(item.name);
72
66
  const {
73
67
  hasNotice,
@@ -87,13 +81,11 @@ function DownloadableBlockListItem({
87
81
  };
88
82
  }, [item]);
89
83
  let statusText = '';
90
-
91
84
  if (isInstalled) {
92
85
  statusText = __('Installed!');
93
86
  } else if (isInstalling) {
94
87
  statusText = __('Installing…');
95
88
  }
96
-
97
89
  return createElement(CompositeItem, {
98
90
  __experimentalIsFocusable: true,
99
91
  role: "option",
@@ -126,8 +118,7 @@ function DownloadableBlockListItem({
126
118
  className: "block-directory-downloadable-block-list-item__details"
127
119
  }, createElement("span", {
128
120
  className: "block-directory-downloadable-block-list-item__title"
129
- }, createInterpolateElement(sprintf(
130
- /* translators: %1$s: block title, %2$s: author name. */
121
+ }, createInterpolateElement(sprintf( /* translators: %1$s: block title, %2$s: author name. */
131
122
  __('%1$s <span>by %2$s</span>'), decodeEntities(title), author), {
132
123
  span: createElement("span", {
133
124
  className: "block-directory-downloadable-block-list-item__author"
@@ -138,6 +129,5 @@ function DownloadableBlockListItem({
138
129
  className: "block-directory-downloadable-block-list-item__desc"
139
130
  }, !!statusText ? statusText : decodeEntities(description)), isInstallable && !(isInstalled || isInstalling) && createElement(VisuallyHidden, null, __('Install block')))));
140
131
  }
141
-
142
132
  export default DownloadableBlockListItem;
143
133
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"names":["__","_n","sprintf","Button","Spinner","VisuallyHidden","__unstableCompositeItem","CompositeItem","createInterpolateElement","decodeEntities","getBlockType","useSelect","BlockRatings","DownloadableBlockIcon","DownloadableBlockNotice","store","blockDirectoryStore","getDownloadableBlockLabel","title","rating","ratingCount","hasNotice","isInstalled","isInstalling","stars","Math","round","DownloadableBlockListItem","composite","item","onClick","author","description","icon","name","isInstallable","select","getErrorNoticeForBlock","isBlockInstalling","notice","id","hasFatal","isFatal","statusText","event","preventDefault","span"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,EAAb,EAAiBC,OAAjB,QAAgC,iBAAhC;AACA,SACCC,MADD,EAECC,OAFD,EAGCC,cAHD,EAICC,uBAAuB,IAAIC,aAJ5B,QAKO,uBALP;AAMA,SAASC,wBAAT,QAAyC,oBAAzC;AACA,SAASC,cAAT,QAA+B,0BAA/B;AACA,SAASC,YAAT,QAA6B,mBAA7B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,OAAOC,uBAAP,MAAoC,8BAApC;AACA,SAASC,KAAK,IAAIC,mBAAlB,QAA6C,aAA7C,C,CAEA;;AACA,SAASC,yBAAT,CACC;AAAEC,EAAAA,KAAF;AAASC,EAAAA,MAAT;AAAiBC,EAAAA;AAAjB,CADD,EAEC;AAAEC,EAAAA,SAAF;AAAaC,EAAAA,WAAb;AAA0BC,EAAAA;AAA1B,CAFD,EAGE;AACD,QAAMC,KAAK,GAAGC,IAAI,CAACC,KAAL,CAAYP,MAAM,GAAG,GAArB,IAA6B,GAA3C;;AAEA,MAAK,CAAEG,WAAF,IAAiBD,SAAtB,EAAkC;AACjC;AACA,WAAOnB,OAAO,CAAE,sBAAF,EAA0BO,cAAc,CAAES,KAAF,CAAxC,CAAd;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B,KACC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGX,wBAAwB,CACzBN,OAAO;AACN;AACAF,EAAAA,EAAE,CAAE,2BAAF,CAFI,EAGNS,cAAc,CAAES,KAAF,CAHR,EAINa,MAJM,CADkB,EAOzB;AACCe,IAAAA,IAAI,EACH;AAAM,MAAA,SAAS,EAAC;AAAhB;AAFF,GAPyB,CAD3B,CADD,EAgBGzB,SAAS,GACV,cAAC,uBAAD;AAAyB,IAAA,KAAK,EAAGQ;AAAjC,IADU,GAGV,8BACC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACG,CAAC,CAAEc,UAAH,GACCA,UADD,GAEClC,cAAc,CAAEuB,WAAF,CAHlB,CADD,EAMGG,aAAa,IACd,EAAIb,WAAW,IAAIC,YAAnB,CADC,IAEA,cAAC,cAAD,QACGvB,EAAE,CAAE,eAAF,CADL,CARH,CAnBF,CA9BD,CADD;AAmEA;;AAED,eAAe2B,yBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tSpinner,\n\tVisuallyHidden,\n\t__unstableCompositeItem as CompositeItem,\n} from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockRatings from '../block-ratings';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\nimport DownloadableBlockNotice from '../downloadable-block-notice';\nimport { store as blockDirectoryStore } from '../../store';\n\n// Return the appropriate block item label, given the block data and status.\nfunction getDownloadableBlockLabel(\n\t{ title, rating, ratingCount },\n\t{ hasNotice, isInstalled, isInstalling }\n) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tif ( ! isInstalled && hasNotice ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Retry installing %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalled ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Add %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalling ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Installing %s.', decodeEntities( title ) );\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Install %s.', decodeEntities( title ) );\n\t}\n\n\treturn sprintf(\n\t\t/* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */\n\t\t_n(\n\t\t\t'Install %1$s. %2$s stars with %3$s review.',\n\t\t\t'Install %1$s. %2$s stars with %3$s reviews.',\n\t\t\tratingCount\n\t\t),\n\t\tdecodeEntities( title ),\n\t\tstars,\n\t\tratingCount\n\t);\n}\n\nfunction DownloadableBlockListItem( { composite, item, onClick } ) {\n\tconst { author, description, icon, rating, title } = item;\n\t// getBlockType returns a block object if this block exists, or null if not.\n\tconst isInstalled = !! getBlockType( item.name );\n\n\tconst { hasNotice, isInstalling, isInstallable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getErrorNoticeForBlock, isInstalling: isBlockInstalling } =\n\t\t\t\tselect( blockDirectoryStore );\n\t\t\tconst notice = getErrorNoticeForBlock( item.id );\n\t\t\tconst hasFatal = notice && notice.isFatal;\n\t\t\treturn {\n\t\t\t\thasNotice: !! notice,\n\t\t\t\tisInstalling: isBlockInstalling( item.id ),\n\t\t\t\tisInstallable: ! hasFatal,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\n\tlet statusText = '';\n\tif ( isInstalled ) {\n\t\tstatusText = __( 'Installed!' );\n\t} else if ( isInstalling ) {\n\t\tstatusText = __( 'Installing…' );\n\t}\n\n\treturn (\n\t\t<CompositeItem\n\t\t\t__experimentalIsFocusable\n\t\t\trole=\"option\"\n\t\t\tas={ Button }\n\t\t\t{ ...composite }\n\t\t\tclassName=\"block-directory-downloadable-block-list-item\"\n\t\t\tonClick={ ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonClick();\n\t\t\t} }\n\t\t\tisBusy={ isInstalling }\n\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\tlabel={ getDownloadableBlockLabel( item, {\n\t\t\t\thasNotice,\n\t\t\t\tisInstalled,\n\t\t\t\tisInstalling,\n\t\t\t} ) }\n\t\t\tshowTooltip={ true }\n\t\t\ttooltipPosition=\"top center\"\n\t\t>\n\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</span>\n\t\t\t\t) : (\n\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %1$s: block title, %2$s: author name. */\n\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__author\" />\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</CompositeItem>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"]}
1
+ {"version":3,"names":["__","_n","sprintf","Button","Spinner","VisuallyHidden","__unstableCompositeItem","CompositeItem","createInterpolateElement","decodeEntities","getBlockType","useSelect","BlockRatings","DownloadableBlockIcon","DownloadableBlockNotice","store","blockDirectoryStore","getDownloadableBlockLabel","title","rating","ratingCount","hasNotice","isInstalled","isInstalling","stars","Math","round","DownloadableBlockListItem","composite","item","onClick","author","description","icon","name","isInstallable","select","getErrorNoticeForBlock","isBlockInstalling","notice","id","hasFatal","isFatal","statusText","createElement","__experimentalIsFocusable","role","as","className","event","preventDefault","isBusy","disabled","label","showTooltip","tooltipPosition","span","block","Fragment"],"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tSpinner,\n\tVisuallyHidden,\n\t__unstableCompositeItem as CompositeItem,\n} from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockRatings from '../block-ratings';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\nimport DownloadableBlockNotice from '../downloadable-block-notice';\nimport { store as blockDirectoryStore } from '../../store';\n\n// Return the appropriate block item label, given the block data and status.\nfunction getDownloadableBlockLabel(\n\t{ title, rating, ratingCount },\n\t{ hasNotice, isInstalled, isInstalling }\n) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tif ( ! isInstalled && hasNotice ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Retry installing %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalled ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Add %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalling ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Installing %s.', decodeEntities( title ) );\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Install %s.', decodeEntities( title ) );\n\t}\n\n\treturn sprintf(\n\t\t/* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */\n\t\t_n(\n\t\t\t'Install %1$s. %2$s stars with %3$s review.',\n\t\t\t'Install %1$s. %2$s stars with %3$s reviews.',\n\t\t\tratingCount\n\t\t),\n\t\tdecodeEntities( title ),\n\t\tstars,\n\t\tratingCount\n\t);\n}\n\nfunction DownloadableBlockListItem( { composite, item, onClick } ) {\n\tconst { author, description, icon, rating, title } = item;\n\t// getBlockType returns a block object if this block exists, or null if not.\n\tconst isInstalled = !! getBlockType( item.name );\n\n\tconst { hasNotice, isInstalling, isInstallable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getErrorNoticeForBlock, isInstalling: isBlockInstalling } =\n\t\t\t\tselect( blockDirectoryStore );\n\t\t\tconst notice = getErrorNoticeForBlock( item.id );\n\t\t\tconst hasFatal = notice && notice.isFatal;\n\t\t\treturn {\n\t\t\t\thasNotice: !! notice,\n\t\t\t\tisInstalling: isBlockInstalling( item.id ),\n\t\t\t\tisInstallable: ! hasFatal,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\n\tlet statusText = '';\n\tif ( isInstalled ) {\n\t\tstatusText = __( 'Installed!' );\n\t} else if ( isInstalling ) {\n\t\tstatusText = __( 'Installing…' );\n\t}\n\n\treturn (\n\t\t<CompositeItem\n\t\t\t__experimentalIsFocusable\n\t\t\trole=\"option\"\n\t\t\tas={ Button }\n\t\t\t{ ...composite }\n\t\t\tclassName=\"block-directory-downloadable-block-list-item\"\n\t\t\tonClick={ ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonClick();\n\t\t\t} }\n\t\t\tisBusy={ isInstalling }\n\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\tlabel={ getDownloadableBlockLabel( item, {\n\t\t\t\thasNotice,\n\t\t\t\tisInstalled,\n\t\t\t\tisInstalling,\n\t\t\t} ) }\n\t\t\tshowTooltip={ true }\n\t\t\ttooltipPosition=\"top center\"\n\t\t>\n\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</span>\n\t\t\t\t) : (\n\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %1$s: block title, %2$s: author name. */\n\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__author\" />\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</CompositeItem>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SACCC,MAAM,EACNC,OAAO,EACPC,cAAc,EACdC,uBAAuB,IAAIC,aAAa,QAClC,uBAAuB;AAC9B,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,uBAAuB,MAAM,8BAA8B;AAClE,SAASC,KAAK,IAAIC,mBAAmB,QAAQ,aAAa;;AAE1D;AACA,SAASC,yBAAyBA,CACjC;EAAEC,KAAK;EAAEC,MAAM;EAAEC;AAAY,CAAC,EAC9B;EAAEC,SAAS;EAAEC,WAAW;EAAEC;AAAa,CAAC,EACvC;EACD,MAAMC,KAAK,GAAGC,IAAI,CAACC,KAAK,CAAEP,MAAM,GAAG,GAAI,CAAC,GAAG,GAAG;EAE9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AwB,CACzBN,OAAO,EACN;EACAF,EAAE,CAAE,2BAA4B,CAAC,EACjCS,cAAc,CAAES,KAAM,CAAC,EACvBa,MACD,CAAC,EACD;IACCyB,IAAI,EACHZ,aAAA;MAAMI,SAAS,EAAC;IAAsD,CAAE;EAE1E,CACD,CACK,CAAC,EACL3B,SAAS,GACVuB,aAAA,CAAC9B,uBAAuB;IAAC2C,KAAK,EAAG5B;EAAM,CAAE,CAAC,GAE1Ce,aAAA,CAAAc,QAAA,QACCd,aAAA;IAAMI,SAAS,EAAC;EAAoD,GACjE,CAAC,CAAEL,UAAU,GACZA,UAAU,GACVlC,cAAc,CAAEuB,WAAY,CAC1B,CAAC,EACLG,aAAa,IACd,EAAIb,WAAW,IAAIC,YAAY,CAAE,IAChCqB,aAAA,CAACvC,cAAc,QACZL,EAAE,CAAE,eAAgB,CACP,CAEjB,CAEE,CACQ,CAAC;AAElB;AAEA,eAAe2B,yBAAyB"}
@@ -1,24 +1,21 @@
1
1
  import { createElement } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * WordPress dependencies
5
4
  */
6
5
  import { __ } from '@wordpress/i18n';
7
6
  import { useSelect } from '@wordpress/data';
7
+
8
8
  /**
9
9
  * Internal dependencies
10
10
  */
11
-
12
11
  import { store as blockDirectoryStore } from '../../store';
13
12
  export const DownloadableBlockNotice = ({
14
13
  block
15
14
  }) => {
16
15
  const errorNotice = useSelect(select => select(blockDirectoryStore).getErrorNoticeForBlock(block.id), [block]);
17
-
18
16
  if (!errorNotice) {
19
17
  return null;
20
18
  }
21
-
22
19
  return createElement("div", {
23
20
  className: "block-directory-downloadable-block-notice"
24
21
  }, createElement("div", {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-directory/src/components/downloadable-block-notice/index.js"],"names":["__","useSelect","store","blockDirectoryStore","DownloadableBlockNotice","block","errorNotice","select","getErrorNoticeForBlock","id","message","isFatal"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,mBAAlB,QAA6C,aAA7C;AAEA,OAAO,MAAMC,uBAAuB,GAAG,CAAE;AAAEC,EAAAA;AAAF,CAAF,KAAiB;AACvD,QAAMC,WAAW,GAAGL,SAAS,CAC1BM,MAAF,IACCA,MAAM,CAAEJ,mBAAF,CAAN,CAA8BK,sBAA9B,CAAsDH,KAAK,CAACI,EAA5D,CAF2B,EAG5B,CAAEJ,KAAF,CAH4B,CAA7B;;AAMA,MAAK,CAAEC,WAAP,EAAqB;AACpB,WAAO,IAAP;AACA;;AAED,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGA,WAAW,CAACI,OADf,EAEGJ,WAAW,CAACK,OAAZ,GACC,MAAMX,EAAE,CAAE,yBAAF,CADT,GAEC,IAJJ,CADD,CADD;AAUA,CArBM;AAuBP,eAAeI,uBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockDirectoryStore } from '../../store';\n\nexport const DownloadableBlockNotice = ( { block } ) => {\n\tconst errorNotice = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockDirectoryStore ).getErrorNoticeForBlock( block.id ),\n\t\t[ block ]\n\t);\n\n\tif ( ! errorNotice ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"block-directory-downloadable-block-notice\">\n\t\t\t<div className=\"block-directory-downloadable-block-notice__content\">\n\t\t\t\t{ errorNotice.message }\n\t\t\t\t{ errorNotice.isFatal\n\t\t\t\t\t? ' ' + __( 'Try reloading the page.' )\n\t\t\t\t\t: null }\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default DownloadableBlockNotice;\n"]}
1
+ {"version":3,"names":["__","useSelect","store","blockDirectoryStore","DownloadableBlockNotice","block","errorNotice","select","getErrorNoticeForBlock","id","createElement","className","message","isFatal"],"sources":["@wordpress/block-directory/src/components/downloadable-block-notice/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockDirectoryStore } from '../../store';\n\nexport const DownloadableBlockNotice = ( { block } ) => {\n\tconst errorNotice = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockDirectoryStore ).getErrorNoticeForBlock( block.id ),\n\t\t[ block ]\n\t);\n\n\tif ( ! errorNotice ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"block-directory-downloadable-block-notice\">\n\t\t\t<div className=\"block-directory-downloadable-block-notice__content\">\n\t\t\t\t{ errorNotice.message }\n\t\t\t\t{ errorNotice.isFatal\n\t\t\t\t\t? ' ' + __( 'Try reloading the page.' )\n\t\t\t\t\t: null }\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default DownloadableBlockNotice;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,mBAAmB,QAAQ,aAAa;AAE1D,OAAO,MAAMC,uBAAuB,GAAGA,CAAE;EAAEC;AAAM,CAAC,KAAM;EACvD,MAAMC,WAAW,GAAGL,SAAS,CAC1BM,MAAM,IACPA,MAAM,CAAEJ,mBAAoB,CAAC,CAACK,sBAAsB,CAAEH,KAAK,CAACI,EAAG,CAAC,EACjE,CAAEJ,KAAK,CACR,CAAC;EAED,IAAK,CAAEC,WAAW,EAAG;IACpB,OAAO,IAAI;EACZ;EAEA,OACCI,aAAA;IAAKC,SAAS,EAAC;EAA2C,GACzDD,aAAA;IAAKC,SAAS,EAAC;EAAoD,GAChEL,WAAW,CAACM,OAAO,EACnBN,WAAW,CAACO,OAAO,GAClB,GAAG,GAAGb,EAAE,CAAE,yBAA0B,CAAC,GACrC,IACC,CACD,CAAC;AAER,CAAC;AAED,eAAeI,uBAAuB"}