@wordpress/widgets 4.32.0 → 4.32.1-next.ff1cebbba.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/build/blocks/legacy-widget/block.json +29 -0
- package/build/blocks/legacy-widget/edit/control.js +137 -167
- package/build/blocks/legacy-widget/edit/control.js.map +7 -1
- package/build/blocks/legacy-widget/edit/convert-to-blocks-button.js +51 -39
- package/build/blocks/legacy-widget/edit/convert-to-blocks-button.js.map +7 -1
- package/build/blocks/legacy-widget/edit/form.js +105 -75
- package/build/blocks/legacy-widget/edit/form.js.map +7 -1
- package/build/blocks/legacy-widget/edit/index.js +121 -131
- package/build/blocks/legacy-widget/edit/index.js.map +7 -1
- package/build/blocks/legacy-widget/edit/inspector-card.js +28 -20
- package/build/blocks/legacy-widget/edit/inspector-card.js.map +7 -1
- package/build/blocks/legacy-widget/edit/no-preview.js +29 -23
- package/build/blocks/legacy-widget/edit/no-preview.js.map +7 -1
- package/build/blocks/legacy-widget/edit/preview.js +107 -108
- package/build/blocks/legacy-widget/edit/preview.js.map +7 -1
- package/build/blocks/legacy-widget/edit/widget-type-selector.js +61 -52
- package/build/blocks/legacy-widget/edit/widget-type-selector.js.map +7 -1
- package/build/blocks/legacy-widget/index.js +49 -53
- package/build/blocks/legacy-widget/index.js.map +7 -1
- package/build/blocks/legacy-widget/transforms.js +189 -198
- package/build/blocks/legacy-widget/transforms.js.map +7 -1
- package/build/blocks/widget-group/block.json +20 -0
- package/build/blocks/widget-group/deprecated.js +38 -24
- package/build/blocks/widget-group/deprecated.js.map +7 -1
- package/build/blocks/widget-group/edit.js +63 -67
- package/build/blocks/widget-group/edit.js.map +7 -1
- package/build/blocks/widget-group/index.js +93 -80
- package/build/blocks/widget-group/index.js.map +7 -1
- package/build/blocks/widget-group/save.js +36 -25
- package/build/blocks/widget-group/save.js.map +7 -1
- package/build/components/index.js +36 -12
- package/build/components/index.js.map +7 -1
- package/build/components/move-to-widget-area/index.js +48 -37
- package/build/components/move-to-widget-area/index.js.map +7 -1
- package/build/index.js +67 -98
- package/build/index.js.map +7 -1
- package/build/register-legacy-widget-variations.js +42 -30
- package/build/register-legacy-widget-variations.js.map +7 -1
- package/build/utils.js +29 -29
- package/build/utils.js.map +7 -1
- package/build-module/blocks/legacy-widget/block.json +29 -0
- package/build-module/blocks/legacy-widget/edit/control.js +107 -158
- package/build-module/blocks/legacy-widget/edit/control.js.map +7 -1
- package/build-module/blocks/legacy-widget/edit/convert-to-blocks-button.js +33 -33
- package/build-module/blocks/legacy-widget/edit/convert-to-blocks-button.js.map +7 -1
- package/build-module/blocks/legacy-widget/edit/form.js +75 -64
- package/build-module/blocks/legacy-widget/edit/form.js.map +7 -1
- package/build-module/blocks/legacy-widget/edit/index.js +96 -122
- package/build-module/blocks/legacy-widget/edit/index.js.map +7 -1
- package/build-module/blocks/legacy-widget/edit/inspector-card.js +10 -15
- package/build-module/blocks/legacy-widget/edit/inspector-card.js.map +7 -1
- package/build-module/blocks/legacy-widget/edit/no-preview.js +11 -17
- package/build-module/blocks/legacy-widget/edit/no-preview.js.map +7 -1
- package/build-module/blocks/legacy-widget/edit/preview.js +76 -98
- package/build-module/blocks/legacy-widget/edit/preview.js.map +7 -1
- package/build-module/blocks/legacy-widget/edit/widget-type-selector.js +43 -46
- package/build-module/blocks/legacy-widget/edit/widget-type-selector.js.map +7 -1
- package/build-module/blocks/legacy-widget/index.js +12 -45
- package/build-module/blocks/legacy-widget/index.js.map +7 -1
- package/build-module/blocks/legacy-widget/transforms.js +171 -192
- package/build-module/blocks/legacy-widget/transforms.js.map +7 -1
- package/build-module/blocks/widget-group/block.json +20 -0
- package/build-module/blocks/widget-group/deprecated.js +20 -18
- package/build-module/blocks/widget-group/deprecated.js.map +7 -1
- package/build-module/blocks/widget-group/edit.js +53 -62
- package/build-module/blocks/widget-group/edit.js.map +7 -1
- package/build-module/blocks/widget-group/index.js +55 -71
- package/build-module/blocks/widget-group/index.js.map +7 -1
- package/build-module/blocks/widget-group/save.js +18 -19
- package/build-module/blocks/widget-group/save.js.map +7 -1
- package/build-module/components/index.js +5 -2
- package/build-module/components/index.js.map +7 -1
- package/build-module/components/move-to-widget-area/index.js +37 -32
- package/build-module/components/move-to-widget-area/index.js.map +7 -1
- package/build-module/index.js +34 -60
- package/build-module/index.js.map +7 -1
- package/build-module/register-legacy-widget-variations.js +24 -24
- package/build-module/register-legacy-widget-variations.js.map +7 -1
- package/build-module/utils.js +8 -25
- package/build-module/utils.js.map +7 -1
- package/build-style/style-rtl.css +10 -145
- package/build-style/style.css +10 -145
- package/package.json +21 -14
- package/src/blocks/legacy-widget/editor.scss +3 -0
- package/src/blocks/widget-group/editor.scss +3 -0
- package/src/style.scss +3 -2
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/move-to-widget-area/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItemsChoice,\n\tToolbarGroup,\n\tToolbarItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { moveTo } from '@wordpress/icons';\n\nexport default function MoveToWidgetArea( {\n\tcurrentWidgetAreaId,\n\twidgetAreas,\n\tonSelect,\n} ) {\n\treturn (\n\t\t<ToolbarGroup>\n\t\t\t<ToolbarItem>\n\t\t\t\t{ ( toggleProps ) => (\n\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\ticon={ moveTo }\n\t\t\t\t\t\tlabel={ __( 'Move to widget area' ) }\n\t\t\t\t\t\ttoggleProps={ toggleProps }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t\t<MenuGroup label={ __( 'Move to' ) }>\n\t\t\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\t\t\tchoices={ widgetAreas.map(\n\t\t\t\t\t\t\t\t\t\t( widgetArea ) => ( {\n\t\t\t\t\t\t\t\t\t\t\tvalue: widgetArea.id,\n\t\t\t\t\t\t\t\t\t\t\tlabel: widgetArea.name,\n\t\t\t\t\t\t\t\t\t\t\tinfo: widgetArea.description,\n\t\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tvalue={ currentWidgetAreaId }\n\t\t\t\t\t\t\t\t\tonSelect={ ( value ) => {\n\t\t\t\t\t\t\t\t\t\tonSelect( value );\n\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</DropdownMenu>\n\t\t\t\t) }\n\t\t\t</ToolbarItem>\n\t\t</ToolbarGroup>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BQ;AA1BR,wBAMO;AACP,kBAAmB;AACnB,mBAAuB;AAER,SAAR,iBAAmC;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AACD,GAAI;AACH,SACC,4CAAC,kCACA,sDAAC,iCACE,WAAE,gBACH;AAAA,IAAC;AAAA;AAAA,MACA,MAAO;AAAA,MACP,WAAQ,gBAAI,qBAAsB;AAAA,MAClC;AAAA,MAEE,WAAE,EAAE,QAAQ,MACb,4CAAC,+BAAU,WAAQ,gBAAI,SAAU,GAChC;AAAA,QAAC;AAAA;AAAA,UACA,SAAU,YAAY;AAAA,YACrB,CAAE,gBAAkB;AAAA,cACnB,OAAO,WAAW;AAAA,cAClB,OAAO,WAAW;AAAA,cAClB,MAAM,WAAW;AAAA,YAClB;AAAA,UACD;AAAA,UACA,OAAQ;AAAA,UACR,UAAW,CAAE,UAAW;AACvB,qBAAU,KAAM;AAChB,oBAAQ;AAAA,UACT;AAAA;AAAA,MACD,GACD;AAAA;AAAA,EAEF,GAEF,GACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/build/index.js
CHANGED
|
@@ -1,107 +1,76 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
registerLegacyWidgetVariations: true
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
10
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
16
|
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var index_exports = {};
|
|
30
|
+
__export(index_exports, {
|
|
31
|
+
registerLegacyWidgetBlock: () => registerLegacyWidgetBlock,
|
|
32
|
+
registerLegacyWidgetVariations: () => import_register_legacy_widget_variations.default,
|
|
33
|
+
registerWidgetGroupBlock: () => registerWidgetGroupBlock
|
|
18
34
|
});
|
|
19
|
-
exports
|
|
20
|
-
var
|
|
21
|
-
var legacyWidget =
|
|
22
|
-
var widgetGroup =
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
27
|
-
if (key in exports && exports[key] === _components[key]) return;
|
|
28
|
-
Object.defineProperty(exports, key, {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: function () {
|
|
31
|
-
return _components[key];
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
var _utils = require("./utils");
|
|
36
|
-
Object.keys(_utils).forEach(function (key) {
|
|
37
|
-
if (key === "default" || key === "__esModule") return;
|
|
38
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
39
|
-
if (key in exports && exports[key] === _utils[key]) return;
|
|
40
|
-
Object.defineProperty(exports, key, {
|
|
41
|
-
enumerable: true,
|
|
42
|
-
get: function () {
|
|
43
|
-
return _utils[key];
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
var _registerLegacyWidgetVariations = _interopRequireDefault(require("./register-legacy-widget-variations"));
|
|
48
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
49
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
50
|
-
/**
|
|
51
|
-
* WordPress dependencies
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Internal dependencies
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Registers the Legacy Widget block.
|
|
60
|
-
*
|
|
61
|
-
* Note that for the block to be useful, any scripts required by a widget must
|
|
62
|
-
* be loaded into the page.
|
|
63
|
-
*
|
|
64
|
-
* @param {Object} supports Block support settings.
|
|
65
|
-
* @see https://developer.wordpress.org/block-editor/how-to-guides/widgets/legacy-widget-block/
|
|
66
|
-
*/
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
36
|
+
var import_blocks = require("@wordpress/blocks");
|
|
37
|
+
var legacyWidget = __toESM(require("./blocks/legacy-widget"));
|
|
38
|
+
var widgetGroup = __toESM(require("./blocks/widget-group"));
|
|
39
|
+
__reExport(index_exports, require("./components"), module.exports);
|
|
40
|
+
__reExport(index_exports, require("./utils"), module.exports);
|
|
41
|
+
var import_register_legacy_widget_variations = __toESM(require("./register-legacy-widget-variations"));
|
|
67
42
|
function registerLegacyWidgetBlock(supports = {}) {
|
|
68
|
-
const {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
...settings,
|
|
78
|
-
supports: {
|
|
79
|
-
...settings.supports,
|
|
80
|
-
...supports
|
|
43
|
+
const { metadata, settings, name } = legacyWidget;
|
|
44
|
+
(0, import_blocks.registerBlockType)(
|
|
45
|
+
{ name, ...metadata },
|
|
46
|
+
{
|
|
47
|
+
...settings,
|
|
48
|
+
supports: {
|
|
49
|
+
...settings.supports,
|
|
50
|
+
...supports
|
|
51
|
+
}
|
|
81
52
|
}
|
|
82
|
-
|
|
53
|
+
);
|
|
83
54
|
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Registers the Widget Group block.
|
|
87
|
-
*
|
|
88
|
-
* @param {Object} supports Block support settings.
|
|
89
|
-
*/
|
|
90
55
|
function registerWidgetGroupBlock(supports = {}) {
|
|
91
|
-
const {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
...settings,
|
|
101
|
-
supports: {
|
|
102
|
-
...settings.supports,
|
|
103
|
-
...supports
|
|
56
|
+
const { metadata, settings, name } = widgetGroup;
|
|
57
|
+
(0, import_blocks.registerBlockType)(
|
|
58
|
+
{ name, ...metadata },
|
|
59
|
+
{
|
|
60
|
+
...settings,
|
|
61
|
+
supports: {
|
|
62
|
+
...settings.supports,
|
|
63
|
+
...supports
|
|
64
|
+
}
|
|
104
65
|
}
|
|
105
|
-
|
|
66
|
+
);
|
|
106
67
|
}
|
|
107
|
-
|
|
68
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
+
0 && (module.exports = {
|
|
70
|
+
registerLegacyWidgetBlock,
|
|
71
|
+
registerLegacyWidgetVariations,
|
|
72
|
+
registerWidgetGroupBlock,
|
|
73
|
+
...require("./components"),
|
|
74
|
+
...require("./utils")
|
|
75
|
+
});
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
package/build/index.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { registerBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport * as legacyWidget from './blocks/legacy-widget';\nimport * as widgetGroup from './blocks/widget-group';\n\nexport * from './components';\nexport * from './utils';\n\n/**\n * Registers the Legacy Widget block.\n *\n * Note that for the block to be useful, any scripts required by a widget must\n * be loaded into the page.\n *\n * @param {Object} supports Block support settings.\n * @see https://developer.wordpress.org/block-editor/how-to-guides/widgets/legacy-widget-block/\n */\nexport function registerLegacyWidgetBlock( supports = {} ) {\n\tconst { metadata, settings, name } = legacyWidget;\n\tregisterBlockType(\n\t\t{ name, ...metadata },\n\t\t{\n\t\t\t...settings,\n\t\t\tsupports: {\n\t\t\t\t...settings.supports,\n\t\t\t\t...supports,\n\t\t\t},\n\t\t}\n\t);\n}\n\n/**\n * Registers the Widget Group block.\n *\n * @param {Object} supports Block support settings.\n */\nexport function registerWidgetGroupBlock( supports = {} ) {\n\tconst { metadata, settings, name } = widgetGroup;\n\tregisterBlockType(\n\t\t{ name, ...metadata },\n\t\t{\n\t\t\t...settings,\n\t\t\tsupports: {\n\t\t\t\t...settings.supports,\n\t\t\t\t...supports,\n\t\t\t},\n\t\t}\n\t);\n}\n\nexport { default as registerLegacyWidgetVariations } from './register-legacy-widget-variations';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAkC;AAKlC,mBAA8B;AAC9B,kBAA6B;AAE7B,0BAAc,yBAXd;AAYA,0BAAc,oBAZd;AAwDA,+CAA0D;AAjCnD,SAAS,0BAA2B,WAAW,CAAC,GAAI;AAC1D,QAAM,EAAE,UAAU,UAAU,KAAK,IAAI;AACrC;AAAA,IACC,EAAE,MAAM,GAAG,SAAS;AAAA,IACpB;AAAA,MACC,GAAG;AAAA,MACH,UAAU;AAAA,QACT,GAAG,SAAS;AAAA,QACZ,GAAG;AAAA,MACJ;AAAA,IACD;AAAA,EACD;AACD;AAOO,SAAS,yBAA0B,WAAW,CAAC,GAAI;AACzD,QAAM,EAAE,UAAU,UAAU,KAAK,IAAI;AACrC;AAAA,IACC,EAAE,MAAM,GAAG,SAAS;AAAA,IACpB;AAAA,MACC,GAAG;AAAA,MACH,UAAU;AAAA,QACT,GAAG,SAAS;AAAA,QACZ,GAAG;AAAA,MACJ;AAAA,IACD;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,37 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var register_legacy_widget_variations_exports = {};
|
|
19
|
+
__export(register_legacy_widget_variations_exports, {
|
|
20
|
+
default: () => registerLegacyWidgetVariations
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
/**
|
|
11
|
-
* WordPress dependencies
|
|
12
|
-
*/
|
|
13
|
-
|
|
22
|
+
module.exports = __toCommonJS(register_legacy_widget_variations_exports);
|
|
23
|
+
var import_data = require("@wordpress/data");
|
|
24
|
+
var import_core_data = require("@wordpress/core-data");
|
|
25
|
+
var import_blocks = require("@wordpress/blocks");
|
|
14
26
|
function registerLegacyWidgetVariations(settings) {
|
|
15
|
-
const unsubscribe = (0,
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
const widgetTypes = (0, _data.select)(_coreData.store).getWidgetTypes({
|
|
19
|
-
per_page: -1
|
|
20
|
-
})?.filter(widgetType => !hiddenIds.includes(widgetType.id));
|
|
27
|
+
const unsubscribe = (0, import_data.subscribe)(() => {
|
|
28
|
+
const hiddenIds = settings?.widgetTypesToHideFromLegacyWidgetBlock ?? [];
|
|
29
|
+
const widgetTypes = (0, import_data.select)(import_core_data.store).getWidgetTypes({ per_page: -1 })?.filter((widgetType) => !hiddenIds.includes(widgetType.id));
|
|
21
30
|
if (widgetTypes) {
|
|
22
31
|
unsubscribe();
|
|
23
|
-
(0,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
(0, import_data.dispatch)(import_blocks.store).addBlockVariations(
|
|
33
|
+
"core/legacy-widget",
|
|
34
|
+
widgetTypes.map((widgetType) => ({
|
|
35
|
+
name: widgetType.id,
|
|
36
|
+
title: widgetType.name,
|
|
37
|
+
description: widgetType.description,
|
|
38
|
+
attributes: widgetType.is_multi ? {
|
|
39
|
+
idBase: widgetType.id,
|
|
40
|
+
instance: {}
|
|
41
|
+
} : {
|
|
42
|
+
id: widgetType.id
|
|
43
|
+
}
|
|
44
|
+
}))
|
|
45
|
+
);
|
|
34
46
|
}
|
|
35
47
|
});
|
|
36
48
|
}
|
|
37
|
-
//# sourceMappingURL=register-legacy-widget-variations.js.map
|
|
49
|
+
//# sourceMappingURL=register-legacy-widget-variations.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/register-legacy-widget-variations.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { subscribe, select, dispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blocksStore } from '@wordpress/blocks';\n\nexport default function registerLegacyWidgetVariations( settings ) {\n\tconst unsubscribe = subscribe( () => {\n\t\tconst hiddenIds =\n\t\t\tsettings?.widgetTypesToHideFromLegacyWidgetBlock ?? [];\n\t\tconst widgetTypes = select( coreStore )\n\t\t\t.getWidgetTypes( { per_page: -1 } )\n\t\t\t?.filter( ( widgetType ) => ! hiddenIds.includes( widgetType.id ) );\n\t\tif ( widgetTypes ) {\n\t\t\tunsubscribe();\n\t\t\tdispatch( blocksStore ).addBlockVariations(\n\t\t\t\t'core/legacy-widget',\n\t\t\t\twidgetTypes.map( ( widgetType ) => ( {\n\t\t\t\t\tname: widgetType.id,\n\t\t\t\t\ttitle: widgetType.name,\n\t\t\t\t\tdescription: widgetType.description,\n\t\t\t\t\tattributes: widgetType.is_multi\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tidBase: widgetType.id,\n\t\t\t\t\t\t\t\tinstance: {},\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tid: widgetType.id,\n\t\t\t\t\t\t },\n\t\t\t\t} ) )\n\t\t\t);\n\t\t}\n\t} );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4C;AAC5C,uBAAmC;AACnC,oBAAqC;AAEtB,SAAR,+BAAiD,UAAW;AAClE,QAAM,kBAAc,uBAAW,MAAM;AACpC,UAAM,YACL,UAAU,0CAA0C,CAAC;AACtD,UAAM,kBAAc,oBAAQ,iBAAAA,KAAU,EACpC,eAAgB,EAAE,UAAU,GAAG,CAAE,GAChC,OAAQ,CAAE,eAAgB,CAAE,UAAU,SAAU,WAAW,EAAG,CAAE;AACnE,QAAK,aAAc;AAClB,kBAAY;AACZ,gCAAU,cAAAC,KAAY,EAAE;AAAA,QACvB;AAAA,QACA,YAAY,IAAK,CAAE,gBAAkB;AAAA,UACpC,MAAM,WAAW;AAAA,UACjB,OAAO,WAAW;AAAA,UAClB,aAAa,WAAW;AAAA,UACxB,YAAY,WAAW,WACpB;AAAA,YACA,QAAQ,WAAW;AAAA,YACnB,UAAU,CAAC;AAAA,UACX,IACA;AAAA,YACA,IAAI,WAAW;AAAA,UACf;AAAA,QACJ,EAAI;AAAA,MACL;AAAA,IACD;AAAA,EACD,CAAE;AACH;",
|
|
6
|
+
"names": ["coreStore", "blocksStore"]
|
|
7
|
+
}
|
package/build/utils.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var utils_exports = {};
|
|
19
|
+
__export(utils_exports, {
|
|
20
|
+
addWidgetIdToBlock: () => addWidgetIdToBlock,
|
|
21
|
+
getWidgetIdFromBlock: () => getWidgetIdFromBlock
|
|
5
22
|
});
|
|
6
|
-
exports
|
|
7
|
-
exports.getWidgetIdFromBlock = getWidgetIdFromBlock;
|
|
8
|
-
// @ts-check
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Get the internal widget id from block.
|
|
12
|
-
*
|
|
13
|
-
* @typedef {Object} Attributes
|
|
14
|
-
* @property {string} __internalWidgetId The internal widget id.
|
|
15
|
-
* @typedef {Object} Block
|
|
16
|
-
* @property {Attributes} attributes The attributes of the block.
|
|
17
|
-
*
|
|
18
|
-
* @param {Block} block The block.
|
|
19
|
-
* @return {string} The internal widget id.
|
|
20
|
-
*/
|
|
23
|
+
module.exports = __toCommonJS(utils_exports);
|
|
21
24
|
function getWidgetIdFromBlock(block) {
|
|
22
25
|
return block.attributes.__internalWidgetId;
|
|
23
26
|
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Add internal widget id to block's attributes.
|
|
27
|
-
*
|
|
28
|
-
* @param {Block} block The block.
|
|
29
|
-
* @param {string} widgetId The widget id.
|
|
30
|
-
* @return {Block} The updated block.
|
|
31
|
-
*/
|
|
32
27
|
function addWidgetIdToBlock(block, widgetId) {
|
|
33
28
|
return {
|
|
34
29
|
...block,
|
|
35
30
|
attributes: {
|
|
36
|
-
...
|
|
31
|
+
...block.attributes || {},
|
|
37
32
|
__internalWidgetId: widgetId
|
|
38
33
|
}
|
|
39
34
|
};
|
|
40
35
|
}
|
|
41
|
-
|
|
36
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
37
|
+
0 && (module.exports = {
|
|
38
|
+
addWidgetIdToBlock,
|
|
39
|
+
getWidgetIdFromBlock
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=utils.js.map
|
package/build/utils.js.map
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/utils.js"],
|
|
4
|
+
"sourcesContent": ["// @ts-check\n\n/**\n * Get the internal widget id from block.\n *\n * @typedef {Object} Attributes\n * @property {string} __internalWidgetId The internal widget id.\n * @typedef {Object} Block\n * @property {Attributes} attributes The attributes of the block.\n *\n * @param {Block} block The block.\n * @return {string} The internal widget id.\n */\nexport function getWidgetIdFromBlock( block ) {\n\treturn block.attributes.__internalWidgetId;\n}\n\n/**\n * Add internal widget id to block's attributes.\n *\n * @param {Block} block The block.\n * @param {string} widgetId The widget id.\n * @return {Block} The updated block.\n */\nexport function addWidgetIdToBlock( block, widgetId ) {\n\treturn {\n\t\t...block,\n\t\tattributes: {\n\t\t\t...( block.attributes || {} ),\n\t\t\t__internalWidgetId: widgetId,\n\t\t},\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,SAAS,qBAAsB,OAAQ;AAC7C,SAAO,MAAM,WAAW;AACzB;AASO,SAAS,mBAAoB,OAAO,UAAW;AACrD,SAAO;AAAA,IACN,GAAG;AAAA,IACH,YAAY;AAAA,MACX,GAAK,MAAM,cAAc,CAAC;AAAA,MAC1B,oBAAoB;AAAA,IACrB;AAAA,EACD;AACD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 3,
|
|
4
|
+
"name": "core/legacy-widget",
|
|
5
|
+
"title": "Legacy Widget",
|
|
6
|
+
"category": "widgets",
|
|
7
|
+
"description": "Display a legacy widget.",
|
|
8
|
+
"textdomain": "default",
|
|
9
|
+
"attributes": {
|
|
10
|
+
"id": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"default": null
|
|
13
|
+
},
|
|
14
|
+
"idBase": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"default": null
|
|
17
|
+
},
|
|
18
|
+
"instance": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"default": null
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"supports": {
|
|
24
|
+
"html": false,
|
|
25
|
+
"customClassName": false,
|
|
26
|
+
"reusable": false
|
|
27
|
+
},
|
|
28
|
+
"editorStyle": "wp-block-legacy-widget-editor"
|
|
29
|
+
}
|