@wordpress/block-directory 3.13.0 → 3.14.1-next.957ca95e4c.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.
- package/CHANGELOG.md +2 -0
- package/build/components/block-ratings/stars.js +9 -9
- package/build/components/block-ratings/stars.js.map +1 -1
- package/build/store/resolvers.js +5 -2
- package/build/store/resolvers.js.map +1 -1
- package/build-module/components/block-ratings/stars.js +9 -8
- package/build-module/components/block-ratings/stars.js.map +1 -1
- package/build-module/store/resolvers.js +5 -2
- package/build-module/store/resolvers.js.map +1 -1
- package/package.json +21 -20
- package/src/components/block-ratings/stars.js +3 -8
- package/src/components/downloadable-blocks-list/test/index.js +3 -3
- package/src/store/resolvers.js +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,16 +7,10 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _element = require("@wordpress/element");
|
|
9
9
|
|
|
10
|
-
var _lodash = require("lodash");
|
|
11
|
-
|
|
12
10
|
var _i18n = require("@wordpress/i18n");
|
|
13
11
|
|
|
14
12
|
var _icons = require("@wordpress/icons");
|
|
15
13
|
|
|
16
|
-
/**
|
|
17
|
-
* External dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
14
|
/**
|
|
21
15
|
* WordPress dependencies
|
|
22
16
|
*/
|
|
@@ -32,17 +26,23 @@ function Stars(_ref) {
|
|
|
32
26
|
"aria-label": (0, _i18n.sprintf)(
|
|
33
27
|
/* translators: %s: number of stars. */
|
|
34
28
|
(0, _i18n.__)('%s out of 5 stars'), stars)
|
|
35
|
-
},
|
|
29
|
+
}, Array.from({
|
|
30
|
+
length: fullStarCount
|
|
31
|
+
}).map((_, i) => (0, _element.createElement)(_icons.Icon, {
|
|
36
32
|
key: `full_stars_${i}`,
|
|
37
33
|
className: "block-directory-block-ratings__star-full",
|
|
38
34
|
icon: _icons.starFilled,
|
|
39
35
|
size: 16
|
|
40
|
-
})),
|
|
36
|
+
})), Array.from({
|
|
37
|
+
length: halfStarCount
|
|
38
|
+
}).map((_, i) => (0, _element.createElement)(_icons.Icon, {
|
|
41
39
|
key: `half_stars_${i}`,
|
|
42
40
|
className: "block-directory-block-ratings__star-half-full",
|
|
43
41
|
icon: _icons.starHalf,
|
|
44
42
|
size: 16
|
|
45
|
-
})),
|
|
43
|
+
})), Array.from({
|
|
44
|
+
length: emptyStarCount
|
|
45
|
+
}).map((_, i) => (0, _element.createElement)(_icons.Icon, {
|
|
46
46
|
key: `empty_stars_${i}`,
|
|
47
47
|
className: "block-directory-block-ratings__star-empty",
|
|
48
48
|
icon: _icons.starEmpty,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-directory/src/components/block-ratings/stars.js"],"names":["Stars","rating","stars","Math","round","fullStarCount","floor","halfStarCount","ceil","emptyStarCount","i","starFilled","starHalf","starEmpty"],"mappings":";;;;;;;;;AAGA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-directory/src/components/block-ratings/stars.js"],"names":["Stars","rating","stars","Math","round","fullStarCount","floor","halfStarCount","ceil","emptyStarCount","Array","from","length","map","_","i","starFilled","starHalf","starEmpty"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,SAASA,KAAT,OAA6B;AAAA,MAAb;AAAEC,IAAAA;AAAF,GAAa;AAC5B,QAAMC,KAAK,GAAGC,IAAI,CAACC,KAAL,CAAYH,MAAM,GAAG,GAArB,IAA6B,GAA3C;AAEA,QAAMI,aAAa,GAAGF,IAAI,CAACG,KAAL,CAAYL,MAAZ,CAAtB;AACA,QAAMM,aAAa,GAAGJ,IAAI,CAACK,IAAL,CAAWP,MAAM,GAAGI,aAApB,CAAtB;AACA,QAAMI,cAAc,GAAG,KAAMJ,aAAa,GAAGE,aAAtB,CAAvB;AAEA,SACC;AACC,kBAAa;AACZ;AACA,kBAAI,mBAAJ,CAFY,EAGZL,KAHY;AADd,KAOGQ,KAAK,CAACC,IAAN,CAAY;AAAEC,IAAAA,MAAM,EAAEP;AAAV,GAAZ,EAAwCQ,GAAxC,CAA6C,CAAEC,CAAF,EAAKC,CAAL,KAC9C,4BAAC,WAAD;AACC,IAAA,GAAG,EAAI,cAAcA,CAAG,EADzB;AAEC,IAAA,SAAS,EAAC,0CAFX;AAGC,IAAA,IAAI,EAAGC,iBAHR;AAIC,IAAA,IAAI,EAAG;AAJR,IADC,CAPH,EAeGN,KAAK,CAACC,IAAN,CAAY;AAAEC,IAAAA,MAAM,EAAEL;AAAV,GAAZ,EAAwCM,GAAxC,CAA6C,CAAEC,CAAF,EAAKC,CAAL,KAC9C,4BAAC,WAAD;AACC,IAAA,GAAG,EAAI,cAAcA,CAAG,EADzB;AAEC,IAAA,SAAS,EAAC,+CAFX;AAGC,IAAA,IAAI,EAAGE,eAHR;AAIC,IAAA,IAAI,EAAG;AAJR,IADC,CAfH,EAuBGP,KAAK,CAACC,IAAN,CAAY;AAAEC,IAAAA,MAAM,EAAEH;AAAV,GAAZ,EAAyCI,GAAzC,CAA8C,CAAEC,CAAF,EAAKC,CAAL,KAC/C,4BAAC,WAAD;AACC,IAAA,GAAG,EAAI,eAAeA,CAAG,EAD1B;AAEC,IAAA,SAAS,EAAC,2CAFX;AAGC,IAAA,IAAI,EAAGG,gBAHR;AAIC,IAAA,IAAI,EAAG;AAJR,IADC,CAvBH,CADD;AAkCA;;eAEclB,K","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"]}
|
package/build/store/resolvers.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.getDownloadableBlocks = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _changeCase = require("change-case");
|
|
11
11
|
|
|
12
12
|
var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
|
|
13
13
|
|
|
@@ -38,7 +38,10 @@ const getDownloadableBlocks = filterValue => async _ref => {
|
|
|
38
38
|
const results = await (0, _apiFetch.default)({
|
|
39
39
|
path: `wp/v2/block-directory/search?term=${filterValue}`
|
|
40
40
|
});
|
|
41
|
-
const blocks = results.map(result => (
|
|
41
|
+
const blocks = results.map(result => Object.fromEntries(Object.entries(result).map(_ref2 => {
|
|
42
|
+
let [key, value] = _ref2;
|
|
43
|
+
return [(0, _changeCase.camelCase)(key), value];
|
|
44
|
+
})));
|
|
42
45
|
dispatch((0, _actions.receiveDownloadableBlocks)(blocks, filterValue));
|
|
43
46
|
} catch {}
|
|
44
47
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-directory/src/store/resolvers.js"],"names":["getDownloadableBlocks","filterValue","dispatch","results","path","blocks","map","result","
|
|
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,cAA0B;AAAA,MAAlB;AAAEC,IAAAA;AAAF,GAAkB;;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;AAAA,UAAE,CAAEK,GAAF,EAAOC,KAAP,CAAF;AAAA,aAAsB,CACnD,2BAAWD,GAAX,CADmD,EAEnDC,KAFmD,CAAtB;AAAA,KAA9B,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,13 +1,8 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { times } from 'lodash';
|
|
7
3
|
/**
|
|
8
4
|
* WordPress dependencies
|
|
9
5
|
*/
|
|
10
|
-
|
|
11
6
|
import { __, sprintf } from '@wordpress/i18n';
|
|
12
7
|
import { Icon, starEmpty, starFilled, starHalf } from '@wordpress/icons';
|
|
13
8
|
|
|
@@ -23,17 +18,23 @@ function Stars(_ref) {
|
|
|
23
18
|
"aria-label": sprintf(
|
|
24
19
|
/* translators: %s: number of stars. */
|
|
25
20
|
__('%s out of 5 stars'), stars)
|
|
26
|
-
},
|
|
21
|
+
}, Array.from({
|
|
22
|
+
length: fullStarCount
|
|
23
|
+
}).map((_, i) => createElement(Icon, {
|
|
27
24
|
key: `full_stars_${i}`,
|
|
28
25
|
className: "block-directory-block-ratings__star-full",
|
|
29
26
|
icon: starFilled,
|
|
30
27
|
size: 16
|
|
31
|
-
})),
|
|
28
|
+
})), Array.from({
|
|
29
|
+
length: halfStarCount
|
|
30
|
+
}).map((_, i) => createElement(Icon, {
|
|
32
31
|
key: `half_stars_${i}`,
|
|
33
32
|
className: "block-directory-block-ratings__star-half-full",
|
|
34
33
|
icon: starHalf,
|
|
35
34
|
size: 16
|
|
36
|
-
})),
|
|
35
|
+
})), Array.from({
|
|
36
|
+
length: emptyStarCount
|
|
37
|
+
}).map((_, i) => createElement(Icon, {
|
|
37
38
|
key: `empty_stars_${i}`,
|
|
38
39
|
className: "block-directory-block-ratings__star-empty",
|
|
39
40
|
icon: starEmpty,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-directory/src/components/block-ratings/stars.js"],"names":["
|
|
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","Array","from","length","map","_","i"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,IAAT,EAAeC,SAAf,EAA0BC,UAA1B,EAAsCC,QAAtC,QAAsD,kBAAtD;;AAEA,SAASC,KAAT,OAA6B;AAAA,MAAb;AAAEC,IAAAA;AAAF,GAAa;AAC5B,QAAMC,KAAK,GAAGC,IAAI,CAACC,KAAL,CAAYH,MAAM,GAAG,GAArB,IAA6B,GAA3C;AAEA,QAAMI,aAAa,GAAGF,IAAI,CAACG,KAAL,CAAYL,MAAZ,CAAtB;AACA,QAAMM,aAAa,GAAGJ,IAAI,CAACK,IAAL,CAAWP,MAAM,GAAGI,aAApB,CAAtB;AACA,QAAMI,cAAc,GAAG,KAAMJ,aAAa,GAAGE,aAAtB,CAAvB;AAEA,SACC;AACC,kBAAaZ,OAAO;AACnB;AACAD,IAAAA,EAAE,CAAE,mBAAF,CAFiB,EAGnBQ,KAHmB;AADrB,KAOGQ,KAAK,CAACC,IAAN,CAAY;AAAEC,IAAAA,MAAM,EAAEP;AAAV,GAAZ,EAAwCQ,GAAxC,CAA6C,CAAEC,CAAF,EAAKC,CAAL,KAC9C,cAAC,IAAD;AACC,IAAA,GAAG,EAAI,cAAcA,CAAG,EADzB;AAEC,IAAA,SAAS,EAAC,0CAFX;AAGC,IAAA,IAAI,EAAGjB,UAHR;AAIC,IAAA,IAAI,EAAG;AAJR,IADC,CAPH,EAeGY,KAAK,CAACC,IAAN,CAAY;AAAEC,IAAAA,MAAM,EAAEL;AAAV,GAAZ,EAAwCM,GAAxC,CAA6C,CAAEC,CAAF,EAAKC,CAAL,KAC9C,cAAC,IAAD;AACC,IAAA,GAAG,EAAI,cAAcA,CAAG,EADzB;AAEC,IAAA,SAAS,EAAC,+CAFX;AAGC,IAAA,IAAI,EAAGhB,QAHR;AAIC,IAAA,IAAI,EAAG;AAJR,IADC,CAfH,EAuBGW,KAAK,CAACC,IAAN,CAAY;AAAEC,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,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { camelCase
|
|
4
|
+
import { camelCase } from 'change-case';
|
|
5
5
|
/**
|
|
6
6
|
* WordPress dependencies
|
|
7
7
|
*/
|
|
@@ -26,7 +26,10 @@ export const getDownloadableBlocks = filterValue => async _ref => {
|
|
|
26
26
|
const results = await apiFetch({
|
|
27
27
|
path: `wp/v2/block-directory/search?term=${filterValue}`
|
|
28
28
|
});
|
|
29
|
-
const blocks = results.map(result =>
|
|
29
|
+
const blocks = results.map(result => Object.fromEntries(Object.entries(result).map(_ref2 => {
|
|
30
|
+
let [key, value] = _ref2;
|
|
31
|
+
return [camelCase(key), value];
|
|
32
|
+
})));
|
|
30
33
|
dispatch(receiveDownloadableBlocks(blocks, filterValue));
|
|
31
34
|
} catch {}
|
|
32
35
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-directory/src/store/resolvers.js"],"names":["camelCase","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-directory/src/store/resolvers.js"],"names":["camelCase","apiFetch","fetchDownloadableBlocks","receiveDownloadableBlocks","getDownloadableBlocks","filterValue","dispatch","results","path","blocks","map","result","Object","fromEntries","entries","key","value"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,aAA1B;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAEA;AACA;AACA;;AACA,SAASC,uBAAT,EAAkCC,yBAAlC,QAAmE,WAAnE;AAEA,OAAO,MAAMC,qBAAqB,GAC/BC,WAAF,IACA,cAA0B;AAAA,MAAlB;AAAEC,IAAAA;AAAF,GAAkB;;AACzB,MAAK,CAAED,WAAP,EAAqB;AACpB;AACA;;AAED,MAAI;AACHC,IAAAA,QAAQ,CAAEJ,uBAAuB,CAAEG,WAAF,CAAzB,CAAR;AACA,UAAME,OAAO,GAAG,MAAMN,QAAQ,CAAE;AAC/BO,MAAAA,IAAI,EAAG,qCAAqCH,WAAa;AAD1B,KAAF,CAA9B;AAGA,UAAMI,MAAM,GAAGF,OAAO,CAACG,GAAR,CAAeC,MAAF,IAC3BC,MAAM,CAACC,WAAP,CACCD,MAAM,CAACE,OAAP,CAAgBH,MAAhB,EAAyBD,GAAzB,CAA8B;AAAA,UAAE,CAAEK,GAAF,EAAOC,KAAP,CAAF;AAAA,aAAsB,CACnDhB,SAAS,CAAEe,GAAF,CAD0C,EAEnDC,KAFmD,CAAtB;AAAA,KAA9B,CADD,CADc,CAAf;AASAV,IAAAA,QAAQ,CAAEH,yBAAyB,CAAEM,MAAF,EAAUJ,WAAV,CAA3B,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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-directory",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.1-next.957ca95e4c.0",
|
|
4
4
|
"description": "Extend editor with block directory features to search, download and install blocks.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -26,24 +26,25 @@
|
|
|
26
26
|
"react-native": "src/index",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@babel/runtime": "^7.16.0",
|
|
29
|
-
"@wordpress/a11y": "^3.
|
|
30
|
-
"@wordpress/api-fetch": "^6.
|
|
31
|
-
"@wordpress/block-editor": "^9.
|
|
32
|
-
"@wordpress/blocks": "^11.
|
|
33
|
-
"@wordpress/components": "^
|
|
34
|
-
"@wordpress/compose": "^5.
|
|
35
|
-
"@wordpress/core-data": "^
|
|
36
|
-
"@wordpress/data": "^
|
|
37
|
-
"@wordpress/edit-post": "^6.
|
|
38
|
-
"@wordpress/editor": "^12.
|
|
39
|
-
"@wordpress/element": "^4.
|
|
40
|
-
"@wordpress/hooks": "^3.
|
|
41
|
-
"@wordpress/html-entities": "^3.
|
|
42
|
-
"@wordpress/i18n": "^4.
|
|
43
|
-
"@wordpress/icons": "^9.
|
|
44
|
-
"@wordpress/notices": "^3.
|
|
45
|
-
"@wordpress/plugins": "^4.
|
|
46
|
-
"@wordpress/url": "^3.
|
|
29
|
+
"@wordpress/a11y": "^3.16.1-next.957ca95e4c.0",
|
|
30
|
+
"@wordpress/api-fetch": "^6.13.1-next.957ca95e4c.0",
|
|
31
|
+
"@wordpress/block-editor": "^9.8.1-next.957ca95e4c.0",
|
|
32
|
+
"@wordpress/blocks": "^11.15.1-next.957ca95e4c.0",
|
|
33
|
+
"@wordpress/components": "^20.0.2-next.957ca95e4c.0",
|
|
34
|
+
"@wordpress/compose": "^5.14.1-next.957ca95e4c.0",
|
|
35
|
+
"@wordpress/core-data": "^5.0.1-next.957ca95e4c.0",
|
|
36
|
+
"@wordpress/data": "^7.0.1-next.957ca95e4c.0",
|
|
37
|
+
"@wordpress/edit-post": "^6.13.1-next.957ca95e4c.0",
|
|
38
|
+
"@wordpress/editor": "^12.15.1-next.957ca95e4c.0",
|
|
39
|
+
"@wordpress/element": "^4.14.1-next.957ca95e4c.0",
|
|
40
|
+
"@wordpress/hooks": "^3.16.1-next.957ca95e4c.0",
|
|
41
|
+
"@wordpress/html-entities": "^3.16.1-next.957ca95e4c.0",
|
|
42
|
+
"@wordpress/i18n": "^4.16.1-next.957ca95e4c.0",
|
|
43
|
+
"@wordpress/icons": "^9.7.1-next.957ca95e4c.0",
|
|
44
|
+
"@wordpress/notices": "^3.16.1-next.957ca95e4c.0",
|
|
45
|
+
"@wordpress/plugins": "^4.14.1-next.957ca95e4c.0",
|
|
46
|
+
"@wordpress/url": "^3.17.1-next.957ca95e4c.0",
|
|
47
|
+
"change-case": "^4.1.2",
|
|
47
48
|
"lodash": "^4.17.21"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
@@ -53,5 +54,5 @@
|
|
|
53
54
|
"publishConfig": {
|
|
54
55
|
"access": "public"
|
|
55
56
|
},
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "272a74bbbaab10ee24424eafe9578e705fbfbbb4"
|
|
57
58
|
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { times } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -24,7 +19,7 @@ function Stars( { rating } ) {
|
|
|
24
19
|
stars
|
|
25
20
|
) }
|
|
26
21
|
>
|
|
27
|
-
{
|
|
22
|
+
{ Array.from( { length: fullStarCount } ).map( ( _, i ) => (
|
|
28
23
|
<Icon
|
|
29
24
|
key={ `full_stars_${ i }` }
|
|
30
25
|
className="block-directory-block-ratings__star-full"
|
|
@@ -32,7 +27,7 @@ function Stars( { rating } ) {
|
|
|
32
27
|
size={ 16 }
|
|
33
28
|
/>
|
|
34
29
|
) ) }
|
|
35
|
-
{
|
|
30
|
+
{ Array.from( { length: halfStarCount } ).map( ( _, i ) => (
|
|
36
31
|
<Icon
|
|
37
32
|
key={ `half_stars_${ i }` }
|
|
38
33
|
className="block-directory-block-ratings__star-half-full"
|
|
@@ -40,7 +35,7 @@ function Stars( { rating } ) {
|
|
|
40
35
|
size={ 16 }
|
|
41
36
|
/>
|
|
42
37
|
) ) }
|
|
43
|
-
{
|
|
38
|
+
{ Array.from( { length: emptyStarCount } ).map( ( _, i ) => (
|
|
44
39
|
<Icon
|
|
45
40
|
key={ `empty_stars_${ i }` }
|
|
46
41
|
className="block-directory-block-ratings__star-empty"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render } from '@testing-library/react';
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -44,14 +44,14 @@ describe( 'DownloadableBlocksList', () => {
|
|
|
44
44
|
} );
|
|
45
45
|
|
|
46
46
|
it( 'should render plugins items into the list', () => {
|
|
47
|
-
|
|
47
|
+
render(
|
|
48
48
|
<DownloadableBlocksList
|
|
49
49
|
items={ items }
|
|
50
50
|
onSelect={ jest.fn() }
|
|
51
51
|
onHover={ jest.fn() }
|
|
52
52
|
/>
|
|
53
53
|
);
|
|
54
|
-
const downloadableBlocks = getAllByRole( 'option' );
|
|
54
|
+
const downloadableBlocks = screen.getAllByRole( 'option' );
|
|
55
55
|
|
|
56
56
|
expect( downloadableBlocks ).toHaveLength( items.length );
|
|
57
57
|
} );
|
package/src/store/resolvers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { camelCase
|
|
4
|
+
import { camelCase } from 'change-case';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
@@ -26,7 +26,12 @@ export const getDownloadableBlocks =
|
|
|
26
26
|
path: `wp/v2/block-directory/search?term=${ filterValue }`,
|
|
27
27
|
} );
|
|
28
28
|
const blocks = results.map( ( result ) =>
|
|
29
|
-
|
|
29
|
+
Object.fromEntries(
|
|
30
|
+
Object.entries( result ).map( ( [ key, value ] ) => [
|
|
31
|
+
camelCase( key ),
|
|
32
|
+
value,
|
|
33
|
+
] )
|
|
34
|
+
)
|
|
30
35
|
);
|
|
31
36
|
|
|
32
37
|
dispatch( receiveDownloadableBlocks( blocks, filterValue ) );
|