@wordpress/block-directory 5.8.6 → 5.8.7
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/build/components/downloadable-block-list-item/index.js +49 -47
- package/build/components/downloadable-block-list-item/index.js.map +1 -1
- package/build/plugins/get-install-missing/index.js +2 -4
- package/build/plugins/get-install-missing/index.js.map +1 -1
- package/build/plugins/get-install-missing/install-button.js +2 -4
- package/build/plugins/get-install-missing/install-button.js.map +1 -1
- package/build-module/components/downloadable-block-list-item/index.js +50 -48
- package/build-module/components/downloadable-block-list-item/index.js.map +1 -1
- package/build-module/plugins/get-install-missing/index.js +2 -4
- package/build-module/plugins/get-install-missing/index.js.map +1 -1
- package/build-module/plugins/get-install-missing/install-button.js +2 -4
- package/build-module/plugins/get-install-missing/install-button.js.map +1 -1
- package/build-style/style-rtl.css +18 -13
- package/build-style/style.css +18 -13
- package/package.json +9 -8
- package/src/components/downloadable-block-list-item/index.js +70 -67
- package/src/components/downloadable-block-list-item/style.scss +23 -10
- package/src/components/downloadable-blocks-panel/style.scss +0 -3
- package/src/plugins/get-install-missing/index.js +1 -2
- package/src/plugins/get-install-missing/install-button.js +1 -2
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
8
9
|
var _i18n = require("@wordpress/i18n");
|
|
9
10
|
var _components = require("@wordpress/components");
|
|
10
11
|
var _element = require("@wordpress/element");
|
|
@@ -16,6 +17,10 @@ var _downloadableBlockIcon = _interopRequireDefault(require("../downloadable-blo
|
|
|
16
17
|
var _downloadableBlockNotice = _interopRequireDefault(require("../downloadable-block-notice"));
|
|
17
18
|
var _store = require("../../store");
|
|
18
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
|
+
/**
|
|
21
|
+
* External dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
19
24
|
/**
|
|
20
25
|
* WordPress dependencies
|
|
21
26
|
*/
|
|
@@ -92,61 +97,58 @@ function DownloadableBlockListItem({
|
|
|
92
97
|
} else if (isInstalling) {
|
|
93
98
|
statusText = (0, _i18n.__)('Installing…');
|
|
94
99
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
const itemLabel = getDownloadableBlockLabel(item, {
|
|
101
|
+
hasNotice,
|
|
102
|
+
isInstalled,
|
|
103
|
+
isInstalling
|
|
104
|
+
});
|
|
105
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Tooltip, {
|
|
106
|
+
placement: "top",
|
|
107
|
+
text: itemLabel,
|
|
108
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Composite.Item, {
|
|
109
|
+
className: (0, _clsx.default)('block-directory-downloadable-block-list-item', isInstalling && 'is-installing'),
|
|
100
110
|
accessibleWhenDisabled: true,
|
|
101
|
-
|
|
102
|
-
role: "option",
|
|
103
|
-
className: "block-directory-downloadable-block-list-item",
|
|
104
|
-
isBusy: isInstalling,
|
|
111
|
+
disabled: isInstalling || !isInstallable,
|
|
105
112
|
onClick: event => {
|
|
106
113
|
event.preventDefault();
|
|
107
114
|
onClick();
|
|
108
115
|
},
|
|
109
|
-
label:
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}),
|
|
124
|
-
className: "block-directory-downloadable-block-list-
|
|
125
|
-
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {})
|
|
126
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockRatings.default, {
|
|
127
|
-
rating: rating
|
|
128
|
-
})]
|
|
129
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
130
|
-
className: "block-directory-downloadable-block-list-item__details",
|
|
131
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
132
|
-
className: "block-directory-downloadable-block-list-item__title",
|
|
133
|
-
children: (0, _element.createInterpolateElement)((0, _i18n.sprintf)( /* translators: %1$s: block title, %2$s: author name. */
|
|
134
|
-
(0, _i18n.__)('%1$s <span>by %2$s</span>'), (0, _htmlEntities.decodeEntities)(title), author), {
|
|
135
|
-
span: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
136
|
-
className: "block-directory-downloadable-block-list-item__author"
|
|
137
|
-
})
|
|
138
|
-
})
|
|
139
|
-
}), hasNotice ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_downloadableBlockNotice.default, {
|
|
140
|
-
block: item
|
|
141
|
-
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
116
|
+
"aria-label": itemLabel,
|
|
117
|
+
type: "button",
|
|
118
|
+
role: "option",
|
|
119
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
120
|
+
className: "block-directory-downloadable-block-list-item__icon",
|
|
121
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_downloadableBlockIcon.default, {
|
|
122
|
+
icon: icon,
|
|
123
|
+
title: title
|
|
124
|
+
}), isInstalling ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
125
|
+
className: "block-directory-downloadable-block-list-item__spinner",
|
|
126
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Spinner, {})
|
|
127
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockRatings.default, {
|
|
128
|
+
rating: rating
|
|
129
|
+
})]
|
|
130
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
131
|
+
className: "block-directory-downloadable-block-list-item__details",
|
|
142
132
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
143
|
-
className: "block-directory-downloadable-block-list-
|
|
144
|
-
children:
|
|
145
|
-
|
|
146
|
-
|
|
133
|
+
className: "block-directory-downloadable-block-list-item__title",
|
|
134
|
+
children: (0, _element.createInterpolateElement)((0, _i18n.sprintf)( /* translators: %1$s: block title, %2$s: author name. */
|
|
135
|
+
(0, _i18n.__)('%1$s <span>by %2$s</span>'), (0, _htmlEntities.decodeEntities)(title), author), {
|
|
136
|
+
span: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
137
|
+
className: "block-directory-downloadable-block-list-item__author"
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
}), hasNotice ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_downloadableBlockNotice.default, {
|
|
141
|
+
block: item
|
|
142
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
143
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
144
|
+
className: "block-directory-downloadable-block-list-item__desc",
|
|
145
|
+
children: !!statusText ? statusText : (0, _htmlEntities.decodeEntities)(description)
|
|
146
|
+
}), isInstallable && !(isInstalled || isInstalling) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.VisuallyHidden, {
|
|
147
|
+
children: (0, _i18n.__)('Install block')
|
|
148
|
+
})]
|
|
147
149
|
})]
|
|
148
150
|
})]
|
|
149
|
-
})
|
|
151
|
+
})
|
|
150
152
|
});
|
|
151
153
|
}
|
|
152
154
|
var _default = exports.default = DownloadableBlockListItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_element","_htmlEntities","_blocks","_data","_blockRatings","_interopRequireDefault","_downloadableBlockIcon","_downloadableBlockNotice","_store","_jsxRuntime","getDownloadableBlockLabel","title","rating","ratingCount","hasNotice","isInstalled","isInstalling","stars","Math","round","sprintf","decodeEntities","_n","DownloadableBlockListItem","item","onClick","author","description","icon","getBlockType","name","isInstallable","useSelect","select","getErrorNoticeForBlock","isBlockInstalling","blockDirectoryStore","notice","id","hasFatal","isFatal","statusText","__","jsxs","Composite","Item","render","jsx","Button","__next40pxDefaultSize","accessibleWhenDisabled","type","role","className","isBusy","event","preventDefault","label","showTooltip","tooltipPosition","disabled","children","default","Spinner","createInterpolateElement","span","block","Fragment","VisuallyHidden","_default","exports"],"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\tComposite,\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( { 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<Composite.Item\n\t\t\trender={\n\t\t\t\t<Button\n\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\tclassName=\"block-directory-downloadable-block-list-item\"\n\t\t\t\t\tisBusy={ isInstalling }\n\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tonClick();\n\t\t\t\t\t} }\n\t\t\t\t\tlabel={ getDownloadableBlockLabel( item, {\n\t\t\t\t\t\thasNotice,\n\t\t\t\t\t\tisInstalled,\n\t\t\t\t\t\tisInstalling,\n\t\t\t\t\t} ) }\n\t\t\t\t\tshowTooltip\n\t\t\t\t\ttooltipPosition=\"top center\"\n\t\t\t\t/>\n\t\t\t}\n\t\t\tdisabled={ isInstalling || ! isInstallable }\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\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AAS,EAAC,uDAAuD;MAAAQ,QAAA,gBACtE,IAAApD,WAAA,CAAAsC,GAAA;QAAMM,SAAS,EAAC,qDAAqD;QAAAQ,QAAA,EAClE,IAAAG,iCAAwB,EACzB,IAAA5C,aAAO,GACN;QACA,IAAAsB,QAAE,EAAE,2BAA4B,CAAC,EACjC,IAAArB,4BAAc,EAAEV,KAAM,CAAC,EACvBe,MACD,CAAC,EACD;UACCuC,IAAI,eACH,IAAAxD,WAAA,CAAAsC,GAAA;YAAMM,SAAS,EAAC;UAAsD,CAAE;QAE1E,CACD;MAAC,CACI,CAAC,EACLvC,SAAS,gBACV,IAAAL,WAAA,CAAAsC,GAAA,EAACxC,wBAAA,CAAAuD,OAAuB;QAACI,KAAK,EAAG1C;MAAM,CAAE,CAAC,gBAE1C,IAAAf,WAAA,CAAAkC,IAAA,EAAAlC,WAAA,CAAA0D,QAAA;QAAAN,QAAA,gBACC,IAAApD,WAAA,CAAAsC,GAAA;UAAMM,SAAS,EAAC,oDAAoD;UAAAQ,QAAA,EACjE,CAAC,CAAEpB,UAAU,GACZA,UAAU,GACV,IAAApB,4BAAc,EAAEM,WAAY;QAAC,CAC3B,CAAC,EACLI,aAAa,IACd,EAAIhB,WAAW,IAAIC,YAAY,CAAE,iBAChC,IAAAP,WAAA,CAAAsC,GAAA,EAAChD,WAAA,CAAAqE,cAAc;UAAAP,QAAA,EACZ,IAAAnB,QAAE,EAAE,eAAgB;QAAC,CACR,CAChB;MAAA,CACD,CACF;IAAA,CACI,CAAC;EAAA,CACQ,CAAC;AAEnB;AAAC,IAAA2B,QAAA,GAAAC,OAAA,CAAAR,OAAA,GAEcvC,yBAAyB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_components","_element","_htmlEntities","_blocks","_data","_blockRatings","_downloadableBlockIcon","_downloadableBlockNotice","_store","_jsxRuntime","getDownloadableBlockLabel","title","rating","ratingCount","hasNotice","isInstalled","isInstalling","stars","Math","round","sprintf","decodeEntities","_n","DownloadableBlockListItem","item","onClick","author","description","icon","getBlockType","name","isInstallable","useSelect","select","getErrorNoticeForBlock","isBlockInstalling","blockDirectoryStore","notice","id","hasFatal","isFatal","statusText","__","itemLabel","jsx","Tooltip","placement","text","children","jsxs","Composite","Item","className","clsx","accessibleWhenDisabled","disabled","event","preventDefault","type","role","default","Spinner","createInterpolateElement","span","block","Fragment","VisuallyHidden","_default","exports"],"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tTooltip,\n\tSpinner,\n\tVisuallyHidden,\n\tComposite,\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( { 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\tconst itemLabel = getDownloadableBlockLabel( item, {\n\t\thasNotice,\n\t\tisInstalled,\n\t\tisInstalling,\n\t} );\n\n\treturn (\n\t\t<Tooltip placement=\"top\" text={ itemLabel }>\n\t\t\t<Composite.Item\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-directory-downloadable-block-list-item',\n\t\t\t\t\tisInstalling && 'is-installing'\n\t\t\t\t) }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tonClick();\n\t\t\t\t} }\n\t\t\t\taria-label={ itemLabel }\n\t\t\t\ttype=\"button\"\n\t\t\t\trole=\"option\"\n\t\t\t>\n\t\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %1$s: block title, %2$s: author name. */\n\t\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: (\n\t\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\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\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arning = ({
|
|
|
91
91
|
if (hasContent && hasHTMLBlock) {
|
|
92
92
|
messageHTML = (0, _i18n.sprintf)( /* translators: %s: block name */
|
|
93
93
|
(0, _i18n.__)('Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'), originalBlock.title || originalName);
|
|
94
|
-
actions.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
95
|
-
|
|
96
|
-
, {
|
|
97
|
-
__next40pxDefaultSize: false,
|
|
94
|
+
actions.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
95
|
+
__next40pxDefaultSize: true,
|
|
98
96
|
onClick: convertToHTML,
|
|
99
97
|
variant: "tertiary",
|
|
100
98
|
children: (0, _i18n.__)('Keep as HTML')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_blocks","_element","_data","_coreData","_blockEditor","_installButton","_interopRequireDefault","_store","_jsxRuntime","getInstallMissing","OriginalComponent","props","originalName","attributes","block","hasPermission","useSelect","select","getDownloadableBlocks","blockDirectoryStore","blocks","filter","name","coreStore","canUser","length","jsx","ModifiedWarning","originalBlock","originalUndelimitedContent","clientId","replaceBlock","useDispatch","blockEditorStore","convertToHTML","createBlock","content","hasContent","hasHTMLBlock","canInsertBlockType","getBlockRootClientId","messageHTML","sprintf","__","title","actions","default","push","Button","__next40pxDefaultSize","onClick","variant","children","jsxs","useBlockProps","Warning","RawHTML","_default","exports"],"sources":["@wordpress/block-directory/src/plugins/get-install-missing/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createBlock } from '@wordpress/blocks';\nimport { RawHTML } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tWarning,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport InstallButton from './install-button';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst getInstallMissing = ( OriginalComponent ) => ( props ) => {\n\tconst { originalName } = props.attributes;\n\t// Disable reason: This is a valid component, but it's mistaken for a callback.\n\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\tconst { block, hasPermission } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getDownloadableBlocks } = select( blockDirectoryStore );\n\t\t\tconst blocks = getDownloadableBlocks(\n\t\t\t\t'block:' + originalName\n\t\t\t).filter( ( { name } ) => originalName === name );\n\t\t\treturn {\n\t\t\t\thasPermission: select( coreStore ).canUser(\n\t\t\t\t\t'read',\n\t\t\t\t\t'block-directory/search'\n\t\t\t\t),\n\t\t\t\tblock: blocks.length && blocks[ 0 ],\n\t\t\t};\n\t\t},\n\t\t[ originalName ]\n\t);\n\n\t// The user can't install blocks, or the block isn't available for download.\n\tif ( ! hasPermission || ! block ) {\n\t\treturn <OriginalComponent { ...props } />;\n\t}\n\n\treturn <ModifiedWarning { ...props } originalBlock={ block } />;\n};\n\nconst ModifiedWarning = ( { originalBlock, ...props } ) => {\n\tconst { originalName, originalUndelimitedContent, clientId } =\n\t\tprops.attributes;\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\tconst convertToHTML = () => {\n\t\treplaceBlock(\n\t\t\tprops.clientId,\n\t\t\tcreateBlock( 'core/html', {\n\t\t\t\tcontent: originalUndelimitedContent,\n\t\t\t} )\n\t\t);\n\t};\n\n\tconst hasContent = !! originalUndelimitedContent;\n\tconst hasHTMLBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn canInsertBlockType(\n\t\t\t\t'core/html',\n\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tlet messageHTML = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__(\n\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.'\n\t\t),\n\t\toriginalBlock.title || originalName\n\t);\n\tconst actions = [\n\t\t<InstallButton\n\t\t\tkey=\"install\"\n\t\t\tblock={ originalBlock }\n\t\t\tattributes={ props.attributes }\n\t\t\tclientId={ props.clientId }\n\t\t/>,\n\t];\n\n\tif ( hasContent && hasHTMLBlock ) {\n\t\tmessageHTML = sprintf(\n\t\t\t/* translators: %s: block name */\n\t\t\t__(\n\t\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'\n\t\t\t),\n\t\t\toriginalBlock.title || originalName\n\t\t);\n\t\tactions.push(\n\t\t\t<Button\n\t\t\t\
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_blocks","_element","_data","_coreData","_blockEditor","_installButton","_interopRequireDefault","_store","_jsxRuntime","getInstallMissing","OriginalComponent","props","originalName","attributes","block","hasPermission","useSelect","select","getDownloadableBlocks","blockDirectoryStore","blocks","filter","name","coreStore","canUser","length","jsx","ModifiedWarning","originalBlock","originalUndelimitedContent","clientId","replaceBlock","useDispatch","blockEditorStore","convertToHTML","createBlock","content","hasContent","hasHTMLBlock","canInsertBlockType","getBlockRootClientId","messageHTML","sprintf","__","title","actions","default","push","Button","__next40pxDefaultSize","onClick","variant","children","jsxs","useBlockProps","Warning","RawHTML","_default","exports"],"sources":["@wordpress/block-directory/src/plugins/get-install-missing/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createBlock } from '@wordpress/blocks';\nimport { RawHTML } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tWarning,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport InstallButton from './install-button';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst getInstallMissing = ( OriginalComponent ) => ( props ) => {\n\tconst { originalName } = props.attributes;\n\t// Disable reason: This is a valid component, but it's mistaken for a callback.\n\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\tconst { block, hasPermission } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getDownloadableBlocks } = select( blockDirectoryStore );\n\t\t\tconst blocks = getDownloadableBlocks(\n\t\t\t\t'block:' + originalName\n\t\t\t).filter( ( { name } ) => originalName === name );\n\t\t\treturn {\n\t\t\t\thasPermission: select( coreStore ).canUser(\n\t\t\t\t\t'read',\n\t\t\t\t\t'block-directory/search'\n\t\t\t\t),\n\t\t\t\tblock: blocks.length && blocks[ 0 ],\n\t\t\t};\n\t\t},\n\t\t[ originalName ]\n\t);\n\n\t// The user can't install blocks, or the block isn't available for download.\n\tif ( ! hasPermission || ! block ) {\n\t\treturn <OriginalComponent { ...props } />;\n\t}\n\n\treturn <ModifiedWarning { ...props } originalBlock={ block } />;\n};\n\nconst ModifiedWarning = ( { originalBlock, ...props } ) => {\n\tconst { originalName, originalUndelimitedContent, clientId } =\n\t\tprops.attributes;\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\tconst convertToHTML = () => {\n\t\treplaceBlock(\n\t\t\tprops.clientId,\n\t\t\tcreateBlock( 'core/html', {\n\t\t\t\tcontent: originalUndelimitedContent,\n\t\t\t} )\n\t\t);\n\t};\n\n\tconst hasContent = !! originalUndelimitedContent;\n\tconst hasHTMLBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn canInsertBlockType(\n\t\t\t\t'core/html',\n\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tlet messageHTML = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__(\n\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.'\n\t\t),\n\t\toriginalBlock.title || originalName\n\t);\n\tconst actions = [\n\t\t<InstallButton\n\t\t\tkey=\"install\"\n\t\t\tblock={ originalBlock }\n\t\t\tattributes={ props.attributes }\n\t\t\tclientId={ props.clientId }\n\t\t/>,\n\t];\n\n\tif ( hasContent && hasHTMLBlock ) {\n\t\tmessageHTML = sprintf(\n\t\t\t/* translators: %s: block name */\n\t\t\t__(\n\t\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'\n\t\t\t),\n\t\t\toriginalBlock.title || originalName\n\t\t);\n\t\tactions.push(\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tkey=\"convert\"\n\t\t\t\tonClick={ convertToHTML }\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t>\n\t\t\t\t{ __( 'Keep as HTML' ) }\n\t\t\t</Button>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div { ...useBlockProps() }>\n\t\t\t<Warning actions={ actions }>{ messageHTML }</Warning>\n\t\t\t<RawHTML>{ originalUndelimitedContent }</RawHTML>\n\t\t</div>\n\t);\n};\n\nexport default getInstallMissing;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AASA,IAAAO,cAAA,GAAAC,sBAAA,CAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AAA2D,IAAAU,WAAA,GAAAV,OAAA;AAnB3D;AACA;AACA;;AAaA;AACA;AACA;;AAIA,MAAMW,iBAAiB,GAAKC,iBAAiB,IAAQC,KAAK,IAAM;EAC/D,MAAM;IAAEC;EAAa,CAAC,GAAGD,KAAK,CAACE,UAAU;EACzC;EACA;EACA,MAAM;IAAEC,KAAK;IA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AACzB,QAAA,CAAAuD,OAAO;MAAAJ,QAAA,EAAGvB;IAA0B,CAAW,CAAC;EAAA,CAC7C,CAAC;AAER,CAAC;AAAC,IAAA4B,QAAA,GAAAC,OAAA,CAAAZ,OAAA,GAEarC,iBAAiB","ignoreList":[]}
|
|
@@ -31,10 +31,8 @@ function InstallButton({
|
|
|
31
31
|
const {
|
|
32
32
|
replaceBlock
|
|
33
33
|
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
34
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
35
|
-
|
|
36
|
-
, {
|
|
37
|
-
__next40pxDefaultSize: false,
|
|
34
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
35
|
+
__next40pxDefaultSize: true,
|
|
38
36
|
onClick: () => installBlockType(block).then(success => {
|
|
39
37
|
if (success) {
|
|
40
38
|
const blockType = (0, _blocks.getBlockType)(block.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_blocks","_data","_blockEditor","_store","_jsxRuntime","InstallButton","attributes","block","clientId","isInstallingBlock","useSelect","select","blockDirectoryStore","isInstalling","id","installBlockType","useDispatch","replaceBlock","blockEditorStore","jsx","Button","__next40pxDefaultSize","onClick","then","success","blockType","getBlockType","name","originalBlock","parse","originalContent","createBlock","innerBlocks","accessibleWhenDisabled","disabled","isBusy","variant","children","sprintf","__","title"],"sources":["@wordpress/block-directory/src/plugins/get-install-missing/install-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createBlock, getBlockType, parse } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function InstallButton( { attributes, block, clientId } ) {\n\tconst isInstallingBlock = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).isInstalling( block.id ),\n\t\t[ block.id ]\n\t);\n\tconst { installBlockType } = useDispatch( blockDirectoryStore );\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<Button\n\t\t\
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_blocks","_data","_blockEditor","_store","_jsxRuntime","InstallButton","attributes","block","clientId","isInstallingBlock","useSelect","select","blockDirectoryStore","isInstalling","id","installBlockType","useDispatch","replaceBlock","blockEditorStore","jsx","Button","__next40pxDefaultSize","onClick","then","success","blockType","getBlockType","name","originalBlock","parse","originalContent","createBlock","innerBlocks","accessibleWhenDisabled","disabled","isBusy","variant","children","sprintf","__","title"],"sources":["@wordpress/block-directory/src/plugins/get-install-missing/install-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createBlock, getBlockType, parse } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function InstallButton( { attributes, block, clientId } ) {\n\tconst isInstallingBlock = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).isInstalling( block.id ),\n\t\t[ block.id ]\n\t);\n\tconst { installBlockType } = useDispatch( blockDirectoryStore );\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tonClick={ () =>\n\t\t\t\tinstallBlockType( block ).then( ( success ) => {\n\t\t\t\t\tif ( success ) {\n\t\t\t\t\t\tconst blockType = getBlockType( block.name );\n\t\t\t\t\t\tconst [ originalBlock ] = parse(\n\t\t\t\t\t\t\tattributes.originalContent\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( originalBlock && blockType ) {\n\t\t\t\t\t\t\treplaceBlock(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\tblockType.name,\n\t\t\t\t\t\t\t\t\toriginalBlock.attributes,\n\t\t\t\t\t\t\t\t\toriginalBlock.innerBlocks\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} )\n\t\t\t}\n\t\t\taccessibleWhenDisabled\n\t\t\tdisabled={ isInstallingBlock }\n\t\t\tisBusy={ isInstallingBlock }\n\t\t\tvariant=\"primary\"\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %s: block name */\n\t\t\t\t__( 'Install %s' ),\n\t\t\t\tblock.title\n\t\t\t) }\n\t\t</Button>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAA2D,IAAAM,WAAA,GAAAN,OAAA;AAZ3D;AACA;AACA;;AAOA;AACA;AACA;;AAGe,SAASO,aAAaA,CAAE;EAAEC,UAAU;EAAEC,KAAK;EAAEC;AAAS,CAAC,EAAG;EACxE,MAAMC,iBAAiB,GAAG,IAAAC,eAAS,EAChCC,MAAM,IAAMA,MAAM,CAAEC,YAAoB,CAAC,CAACC,YAAY,CAAEN,KAAK,CAACO,EAAG,CAAC,EACpE,CAAEP,KAAK,CAACO,EAAE,CACX,CAAC;EACD,MAAM;IAAEC;EAAiB,CAAC,GAAG,IAAAC,iBAAW,EAAEJ,YAAoB,CAAC;EAC/D,MAAM;IAAEK;EAAa,CAAC,GAAG,IAAAD,iBAAW,EAAEE,kBAAiB,CAAC;EAExD,oBACC,IAAAd,WAAA,CAAAe,GAAA,EAACpB,WAAA,CAAAqB,MAAM;IACNC,qBAAqB;IACrBC,OAAO,EAAGA,CAAA,KACTP,gBAAgB,CAAER,KAAM,CAAC,CAACgB,IAAI,CAAIC,OAAO,IAAM;MAC9C,IAAKA,OAAO,EAAG;QACd,MAAMC,SAAS,GAAG,IAAAC,oBAAY,EAAEnB,KAAK,CAACoB,IAAK,CAAC;QAC5C,MAAM,CAAEC,aAAa,CAAE,GAAG,IAAAC,aAAK,EAC9BvB,UAAU,CAACwB,eACZ,CAAC;QACD,IAAKF,aAAa,IAAIH,SAAS,EAAG;UACjCR,YAAY,CACXT,QAAQ,EACR,IAAAuB,mBAAW,EACVN,SAAS,CAACE,IAAI,EACdC,aAAa,CAACtB,UAAU,EACxBsB,aAAa,CAACI,WACf,CACD,CAAC;QACF;MACD;IACD,CAAE,CACF;IACDC,sBAAsB;IACtBC,QAAQ,EAAGzB,iBAAmB;IAC9B0B,MAAM,EAAG1B,iBAAmB;IAC5B2B,OAAO,EAAC,SAAS;IAAAC,QAAA,EAEf,IAAAC,aAAO,GACR;IACA,IAAAC,QAAE,EAAE,YAAa,CAAC,EAClBhC,KAAK,CAACiC,KACP;EAAC,CACM,CAAC;AAEX","ignoreList":[]}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
4
9
|
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
10
|
+
import { Tooltip, Spinner, VisuallyHidden, Composite } from '@wordpress/components';
|
|
6
11
|
import { createInterpolateElement } from '@wordpress/element';
|
|
7
12
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
8
13
|
import { getBlockType } from '@wordpress/blocks';
|
|
@@ -87,61 +92,58 @@ function DownloadableBlockListItem({
|
|
|
87
92
|
} else if (isInstalling) {
|
|
88
93
|
statusText = __('Installing…');
|
|
89
94
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
const itemLabel = getDownloadableBlockLabel(item, {
|
|
96
|
+
hasNotice,
|
|
97
|
+
isInstalled,
|
|
98
|
+
isInstalling
|
|
99
|
+
});
|
|
100
|
+
return /*#__PURE__*/_jsx(Tooltip, {
|
|
101
|
+
placement: "top",
|
|
102
|
+
text: itemLabel,
|
|
103
|
+
children: /*#__PURE__*/_jsxs(Composite.Item, {
|
|
104
|
+
className: clsx('block-directory-downloadable-block-list-item', isInstalling && 'is-installing'),
|
|
95
105
|
accessibleWhenDisabled: true,
|
|
96
|
-
|
|
97
|
-
role: "option",
|
|
98
|
-
className: "block-directory-downloadable-block-list-item",
|
|
99
|
-
isBusy: isInstalling,
|
|
106
|
+
disabled: isInstalling || !isInstallable,
|
|
100
107
|
onClick: event => {
|
|
101
108
|
event.preventDefault();
|
|
102
109
|
onClick();
|
|
103
110
|
},
|
|
104
|
-
label:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}),
|
|
119
|
-
className: "block-directory-downloadable-block-list-
|
|
120
|
-
children: /*#__PURE__*/_jsx(Spinner, {})
|
|
121
|
-
}) : /*#__PURE__*/_jsx(BlockRatings, {
|
|
122
|
-
rating: rating
|
|
123
|
-
})]
|
|
124
|
-
}), /*#__PURE__*/_jsxs("span", {
|
|
125
|
-
className: "block-directory-downloadable-block-list-item__details",
|
|
126
|
-
children: [/*#__PURE__*/_jsx("span", {
|
|
127
|
-
className: "block-directory-downloadable-block-list-item__title",
|
|
128
|
-
children: createInterpolateElement(sprintf( /* translators: %1$s: block title, %2$s: author name. */
|
|
129
|
-
__('%1$s <span>by %2$s</span>'), decodeEntities(title), author), {
|
|
130
|
-
span: /*#__PURE__*/_jsx("span", {
|
|
131
|
-
className: "block-directory-downloadable-block-list-item__author"
|
|
132
|
-
})
|
|
133
|
-
})
|
|
134
|
-
}), hasNotice ? /*#__PURE__*/_jsx(DownloadableBlockNotice, {
|
|
135
|
-
block: item
|
|
136
|
-
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
111
|
+
"aria-label": itemLabel,
|
|
112
|
+
type: "button",
|
|
113
|
+
role: "option",
|
|
114
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
115
|
+
className: "block-directory-downloadable-block-list-item__icon",
|
|
116
|
+
children: [/*#__PURE__*/_jsx(DownloadableBlockIcon, {
|
|
117
|
+
icon: icon,
|
|
118
|
+
title: title
|
|
119
|
+
}), isInstalling ? /*#__PURE__*/_jsx("span", {
|
|
120
|
+
className: "block-directory-downloadable-block-list-item__spinner",
|
|
121
|
+
children: /*#__PURE__*/_jsx(Spinner, {})
|
|
122
|
+
}) : /*#__PURE__*/_jsx(BlockRatings, {
|
|
123
|
+
rating: rating
|
|
124
|
+
})]
|
|
125
|
+
}), /*#__PURE__*/_jsxs("span", {
|
|
126
|
+
className: "block-directory-downloadable-block-list-item__details",
|
|
137
127
|
children: [/*#__PURE__*/_jsx("span", {
|
|
138
|
-
className: "block-directory-downloadable-block-list-
|
|
139
|
-
children:
|
|
140
|
-
|
|
141
|
-
|
|
128
|
+
className: "block-directory-downloadable-block-list-item__title",
|
|
129
|
+
children: createInterpolateElement(sprintf( /* translators: %1$s: block title, %2$s: author name. */
|
|
130
|
+
__('%1$s <span>by %2$s</span>'), decodeEntities(title), author), {
|
|
131
|
+
span: /*#__PURE__*/_jsx("span", {
|
|
132
|
+
className: "block-directory-downloadable-block-list-item__author"
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
}), hasNotice ? /*#__PURE__*/_jsx(DownloadableBlockNotice, {
|
|
136
|
+
block: item
|
|
137
|
+
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
138
|
+
children: [/*#__PURE__*/_jsx("span", {
|
|
139
|
+
className: "block-directory-downloadable-block-list-item__desc",
|
|
140
|
+
children: !!statusText ? statusText : decodeEntities(description)
|
|
141
|
+
}), isInstallable && !(isInstalled || isInstalling) && /*#__PURE__*/_jsx(VisuallyHidden, {
|
|
142
|
+
children: __('Install block')
|
|
143
|
+
})]
|
|
142
144
|
})]
|
|
143
145
|
})]
|
|
144
|
-
})
|
|
146
|
+
})
|
|
145
147
|
});
|
|
146
148
|
}
|
|
147
149
|
export default DownloadableBlockListItem;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","_n","sprintf","
|
|
1
|
+
{"version":3,"names":["clsx","__","_n","sprintf","Tooltip","Spinner","VisuallyHidden","Composite","createInterpolateElement","decodeEntities","getBlockType","useSelect","BlockRatings","DownloadableBlockIcon","DownloadableBlockNotice","store","blockDirectoryStore","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","getDownloadableBlockLabel","title","rating","ratingCount","hasNotice","isInstalled","isInstalling","stars","Math","round","DownloadableBlockListItem","item","onClick","author","description","icon","name","isInstallable","select","getErrorNoticeForBlock","isBlockInstalling","notice","id","hasFatal","isFatal","statusText","itemLabel","placement","text","children","Item","className","accessibleWhenDisabled","disabled","event","preventDefault","type","role","span","block"],"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tTooltip,\n\tSpinner,\n\tVisuallyHidden,\n\tComposite,\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( { 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\tconst itemLabel = getDownloadableBlockLabel( item, {\n\t\thasNotice,\n\t\tisInstalled,\n\t\tisInstalling,\n\t} );\n\n\treturn (\n\t\t<Tooltip placement=\"top\" text={ itemLabel }>\n\t\t\t<Composite.Item\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-directory-downloadable-block-list-item',\n\t\t\t\t\tisInstalling && 'is-installing'\n\t\t\t\t) }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tonClick();\n\t\t\t\t} }\n\t\t\t\taria-label={ itemLabel }\n\t\t\t\ttype=\"button\"\n\t\t\t\trole=\"option\"\n\t\t\t>\n\t\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %1$s: block title, %2$s: author name. */\n\t\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: (\n\t\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\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\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</Composite.Item>\n\t\t</Tooltip>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SACCC,OAAO,EACPC,OAAO,EACPC,cAAc,EACdC,SAAS,QACH,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,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const ModifiedWarning = ({
|
|
|
84
84
|
if (hasContent && hasHTMLBlock) {
|
|
85
85
|
messageHTML = sprintf( /* translators: %s: block name */
|
|
86
86
|
__('Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'), originalBlock.title || originalName);
|
|
87
|
-
actions.push( /*#__PURE__*/_jsx(Button
|
|
88
|
-
|
|
89
|
-
, {
|
|
90
|
-
__next40pxDefaultSize: false,
|
|
87
|
+
actions.push( /*#__PURE__*/_jsx(Button, {
|
|
88
|
+
__next40pxDefaultSize: true,
|
|
91
89
|
onClick: convertToHTML,
|
|
92
90
|
variant: "tertiary",
|
|
93
91
|
children: __('Keep as HTML')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","sprintf","Button","createBlock","RawHTML","useDispatch","useSelect","store","coreStore","Warning","useBlockProps","blockEditorStore","InstallButton","blockDirectoryStore","jsx","_jsx","jsxs","_jsxs","getInstallMissing","OriginalComponent","props","originalName","attributes","block","hasPermission","select","getDownloadableBlocks","blocks","filter","name","canUser","length","ModifiedWarning","originalBlock","originalUndelimitedContent","clientId","replaceBlock","convertToHTML","content","hasContent","hasHTMLBlock","canInsertBlockType","getBlockRootClientId","messageHTML","title","actions","push","__next40pxDefaultSize","onClick","variant","children"],"sources":["@wordpress/block-directory/src/plugins/get-install-missing/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createBlock } from '@wordpress/blocks';\nimport { RawHTML } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tWarning,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport InstallButton from './install-button';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst getInstallMissing = ( OriginalComponent ) => ( props ) => {\n\tconst { originalName } = props.attributes;\n\t// Disable reason: This is a valid component, but it's mistaken for a callback.\n\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\tconst { block, hasPermission } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getDownloadableBlocks } = select( blockDirectoryStore );\n\t\t\tconst blocks = getDownloadableBlocks(\n\t\t\t\t'block:' + originalName\n\t\t\t).filter( ( { name } ) => originalName === name );\n\t\t\treturn {\n\t\t\t\thasPermission: select( coreStore ).canUser(\n\t\t\t\t\t'read',\n\t\t\t\t\t'block-directory/search'\n\t\t\t\t),\n\t\t\t\tblock: blocks.length && blocks[ 0 ],\n\t\t\t};\n\t\t},\n\t\t[ originalName ]\n\t);\n\n\t// The user can't install blocks, or the block isn't available for download.\n\tif ( ! hasPermission || ! block ) {\n\t\treturn <OriginalComponent { ...props } />;\n\t}\n\n\treturn <ModifiedWarning { ...props } originalBlock={ block } />;\n};\n\nconst ModifiedWarning = ( { originalBlock, ...props } ) => {\n\tconst { originalName, originalUndelimitedContent, clientId } =\n\t\tprops.attributes;\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\tconst convertToHTML = () => {\n\t\treplaceBlock(\n\t\t\tprops.clientId,\n\t\t\tcreateBlock( 'core/html', {\n\t\t\t\tcontent: originalUndelimitedContent,\n\t\t\t} )\n\t\t);\n\t};\n\n\tconst hasContent = !! originalUndelimitedContent;\n\tconst hasHTMLBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn canInsertBlockType(\n\t\t\t\t'core/html',\n\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tlet messageHTML = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__(\n\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.'\n\t\t),\n\t\toriginalBlock.title || originalName\n\t);\n\tconst actions = [\n\t\t<InstallButton\n\t\t\tkey=\"install\"\n\t\t\tblock={ originalBlock }\n\t\t\tattributes={ props.attributes }\n\t\t\tclientId={ props.clientId }\n\t\t/>,\n\t];\n\n\tif ( hasContent && hasHTMLBlock ) {\n\t\tmessageHTML = sprintf(\n\t\t\t/* translators: %s: block name */\n\t\t\t__(\n\t\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'\n\t\t\t),\n\t\t\toriginalBlock.title || originalName\n\t\t);\n\t\tactions.push(\n\t\t\t<Button\n\t\t\t\
|
|
1
|
+
{"version":3,"names":["__","sprintf","Button","createBlock","RawHTML","useDispatch","useSelect","store","coreStore","Warning","useBlockProps","blockEditorStore","InstallButton","blockDirectoryStore","jsx","_jsx","jsxs","_jsxs","getInstallMissing","OriginalComponent","props","originalName","attributes","block","hasPermission","select","getDownloadableBlocks","blocks","filter","name","canUser","length","ModifiedWarning","originalBlock","originalUndelimitedContent","clientId","replaceBlock","convertToHTML","content","hasContent","hasHTMLBlock","canInsertBlockType","getBlockRootClientId","messageHTML","title","actions","push","__next40pxDefaultSize","onClick","variant","children"],"sources":["@wordpress/block-directory/src/plugins/get-install-missing/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createBlock } from '@wordpress/blocks';\nimport { RawHTML } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tWarning,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport InstallButton from './install-button';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst getInstallMissing = ( OriginalComponent ) => ( props ) => {\n\tconst { originalName } = props.attributes;\n\t// Disable reason: This is a valid component, but it's mistaken for a callback.\n\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\tconst { block, hasPermission } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getDownloadableBlocks } = select( blockDirectoryStore );\n\t\t\tconst blocks = getDownloadableBlocks(\n\t\t\t\t'block:' + originalName\n\t\t\t).filter( ( { name } ) => originalName === name );\n\t\t\treturn {\n\t\t\t\thasPermission: select( coreStore ).canUser(\n\t\t\t\t\t'read',\n\t\t\t\t\t'block-directory/search'\n\t\t\t\t),\n\t\t\t\tblock: blocks.length && blocks[ 0 ],\n\t\t\t};\n\t\t},\n\t\t[ originalName ]\n\t);\n\n\t// The user can't install blocks, or the block isn't available for download.\n\tif ( ! hasPermission || ! block ) {\n\t\treturn <OriginalComponent { ...props } />;\n\t}\n\n\treturn <ModifiedWarning { ...props } originalBlock={ block } />;\n};\n\nconst ModifiedWarning = ( { originalBlock, ...props } ) => {\n\tconst { originalName, originalUndelimitedContent, clientId } =\n\t\tprops.attributes;\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\tconst convertToHTML = () => {\n\t\treplaceBlock(\n\t\t\tprops.clientId,\n\t\t\tcreateBlock( 'core/html', {\n\t\t\t\tcontent: originalUndelimitedContent,\n\t\t\t} )\n\t\t);\n\t};\n\n\tconst hasContent = !! originalUndelimitedContent;\n\tconst hasHTMLBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn canInsertBlockType(\n\t\t\t\t'core/html',\n\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tlet messageHTML = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__(\n\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.'\n\t\t),\n\t\toriginalBlock.title || originalName\n\t);\n\tconst actions = [\n\t\t<InstallButton\n\t\t\tkey=\"install\"\n\t\t\tblock={ originalBlock }\n\t\t\tattributes={ props.attributes }\n\t\t\tclientId={ props.clientId }\n\t\t/>,\n\t];\n\n\tif ( hasContent && hasHTMLBlock ) {\n\t\tmessageHTML = sprintf(\n\t\t\t/* translators: %s: block name */\n\t\t\t__(\n\t\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'\n\t\t\t),\n\t\t\toriginalBlock.title || originalName\n\t\t);\n\t\tactions.push(\n\t\t\t<Button\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tkey=\"convert\"\n\t\t\t\tonClick={ convertToHTML }\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t>\n\t\t\t\t{ __( 'Keep as HTML' ) }\n\t\t\t</Button>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div { ...useBlockProps() }>\n\t\t\t<Warning actions={ actions }>{ messageHTML }</Warning>\n\t\t\t<RawHTML>{ originalUndelimitedContent }</RawHTML>\n\t\t</div>\n\t);\n};\n\nexport default getInstallMissing;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SACCC,OAAO,EACPC,aAAa,EACbH,KAAK,IAAII,gBAAgB,QACnB,yBAAyB;;AAEhC;AACA;AACA;AACA,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,SAASL,KAAK,IAAIM,mBAAmB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAE3D,MAAMC,iBAAiB,GAAKC,iBAAiB,IAAQC,KAAK,IAAM;EAC/D,MAAM;IAAEC;EAAa,CAAC,GAAGD,KAAK,CAACE,UAAU;EACzC;EACA;EACA,MAAM;IAAEC,KAAK;IAAEC;EAAc,CAAC,GAAGlB,SAAS,CACvCmB,MAAM,IAAM;IACb,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,CAAC;IAE3B,OAAO8B,kBAAkB,CACxB,WAAW,EACXC,oBAAoB,CAAEP,QAAS,CAChC,CAAC;EACF,CAAC,EACD,CAAEA,QAAQ,CACX,CAAC;EAED,IAAIQ,WAAW,GAAG1C,OAAO,EACxB;EACAD,EAAE,CACD,6GACD,CAAC,EACDiC,aAAa,CAACW,KAAK,IAAIvB,YACxB,CAAC;EACD,MAAMwB,OAAO,GAAG,cACf9B,IAAA,CAACH,aAAa;IAEbW,KAAK,EAAGU,aAAe;IACvBX,UAAU,EAAGF,KAAK,CAACE,UAAY;IAC/Ba,QAAQ,EAAGf,KAAK,CAACe;EAAU,GAHvB,SAIJ,CAAC,CACF;EAED,IAAKI,UAAU,IAAIC,YAAY,EAAG;IACjCG,WAAW,GAAG1C,OAAO,EACpB;IACAD,EAAE,CACD,iJACD,CAAC,EACDiC,aAAa,CAACW,KAAK,IAAIvB,YACxB,CAAC;IACDwB,OAAO,CAACC,IAAI,eACX/B,IAAA,CAACb,MAAM;MACN6C,qBAAqB;MAErBC,OAAO,EAAGX,aAAe;MACzBY,OAAO,EAAC,UAAU;MAAAC,QAAA,EAEhBlD,EAAE,CAAE,cAAe;IAAC,GAJlB,SAKG,CACT,CAAC;EACF;EAEA,oBACCiB,KAAA;IAAA,GAAUP,aAAa,CAAC,CAAC;IAAAwC,QAAA,gBACxBnC,IAAA,CAACN,OAAO;MAACoC,OAAO,EAAGA,OAAS;MAAAK,QAAA,EAAGP;IAAW,CAAW,CAAC,eACtD5B,IAAA,CAACX,OAAO;MAAA8C,QAAA,EAAGhB;IAA0B,CAAW,CAAC;EAAA,CAC7C,CAAC;AAER,CAAC;AAED,eAAehB,iBAAiB","ignoreList":[]}
|
|
@@ -24,10 +24,8 @@ export default function InstallButton({
|
|
|
24
24
|
const {
|
|
25
25
|
replaceBlock
|
|
26
26
|
} = useDispatch(blockEditorStore);
|
|
27
|
-
return /*#__PURE__*/_jsx(Button
|
|
28
|
-
|
|
29
|
-
, {
|
|
30
|
-
__next40pxDefaultSize: false,
|
|
27
|
+
return /*#__PURE__*/_jsx(Button, {
|
|
28
|
+
__next40pxDefaultSize: true,
|
|
31
29
|
onClick: () => installBlockType(block).then(success => {
|
|
32
30
|
if (success) {
|
|
33
31
|
const blockType = getBlockType(block.name);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","sprintf","Button","createBlock","getBlockType","parse","useSelect","useDispatch","store","blockEditorStore","blockDirectoryStore","jsx","_jsx","InstallButton","attributes","block","clientId","isInstallingBlock","select","isInstalling","id","installBlockType","replaceBlock","__next40pxDefaultSize","onClick","then","success","blockType","name","originalBlock","originalContent","innerBlocks","accessibleWhenDisabled","disabled","isBusy","variant","children","title"],"sources":["@wordpress/block-directory/src/plugins/get-install-missing/install-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createBlock, getBlockType, parse } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function InstallButton( { attributes, block, clientId } ) {\n\tconst isInstallingBlock = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).isInstalling( block.id ),\n\t\t[ block.id ]\n\t);\n\tconst { installBlockType } = useDispatch( blockDirectoryStore );\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<Button\n\t\t\
|
|
1
|
+
{"version":3,"names":["__","sprintf","Button","createBlock","getBlockType","parse","useSelect","useDispatch","store","blockEditorStore","blockDirectoryStore","jsx","_jsx","InstallButton","attributes","block","clientId","isInstallingBlock","select","isInstalling","id","installBlockType","replaceBlock","__next40pxDefaultSize","onClick","then","success","blockType","name","originalBlock","originalContent","innerBlocks","accessibleWhenDisabled","disabled","isBusy","variant","children","title"],"sources":["@wordpress/block-directory/src/plugins/get-install-missing/install-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createBlock, getBlockType, parse } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function InstallButton( { attributes, block, clientId } ) {\n\tconst isInstallingBlock = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).isInstalling( block.id ),\n\t\t[ block.id ]\n\t);\n\tconst { installBlockType } = useDispatch( blockDirectoryStore );\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<Button\n\t\t\t__next40pxDefaultSize\n\t\t\tonClick={ () =>\n\t\t\t\tinstallBlockType( block ).then( ( success ) => {\n\t\t\t\t\tif ( success ) {\n\t\t\t\t\t\tconst blockType = getBlockType( block.name );\n\t\t\t\t\t\tconst [ originalBlock ] = parse(\n\t\t\t\t\t\t\tattributes.originalContent\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( originalBlock && blockType ) {\n\t\t\t\t\t\t\treplaceBlock(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\tblockType.name,\n\t\t\t\t\t\t\t\t\toriginalBlock.attributes,\n\t\t\t\t\t\t\t\t\toriginalBlock.innerBlocks\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} )\n\t\t\t}\n\t\t\taccessibleWhenDisabled\n\t\t\tdisabled={ isInstallingBlock }\n\t\t\tisBusy={ isInstallingBlock }\n\t\t\tvariant=\"primary\"\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %s: block name */\n\t\t\t\t__( 'Install %s' ),\n\t\t\t\tblock.title\n\t\t\t) }\n\t\t</Button>\n\t);\n}\n"],"mappings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;IACDC,sBAAsB;IACtBC,QAAQ,EAAGhB,iBAAmB;IAC9BiB,MAAM,EAAGjB,iBAAmB;IAC5BkB,OAAO,EAAC,SAAS;IAAAC,QAAA,EAEfnC,OAAO,EACR;IACAD,EAAE,CAAE,YAAa,CAAC,EAClBe,KAAK,CAACsB,KACP;EAAC,CACM,CAAC;AAEX","ignoreList":[]}
|
|
@@ -155,22 +155,34 @@
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
.block-directory-downloadable-block-list-item {
|
|
158
|
-
|
|
158
|
+
display: grid;
|
|
159
|
+
grid-template-columns: auto 1fr;
|
|
159
160
|
width: 100%;
|
|
160
161
|
height: auto;
|
|
162
|
+
padding: 12px;
|
|
163
|
+
margin: 0;
|
|
164
|
+
appearance: none;
|
|
165
|
+
background: none;
|
|
166
|
+
border: 0;
|
|
161
167
|
text-align: right;
|
|
162
|
-
|
|
163
|
-
grid-template-columns: auto 1fr;
|
|
168
|
+
transition: box-shadow 0.1s linear;
|
|
164
169
|
position: relative;
|
|
165
170
|
}
|
|
171
|
+
.block-directory-downloadable-block-list-item + .block-directory-downloadable-block-list-item {
|
|
172
|
+
margin-top: 4px;
|
|
173
|
+
}
|
|
174
|
+
.block-directory-downloadable-block-list-item:not([aria-disabled=true]) {
|
|
175
|
+
cursor: pointer;
|
|
176
|
+
}
|
|
166
177
|
.block-directory-downloadable-block-list-item:hover {
|
|
167
178
|
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
168
179
|
outline: 2px solid transparent;
|
|
169
180
|
}
|
|
170
|
-
.block-directory-downloadable-block-list-item
|
|
171
|
-
|
|
181
|
+
.block-directory-downloadable-block-list-item[data-focus-visible] {
|
|
182
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
183
|
+
outline: 2px solid transparent;
|
|
172
184
|
}
|
|
173
|
-
.block-directory-downloadable-block-list-item.is-
|
|
185
|
+
.block-directory-downloadable-block-list-item.is-installing .block-directory-downloadable-block-list-item__author {
|
|
174
186
|
border: 0;
|
|
175
187
|
clip: rect(1px, 1px, 1px, 1px);
|
|
176
188
|
clip-path: inset(50%);
|
|
@@ -182,9 +194,6 @@
|
|
|
182
194
|
width: 1px;
|
|
183
195
|
word-wrap: normal !important;
|
|
184
196
|
}
|
|
185
|
-
.block-directory-downloadable-block-list-item:disabled, .block-directory-downloadable-block-list-item[aria-disabled] {
|
|
186
|
-
opacity: 1;
|
|
187
|
-
}
|
|
188
197
|
|
|
189
198
|
.block-directory-downloadable-block-list-item__icon {
|
|
190
199
|
position: relative;
|
|
@@ -271,10 +280,6 @@
|
|
|
271
280
|
margin-top: 0;
|
|
272
281
|
}
|
|
273
282
|
|
|
274
|
-
.block-directory-downloadable-blocks-panel button {
|
|
275
|
-
margin-top: 4px;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
283
|
.installed-blocks-pre-publish-panel__copy {
|
|
279
284
|
margin-top: 0;
|
|
280
285
|
}
|
package/build-style/style.css
CHANGED
|
@@ -155,22 +155,34 @@
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
.block-directory-downloadable-block-list-item {
|
|
158
|
-
|
|
158
|
+
display: grid;
|
|
159
|
+
grid-template-columns: auto 1fr;
|
|
159
160
|
width: 100%;
|
|
160
161
|
height: auto;
|
|
162
|
+
padding: 12px;
|
|
163
|
+
margin: 0;
|
|
164
|
+
appearance: none;
|
|
165
|
+
background: none;
|
|
166
|
+
border: 0;
|
|
161
167
|
text-align: left;
|
|
162
|
-
|
|
163
|
-
grid-template-columns: auto 1fr;
|
|
168
|
+
transition: box-shadow 0.1s linear;
|
|
164
169
|
position: relative;
|
|
165
170
|
}
|
|
171
|
+
.block-directory-downloadable-block-list-item + .block-directory-downloadable-block-list-item {
|
|
172
|
+
margin-top: 4px;
|
|
173
|
+
}
|
|
174
|
+
.block-directory-downloadable-block-list-item:not([aria-disabled=true]) {
|
|
175
|
+
cursor: pointer;
|
|
176
|
+
}
|
|
166
177
|
.block-directory-downloadable-block-list-item:hover {
|
|
167
178
|
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
168
179
|
outline: 2px solid transparent;
|
|
169
180
|
}
|
|
170
|
-
.block-directory-downloadable-block-list-item
|
|
171
|
-
|
|
181
|
+
.block-directory-downloadable-block-list-item[data-focus-visible] {
|
|
182
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
183
|
+
outline: 2px solid transparent;
|
|
172
184
|
}
|
|
173
|
-
.block-directory-downloadable-block-list-item.is-
|
|
185
|
+
.block-directory-downloadable-block-list-item.is-installing .block-directory-downloadable-block-list-item__author {
|
|
174
186
|
border: 0;
|
|
175
187
|
clip: rect(1px, 1px, 1px, 1px);
|
|
176
188
|
clip-path: inset(50%);
|
|
@@ -182,9 +194,6 @@
|
|
|
182
194
|
width: 1px;
|
|
183
195
|
word-wrap: normal !important;
|
|
184
196
|
}
|
|
185
|
-
.block-directory-downloadable-block-list-item:disabled, .block-directory-downloadable-block-list-item[aria-disabled] {
|
|
186
|
-
opacity: 1;
|
|
187
|
-
}
|
|
188
197
|
|
|
189
198
|
.block-directory-downloadable-block-list-item__icon {
|
|
190
199
|
position: relative;
|
|
@@ -271,10 +280,6 @@
|
|
|
271
280
|
margin-top: 0;
|
|
272
281
|
}
|
|
273
282
|
|
|
274
|
-
.block-directory-downloadable-blocks-panel button {
|
|
275
|
-
margin-top: 4px;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
283
|
.installed-blocks-pre-publish-panel__copy {
|
|
279
284
|
margin-top: 0;
|
|
280
285
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-directory",
|
|
3
|
-
"version": "5.8.
|
|
3
|
+
"version": "5.8.7",
|
|
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",
|
|
@@ -29,23 +29,24 @@
|
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
30
|
"@wordpress/a11y": "^4.8.2",
|
|
31
31
|
"@wordpress/api-fetch": "^7.8.2",
|
|
32
|
-
"@wordpress/block-editor": "^14.3.
|
|
32
|
+
"@wordpress/block-editor": "^14.3.5",
|
|
33
33
|
"@wordpress/blocks": "^13.8.4",
|
|
34
|
-
"@wordpress/components": "^28.8.
|
|
34
|
+
"@wordpress/components": "^28.8.5",
|
|
35
35
|
"@wordpress/compose": "^7.8.3",
|
|
36
|
-
"@wordpress/core-data": "^7.8.
|
|
36
|
+
"@wordpress/core-data": "^7.8.5",
|
|
37
37
|
"@wordpress/data": "^10.8.3",
|
|
38
|
-
"@wordpress/editor": "^14.8.
|
|
38
|
+
"@wordpress/editor": "^14.8.7",
|
|
39
39
|
"@wordpress/element": "^6.8.1",
|
|
40
40
|
"@wordpress/hooks": "^4.8.2",
|
|
41
41
|
"@wordpress/html-entities": "^4.8.1",
|
|
42
42
|
"@wordpress/i18n": "^5.8.2",
|
|
43
43
|
"@wordpress/icons": "^10.8.2",
|
|
44
44
|
"@wordpress/notices": "^5.8.3",
|
|
45
|
-
"@wordpress/plugins": "^7.8.
|
|
45
|
+
"@wordpress/plugins": "^7.8.5",
|
|
46
46
|
"@wordpress/private-apis": "^1.8.1",
|
|
47
47
|
"@wordpress/url": "^4.8.1",
|
|
48
|
-
"change-case": "^4.1.2"
|
|
48
|
+
"change-case": "^4.1.2",
|
|
49
|
+
"clsx": "^2.1.1"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
52
|
"react": "^18.0.0",
|
|
@@ -54,5 +55,5 @@
|
|
|
54
55
|
"publishConfig": {
|
|
55
56
|
"access": "public"
|
|
56
57
|
},
|
|
57
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "21b3c2e9abda74edab42455041edc6e82fccc388"
|
|
58
59
|
}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
4
9
|
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
5
10
|
import {
|
|
6
|
-
|
|
11
|
+
Tooltip,
|
|
7
12
|
Spinner,
|
|
8
13
|
VisuallyHidden,
|
|
9
14
|
Composite,
|
|
@@ -89,77 +94,75 @@ function DownloadableBlockListItem( { item, onClick } ) {
|
|
|
89
94
|
statusText = __( 'Installing…' );
|
|
90
95
|
}
|
|
91
96
|
|
|
97
|
+
const itemLabel = getDownloadableBlockLabel( item, {
|
|
98
|
+
hasNotice,
|
|
99
|
+
isInstalled,
|
|
100
|
+
isInstalling,
|
|
101
|
+
} );
|
|
102
|
+
|
|
92
103
|
return (
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
accessibleWhenDisabled
|
|
99
|
-
type="button"
|
|
100
|
-
role="option"
|
|
101
|
-
className="block-directory-downloadable-block-list-item"
|
|
102
|
-
isBusy={ isInstalling }
|
|
103
|
-
onClick={ ( event ) => {
|
|
104
|
-
event.preventDefault();
|
|
105
|
-
onClick();
|
|
106
|
-
} }
|
|
107
|
-
label={ getDownloadableBlockLabel( item, {
|
|
108
|
-
hasNotice,
|
|
109
|
-
isInstalled,
|
|
110
|
-
isInstalling,
|
|
111
|
-
} ) }
|
|
112
|
-
showTooltip
|
|
113
|
-
tooltipPosition="top center"
|
|
114
|
-
/>
|
|
115
|
-
}
|
|
116
|
-
disabled={ isInstalling || ! isInstallable }
|
|
117
|
-
>
|
|
118
|
-
<div className="block-directory-downloadable-block-list-item__icon">
|
|
119
|
-
<DownloadableBlockIcon icon={ icon } title={ title } />
|
|
120
|
-
{ isInstalling ? (
|
|
121
|
-
<span className="block-directory-downloadable-block-list-item__spinner">
|
|
122
|
-
<Spinner />
|
|
123
|
-
</span>
|
|
124
|
-
) : (
|
|
125
|
-
<BlockRatings rating={ rating } />
|
|
104
|
+
<Tooltip placement="top" text={ itemLabel }>
|
|
105
|
+
<Composite.Item
|
|
106
|
+
className={ clsx(
|
|
107
|
+
'block-directory-downloadable-block-list-item',
|
|
108
|
+
isInstalling && 'is-installing'
|
|
126
109
|
) }
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
110
|
+
accessibleWhenDisabled
|
|
111
|
+
disabled={ isInstalling || ! isInstallable }
|
|
112
|
+
onClick={ ( event ) => {
|
|
113
|
+
event.preventDefault();
|
|
114
|
+
onClick();
|
|
115
|
+
} }
|
|
116
|
+
aria-label={ itemLabel }
|
|
117
|
+
type="button"
|
|
118
|
+
role="option"
|
|
119
|
+
>
|
|
120
|
+
<div className="block-directory-downloadable-block-list-item__icon">
|
|
121
|
+
<DownloadableBlockIcon icon={ icon } title={ title } />
|
|
122
|
+
{ isInstalling ? (
|
|
123
|
+
<span className="block-directory-downloadable-block-list-item__spinner">
|
|
124
|
+
<Spinner />
|
|
125
|
+
</span>
|
|
126
|
+
) : (
|
|
127
|
+
<BlockRatings rating={ rating } />
|
|
128
|
+
) }
|
|
129
|
+
</div>
|
|
130
|
+
<span className="block-directory-downloadable-block-list-item__details">
|
|
131
|
+
<span className="block-directory-downloadable-block-list-item__title">
|
|
132
|
+
{ createInterpolateElement(
|
|
133
|
+
sprintf(
|
|
134
|
+
/* translators: %1$s: block title, %2$s: author name. */
|
|
135
|
+
__( '%1$s <span>by %2$s</span>' ),
|
|
136
|
+
decodeEntities( title ),
|
|
137
|
+
author
|
|
140
138
|
),
|
|
141
|
-
|
|
139
|
+
{
|
|
140
|
+
span: (
|
|
141
|
+
<span className="block-directory-downloadable-block-list-item__author" />
|
|
142
|
+
),
|
|
143
|
+
}
|
|
144
|
+
) }
|
|
145
|
+
</span>
|
|
146
|
+
{ hasNotice ? (
|
|
147
|
+
<DownloadableBlockNotice block={ item } />
|
|
148
|
+
) : (
|
|
149
|
+
<>
|
|
150
|
+
<span className="block-directory-downloadable-block-list-item__desc">
|
|
151
|
+
{ !! statusText
|
|
152
|
+
? statusText
|
|
153
|
+
: decodeEntities( description ) }
|
|
154
|
+
</span>
|
|
155
|
+
{ isInstallable &&
|
|
156
|
+
! ( isInstalled || isInstalling ) && (
|
|
157
|
+
<VisuallyHidden>
|
|
158
|
+
{ __( 'Install block' ) }
|
|
159
|
+
</VisuallyHidden>
|
|
160
|
+
) }
|
|
161
|
+
</>
|
|
142
162
|
) }
|
|
143
163
|
</span>
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
) : (
|
|
147
|
-
<>
|
|
148
|
-
<span className="block-directory-downloadable-block-list-item__desc">
|
|
149
|
-
{ !! statusText
|
|
150
|
-
? statusText
|
|
151
|
-
: decodeEntities( description ) }
|
|
152
|
-
</span>
|
|
153
|
-
{ isInstallable &&
|
|
154
|
-
! ( isInstalled || isInstalling ) && (
|
|
155
|
-
<VisuallyHidden>
|
|
156
|
-
{ __( 'Install block' ) }
|
|
157
|
-
</VisuallyHidden>
|
|
158
|
-
) }
|
|
159
|
-
</>
|
|
160
|
-
) }
|
|
161
|
-
</span>
|
|
162
|
-
</Composite.Item>
|
|
164
|
+
</Composite.Item>
|
|
165
|
+
</Tooltip>
|
|
163
166
|
);
|
|
164
167
|
}
|
|
165
168
|
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
.block-directory-downloadable-block-list-item {
|
|
2
|
-
|
|
2
|
+
& + & {
|
|
3
|
+
margin-top: $grid-unit-05;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
display: grid;
|
|
7
|
+
grid-template-columns: auto 1fr;
|
|
8
|
+
|
|
3
9
|
width: 100%;
|
|
4
10
|
height: auto;
|
|
11
|
+
padding: $grid-unit-15;
|
|
12
|
+
margin: 0;
|
|
13
|
+
|
|
14
|
+
appearance: none;
|
|
15
|
+
background: none;
|
|
16
|
+
border: 0;
|
|
5
17
|
text-align: left;
|
|
6
|
-
|
|
7
|
-
grid-template-columns: auto 1fr;
|
|
18
|
+
transition: box-shadow 0.1s linear;
|
|
8
19
|
|
|
9
20
|
// The item contains absolutely positioned items.
|
|
10
21
|
// Set `position: relative` on the parent to prevent overflow issues
|
|
@@ -12,13 +23,20 @@
|
|
|
12
23
|
// See: https://github.com/WordPress/gutenberg/issues/63384
|
|
13
24
|
position: relative;
|
|
14
25
|
|
|
26
|
+
|
|
27
|
+
&:not([aria-disabled="true"]) {
|
|
28
|
+
cursor: pointer;
|
|
29
|
+
}
|
|
30
|
+
|
|
15
31
|
&:hover {
|
|
16
32
|
@include button-style__focus();
|
|
17
33
|
}
|
|
18
34
|
|
|
19
|
-
|
|
20
|
-
|
|
35
|
+
&[data-focus-visible] {
|
|
36
|
+
@include button-style__focus();
|
|
37
|
+
}
|
|
21
38
|
|
|
39
|
+
&.is-installing {
|
|
22
40
|
.block-directory-downloadable-block-list-item__author {
|
|
23
41
|
border: 0;
|
|
24
42
|
clip: rect(1px, 1px, 1px, 1px);
|
|
@@ -33,11 +51,6 @@
|
|
|
33
51
|
word-wrap: normal !important;
|
|
34
52
|
}
|
|
35
53
|
}
|
|
36
|
-
|
|
37
|
-
&:disabled,
|
|
38
|
-
&[aria-disabled] {
|
|
39
|
-
opacity: 1;
|
|
40
|
-
}
|
|
41
54
|
}
|
|
42
55
|
|
|
43
56
|
.block-directory-downloadable-block-list-item__icon {
|
|
@@ -101,8 +101,7 @@ const ModifiedWarning = ( { originalBlock, ...props } ) => {
|
|
|
101
101
|
);
|
|
102
102
|
actions.push(
|
|
103
103
|
<Button
|
|
104
|
-
|
|
105
|
-
__next40pxDefaultSize={ false }
|
|
104
|
+
__next40pxDefaultSize
|
|
106
105
|
key="convert"
|
|
107
106
|
onClick={ convertToHTML }
|
|
108
107
|
variant="tertiary"
|
|
@@ -22,8 +22,7 @@ export default function InstallButton( { attributes, block, clientId } ) {
|
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
24
|
<Button
|
|
25
|
-
|
|
26
|
-
__next40pxDefaultSize={ false }
|
|
25
|
+
__next40pxDefaultSize
|
|
27
26
|
onClick={ () =>
|
|
28
27
|
installBlockType( block ).then( ( success ) => {
|
|
29
28
|
if ( success ) {
|