2022-04-11 14:04:30 +02:00
/******/ ( function ( ) { // webpackBootstrap
/******/ var _ _webpack _modules _ _ = ( {
/***/ 4403 :
/***/ ( function ( module , exports ) {
var _ _WEBPACK _AMD _DEFINE _ARRAY _ _ , _ _WEBPACK _AMD _DEFINE _RESULT _ _ ; / * !
2022-09-20 17:43:29 +02:00
Copyright ( c ) 2018 Jed Watson .
Licensed under the MIT License ( MIT ) , see
http : //jedwatson.github.io/classnames
2022-04-11 14:04:30 +02:00
* /
/* global define */
( function ( ) {
'use strict' ;
var hasOwn = { } . hasOwnProperty ;
2022-09-20 17:43:29 +02:00
var nativeCodeString = '[native code]' ;
2022-04-11 14:04:30 +02:00
function classNames ( ) {
var classes = [ ] ;
for ( var i = 0 ; i < arguments . length ; i ++ ) {
var arg = arguments [ i ] ;
if ( ! arg ) continue ;
var argType = typeof arg ;
if ( argType === 'string' || argType === 'number' ) {
classes . push ( arg ) ;
} else if ( Array . isArray ( arg ) ) {
if ( arg . length ) {
var inner = classNames . apply ( null , arg ) ;
if ( inner ) {
classes . push ( inner ) ;
}
}
} else if ( argType === 'object' ) {
2022-09-20 17:43:29 +02:00
if ( arg . toString !== Object . prototype . toString && ! arg . toString . toString ( ) . includes ( '[native code]' ) ) {
2022-04-11 14:04:30 +02:00
classes . push ( arg . toString ( ) ) ;
2022-09-20 17:43:29 +02:00
continue ;
}
for ( var key in arg ) {
if ( hasOwn . call ( arg , key ) && arg [ key ] ) {
classes . push ( key ) ;
}
2022-04-11 14:04:30 +02:00
}
}
}
return classes . join ( ' ' ) ;
}
if ( true && module . exports ) {
classNames . default = classNames ;
module . exports = classNames ;
} else if ( true ) {
// register as 'classnames', consistent with npm package name
! ( _ _WEBPACK _AMD _DEFINE _ARRAY _ _ = [ ] , _ _WEBPACK _AMD _DEFINE _RESULT _ _ = ( function ( ) {
return classNames ;
} ) . apply ( exports , _ _WEBPACK _AMD _DEFINE _ARRAY _ _ ) ,
_ _WEBPACK _AMD _DEFINE _RESULT _ _ !== undefined && ( module . exports = _ _WEBPACK _AMD _DEFINE _RESULT _ _ ) ) ;
} else { }
} ( ) ) ;
/***/ } )
/******/ } ) ;
/************************************************************************/
2021-05-25 10:40:25 +02:00
/******/ // The module cache
2022-04-11 14:04:30 +02:00
/******/ var _ _webpack _module _cache _ _ = { } ;
/******/
2021-05-25 10:40:25 +02:00
/******/ // The require function
/******/ function _ _webpack _require _ _ ( moduleId ) {
/******/ // Check if module is in cache
2022-04-11 14:04:30 +02:00
/******/ var cachedModule = _ _webpack _module _cache _ _ [ moduleId ] ;
/******/ if ( cachedModule !== undefined ) {
/******/ return cachedModule . exports ;
2021-05-25 10:40:25 +02:00
/******/ }
/******/ // Create a new module (and put it into the cache)
2022-04-11 14:04:30 +02:00
/******/ var module = _ _webpack _module _cache _ _ [ moduleId ] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
2021-05-25 10:40:25 +02:00
/******/ exports : { }
/******/ } ;
2022-04-11 14:04:30 +02:00
/******/
2021-05-25 10:40:25 +02:00
/******/ // Execute the module function
2022-04-11 14:04:30 +02:00
/******/ _ _webpack _modules _ _ [ moduleId ] ( module , module . exports , _ _webpack _require _ _ ) ;
/******/
2021-05-25 10:40:25 +02:00
/******/ // Return the exports of the module
/******/ return module . exports ;
/******/ }
2022-04-11 14:04:30 +02:00
/******/
2021-05-25 10:40:25 +02:00
/************************************************************************/
2022-04-11 14:04:30 +02:00
/******/ /* webpack/runtime/compat get default export */
/******/ ! function ( ) {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ _ _webpack _require _ _ . n = function ( module ) {
/******/ var getter = module && module . _ _esModule ?
/******/ function ( ) { return module [ 'default' ] ; } :
/******/ function ( ) { return module ; } ;
/******/ _ _webpack _require _ _ . d ( getter , { a : getter } ) ;
/******/ return getter ;
/******/ } ;
/******/ } ( ) ;
/******/
/******/ /* webpack/runtime/define property getters */
/******/ ! function ( ) {
/******/ // define getter functions for harmony exports
/******/ _ _webpack _require _ _ . d = function ( exports , definition ) {
/******/ for ( var key in definition ) {
/******/ if ( _ _webpack _require _ _ . o ( definition , key ) && ! _ _webpack _require _ _ . o ( exports , key ) ) {
/******/ Object . defineProperty ( exports , key , { enumerable : true , get : definition [ key ] } ) ;
/******/ }
/******/ }
/******/ } ;
/******/ } ( ) ;
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ ! function ( ) {
/******/ _ _webpack _require _ _ . o = function ( obj , prop ) { return Object . prototype . hasOwnProperty . call ( obj , prop ) ; }
/******/ } ( ) ;
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ ! function ( ) {
/******/ // define __esModule on exports
/******/ _ _webpack _require _ _ . r = function ( exports ) {
/******/ if ( typeof Symbol !== 'undefined' && Symbol . toStringTag ) {
/******/ Object . defineProperty ( exports , Symbol . toStringTag , { value : 'Module' } ) ;
/******/ }
/******/ Object . defineProperty ( exports , '__esModule' , { value : true } ) ;
/******/ } ;
/******/ } ( ) ;
/******/
/************************************************************************/
var _ _webpack _exports _ _ = { } ;
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
! function ( ) {
2021-05-25 10:40:25 +02:00
"use strict" ;
// ESM COMPAT FLAG
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
// EXPORTS
2022-04-11 14:04:30 +02:00
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
"MoveToWidgetArea" : function ( ) { return /* reexport */ MoveToWidgetArea ; } ,
"addWidgetIdToBlock" : function ( ) { return /* reexport */ addWidgetIdToBlock ; } ,
"getWidgetIdFromBlock" : function ( ) { return /* reexport */ getWidgetIdFromBlock ; } ,
"registerLegacyWidgetBlock" : function ( ) { return /* binding */ registerLegacyWidgetBlock ; } ,
"registerLegacyWidgetVariations" : function ( ) { return /* reexport */ registerLegacyWidgetVariations ; } ,
"registerWidgetGroupBlock" : function ( ) { return /* binding */ registerWidgetGroupBlock ; }
} ) ;
2021-06-15 10:52:30 +02:00
// NAMESPACE OBJECT: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/index.js
var legacy _widget _namespaceObject = { } ;
_ _webpack _require _ _ . r ( legacy _widget _namespaceObject ) ;
2022-04-11 14:04:30 +02:00
_ _webpack _require _ _ . d ( legacy _widget _namespaceObject , {
"metadata" : function ( ) { return metadata ; } ,
"name" : function ( ) { return legacy _widget _name ; } ,
"settings" : function ( ) { return settings ; }
} ) ;
2021-06-15 10:52:30 +02:00
2021-11-08 15:29:21 +01:00
// NAMESPACE OBJECT: ./node_modules/@wordpress/widgets/build-module/blocks/widget-group/index.js
var widget _group _namespaceObject = { } ;
_ _webpack _require _ _ . r ( widget _group _namespaceObject ) ;
2022-04-11 14:04:30 +02:00
_ _webpack _require _ _ . d ( widget _group _namespaceObject , {
"metadata" : function ( ) { return widget _group _metadata ; } ,
"name" : function ( ) { return widget _group _name ; } ,
"settings" : function ( ) { return widget _group _settings ; }
} ) ;
2021-06-15 10:52:30 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","blocks"]
var external _wp _blocks _namespaceObject = window [ "wp" ] [ "blocks" ] ;
; // CONCATENATED MODULE: external ["wp","element"]
var external _wp _element _namespaceObject = window [ "wp" ] [ "element" ] ;
; // CONCATENATED MODULE: external ["wp","primitives"]
var external _wp _primitives _namespaceObject = window [ "wp" ] [ "primitives" ] ;
; // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/widget.js
2021-06-15 10:52:30 +02:00
/ * *
* WordPress dependencies
* /
2022-04-11 14:04:30 +02:00
const widget = ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _primitives _namespaceObject . SVG , {
2021-07-06 16:38:40 +02:00
xmlns : "http://www.w3.org/2000/svg" ,
viewBox : "0 0 24 24"
2022-04-11 14:04:30 +02:00
} , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _primitives _namespaceObject . Path , {
2021-07-06 16:38:40 +02:00
d : "M6 3H8V5H16V3H18V5C19.1046 5 20 5.89543 20 7V19C20 20.1046 19.1046 21 18 21H6C4.89543 21 4 20.1046 4 19V7C4 5.89543 4.89543 5 6 5V3ZM18 6.5H6C5.72386 6.5 5.5 6.72386 5.5 7V8H18.5V7C18.5 6.72386 18.2761 6.5 18 6.5ZM18.5 9.5H5.5V19C5.5 19.2761 5.72386 19.5 6 19.5H18C18.2761 19.5 18.5 19.2761 18.5 19V9.5ZM11 11H13V13H11V11ZM7 11V13H9V11H7ZM15 13V11H17V13H15Z"
2021-06-15 10:52:30 +02:00
} ) ) ;
2022-04-11 14:04:30 +02:00
/* harmony default export */ var library _widget = ( widget ) ;
2021-06-15 10:52:30 +02:00
// EXTERNAL MODULE: ./node_modules/classnames/index.js
2022-04-11 14:04:30 +02:00
var classnames = _ _webpack _require _ _ ( 4403 ) ;
2021-06-15 10:52:30 +02:00
var classnames _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( classnames ) ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","blockEditor"]
var external _wp _blockEditor _namespaceObject = window [ "wp" ] [ "blockEditor" ] ;
; // CONCATENATED MODULE: external ["wp","components"]
var external _wp _components _namespaceObject = window [ "wp" ] [ "components" ] ;
; // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/brush.js
2021-06-15 10:52:30 +02:00
/ * *
* WordPress dependencies
* /
2022-04-11 14:04:30 +02:00
const brush = ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _primitives _namespaceObject . SVG , {
2021-06-15 10:52:30 +02:00
xmlns : "http://www.w3.org/2000/svg" ,
viewBox : "0 0 24 24"
2022-04-11 14:04:30 +02:00
} , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _primitives _namespaceObject . Path , {
2021-06-15 10:52:30 +02:00
d : "M4 20h8v-1.5H4V20zM18.9 3.5c-.6-.6-1.5-.6-2.1 0l-7.2 7.2c-.4-.1-.7 0-1.1.1-.5.2-1.5.7-1.9 2.2-.4 1.7-.8 2.2-1.1 2.7-.1.1-.2.3-.3.4l-.6 1.1H6c2 0 3.4-.4 4.7-1.4.8-.6 1.2-1.4 1.3-2.3 0-.3 0-.5-.1-.7L19 5.7c.5-.6.5-1.6-.1-2.2zM9.7 14.7c-.7.5-1.5.8-2.4 1 .2-.5.5-1.2.8-2.3.2-.6.4-1 .8-1.1.5-.1 1 .1 1.3.3.2.2.3.5.2.8 0 .3-.1.9-.7 1.3z"
} ) ) ;
/* harmony default export */ var library _brush = ( brush ) ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","i18n"]
var external _wp _i18n _namespaceObject = window [ "wp" ] [ "i18n" ] ;
; // CONCATENATED MODULE: external ["wp","data"]
var external _wp _data _namespaceObject = window [ "wp" ] [ "data" ] ;
; // CONCATENATED MODULE: external ["wp","coreData"]
var external _wp _coreData _namespaceObject = window [ "wp" ] [ "coreData" ] ;
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/widget-type-selector.js
2021-06-15 10:52:30 +02:00
/ * *
* WordPress dependencies
* /
2021-11-15 13:50:17 +01:00
function WidgetTypeSelector ( _ref ) {
let {
selectedId ,
onSelect
} = _ref ;
2022-04-11 14:04:30 +02:00
const widgetTypes = ( 0 , external _wp _data _namespaceObject . useSelect ) ( select => {
2021-06-15 10:52:30 +02:00
var _select$getSettings$w , _select$getSettings , _select$getWidgetType ;
2022-04-11 14:04:30 +02:00
const hiddenIds = ( _select$getSettings$w = ( _select$getSettings = select ( external _wp _blockEditor _namespaceObject . store ) . getSettings ( ) ) === null || _select$getSettings === void 0 ? void 0 : _select$getSettings . widgetTypesToHideFromLegacyWidgetBlock ) !== null && _select$getSettings$w !== void 0 ? _select$getSettings$w : [ ] ;
return ( _select$getWidgetType = select ( external _wp _coreData _namespaceObject . store ) . getWidgetTypes ( {
2021-06-15 10:52:30 +02:00
per _page : - 1
} ) ) === null || _select$getWidgetType === void 0 ? void 0 : _select$getWidgetType . filter ( widgetType => ! hiddenIds . includes ( widgetType . id ) ) ;
} , [ ] ) ;
if ( ! widgetTypes ) {
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Spinner , null ) ;
2021-06-15 10:52:30 +02:00
}
if ( widgetTypes . length === 0 ) {
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'There are no widgets available.' ) ;
2021-06-15 10:52:30 +02:00
}
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . SelectControl , {
2023-02-07 08:04:52 +01:00
_ _nextHasNoMarginBottom : true ,
2022-04-11 14:04:30 +02:00
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Select a legacy widget to display:' ) ,
2021-06-15 10:52:30 +02:00
value : selectedId !== null && selectedId !== void 0 ? selectedId : '' ,
options : [ {
value : '' ,
2022-04-11 14:04:30 +02:00
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Select widget' )
2021-06-15 10:52:30 +02:00
} , ... widgetTypes . map ( widgetType => ( {
value : widgetType . id ,
label : widgetType . name
} ) ) ] ,
onChange : value => {
if ( value ) {
const selected = widgetTypes . find ( widgetType => widgetType . id === value ) ;
onSelect ( {
selectedId : selected . id ,
isMulti : selected . is _multi
} ) ;
} else {
onSelect ( {
selectedId : null
} ) ;
}
}
} ) ;
}
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/inspector-card.js
2021-06-15 10:52:30 +02:00
2021-11-15 13:50:17 +01:00
function InspectorCard ( _ref ) {
let {
name ,
description
} = _ref ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( "div" , {
2021-06-15 10:52:30 +02:00
className : "wp-block-legacy-widget-inspector-card"
2022-04-11 14:04:30 +02:00
} , ( 0 , external _wp _element _namespaceObject . createElement ) ( "h3" , {
2021-06-15 10:52:30 +02:00
className : "wp-block-legacy-widget-inspector-card__name"
2022-04-11 14:04:30 +02:00
} , name ) , ( 0 , external _wp _element _namespaceObject . createElement ) ( "span" , null , description ) ) ;
2021-06-15 10:52:30 +02:00
}
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","notices"]
var external _wp _notices _namespaceObject = window [ "wp" ] [ "notices" ] ;
; // CONCATENATED MODULE: external ["wp","compose"]
var external _wp _compose _namespaceObject = window [ "wp" ] [ "compose" ] ;
; // CONCATENATED MODULE: external ["wp","apiFetch"]
var external _wp _apiFetch _namespaceObject = window [ "wp" ] [ "apiFetch" ] ;
var external _wp _apiFetch _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _wp _apiFetch _namespaceObject ) ;
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/control.js
2021-06-15 10:52:30 +02:00
/ * *
* WordPress dependencies
* /
/ * *
* An API for creating and loading a widget control ( a < div class = "widget" >
* element ) that is compatible with most third party widget scripts . By not
* using React for this , we ensure that we have complete contorl over the DOM
* and do not accidentally remove any elements that a third party widget script
* has attached an event listener to .
*
* @ property { Element } element The control ' s DOM element .
* /
2022-04-11 14:04:30 +02:00
class Control {
2021-06-15 10:52:30 +02:00
/ * *
* Creates and loads a new control .
*
* @ access public
2021-11-08 15:29:21 +01:00
* @ param { Object } params
* @ param { string } params . id
* @ param { string } params . idBase
* @ param { Object } params . instance
2021-06-15 10:52:30 +02:00
* @ param { Function } params . onChangeInstance
* @ param { Function } params . onChangeHasPreview
* @ param { Function } params . onError
* /
2021-11-15 13:50:17 +01:00
constructor ( _ref ) {
let {
id ,
idBase ,
instance ,
onChangeInstance ,
onChangeHasPreview ,
onError
} = _ref ;
2021-06-15 10:52:30 +02:00
this . id = id ;
this . idBase = idBase ;
this . _instance = instance ;
this . _hasPreview = null ;
this . onChangeInstance = onChangeInstance ;
this . onChangeHasPreview = onChangeHasPreview ;
this . onError = onError ; // We can't use the real widget number as this is calculated by the
// server and we may not ever *actually* save this widget. Instead, use
// a fake but unique number.
this . number = ++ lastNumber ;
2023-02-07 08:04:52 +01:00
this . handleFormChange = ( 0 , external _wp _compose _namespaceObject . debounce ) ( this . handleFormChange . bind ( this ) , 200 ) ;
2021-06-15 10:52:30 +02:00
this . handleFormSubmit = this . handleFormSubmit . bind ( this ) ;
this . initDOM ( ) ;
this . bindEvents ( ) ;
this . loadContent ( ) ;
}
/ * *
* Clean up the control so that it can be garabge collected .
*
* @ access public
* /
destroy ( ) {
this . unbindEvents ( ) ;
this . element . remove ( ) ; // TODO: How do we make third party widget scripts remove their event
// listeners?
}
/ * *
* Creates the control ' s DOM structure .
*
* @ access private
* /
initDOM ( ) {
var _this$id , _this$idBase ;
this . element = el ( 'div' , {
class : 'widget open'
} , [ el ( 'div' , {
class : 'widget-inside'
} , [ this . form = el ( 'form' , {
class : 'form' ,
method : 'post'
} , [ // These hidden form inputs are what most widgets' scripts
// use to access data about the widget.
el ( 'input' , {
class : 'widget-id' ,
type : 'hidden' ,
name : 'widget-id' ,
value : ( _this$id = this . id ) !== null && _this$id !== void 0 ? _this$id : ` ${ this . idBase } - ${ this . number } `
} ) , el ( 'input' , {
class : 'id_base' ,
type : 'hidden' ,
name : 'id_base' ,
value : ( _this$idBase = this . idBase ) !== null && _this$idBase !== void 0 ? _this$idBase : this . id
} ) , el ( 'input' , {
class : 'widget-width' ,
type : 'hidden' ,
name : 'widget-width' ,
value : '250'
} ) , el ( 'input' , {
class : 'widget-height' ,
type : 'hidden' ,
name : 'widget-height' ,
value : '200'
} ) , el ( 'input' , {
class : 'widget_number' ,
type : 'hidden' ,
name : 'widget_number' ,
value : this . idBase ? this . number . toString ( ) : ''
} ) , this . content = el ( 'div' , {
class : 'widget-content'
} ) , // Non-multi widgets can be saved via a Save button.
this . id && el ( 'button' , {
class : 'button is-primary' ,
type : 'submit'
2022-04-11 14:04:30 +02:00
} , ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Save' ) ) ] ) ] ) ] ) ;
2021-06-15 10:52:30 +02:00
}
/ * *
* Adds the control ' s event listeners .
*
* @ access private
* /
bindEvents ( ) {
// Prefer jQuery 'change' event instead of the native 'change' event
// because many widgets use jQuery's event bus to trigger an update.
if ( window . jQuery ) {
const {
jQuery : $
} = window ;
$ ( this . form ) . on ( 'change' , null , this . handleFormChange ) ;
$ ( this . form ) . on ( 'input' , null , this . handleFormChange ) ;
$ ( this . form ) . on ( 'submit' , this . handleFormSubmit ) ;
} else {
this . form . addEventListener ( 'change' , this . handleFormChange ) ;
this . form . addEventListener ( 'input' , this . handleFormChange ) ;
this . form . addEventListener ( 'submit' , this . handleFormSubmit ) ;
}
}
/ * *
* Removes the control ' s event listeners .
*
* @ access private
* /
unbindEvents ( ) {
if ( window . jQuery ) {
const {
jQuery : $
} = window ;
$ ( this . form ) . off ( 'change' , null , this . handleFormChange ) ;
$ ( this . form ) . off ( 'input' , null , this . handleFormChange ) ;
$ ( this . form ) . off ( 'submit' , this . handleFormSubmit ) ;
} else {
this . form . removeEventListener ( 'change' , this . handleFormChange ) ;
this . form . removeEventListener ( 'input' , this . handleFormChange ) ;
this . form . removeEventListener ( 'submit' , this . handleFormSubmit ) ;
}
}
/ * *
* Fetches the widget ' s form HTML from the REST API and loads it into the
* control ' s form .
*
* @ access private
* /
async loadContent ( ) {
try {
if ( this . id ) {
const {
form
} = await saveWidget ( this . id ) ;
this . content . innerHTML = form ;
} else if ( this . idBase ) {
const {
form ,
preview
} = await encodeWidget ( {
idBase : this . idBase ,
instance : this . instance ,
number : this . number
} ) ;
this . content . innerHTML = form ;
this . hasPreview = ! isEmptyHTML ( preview ) ; // If we don't have an instance, perform a save right away. This
// happens when creating a new Legacy Widget block.
if ( ! this . instance . hash ) {
const {
instance
} = await encodeWidget ( {
idBase : this . idBase ,
instance : this . instance ,
number : this . number ,
formData : serializeForm ( this . form )
} ) ;
this . instance = instance ;
}
} // Trigger 'widget-added' when widget is ready. This event is what
// widgets' scripts use to initialize, attach events, etc. The event
// must be fired using jQuery's event bus as this is what widget
// scripts expect. If jQuery is not loaded, do nothing - some
// widgets will still work regardless.
if ( window . jQuery ) {
const {
jQuery : $
} = window ;
$ ( document ) . trigger ( 'widget-added' , [ $ ( this . element ) ] ) ;
}
} catch ( error ) {
this . onError ( error ) ;
}
}
2021-06-28 18:01:36 +02:00
/ * *
* Perform a save when a multi widget ' s form is changed . Non - multi widgets
* are saved manually .
*
* @ access private
* /
handleFormChange ( ) {
if ( this . idBase ) {
this . saveForm ( ) ;
}
}
2021-06-15 10:52:30 +02:00
/ * *
* Perform a save when the control ' s form is manually submitted .
*
* @ access private
* @ param { Event } event
* /
handleFormSubmit ( event ) {
event . preventDefault ( ) ;
this . saveForm ( ) ;
}
/ * *
* Serialize the control ' s form , send it to the REST API , and update the
* instance with the encoded instance that the REST API returns .
*
* @ access private
* /
async saveForm ( ) {
const formData = serializeForm ( this . form ) ;
try {
if ( this . id ) {
const {
form
} = await saveWidget ( this . id , formData ) ;
this . content . innerHTML = form ;
if ( window . jQuery ) {
const {
jQuery : $
} = window ;
$ ( document ) . trigger ( 'widget-updated' , [ $ ( this . element ) ] ) ;
}
} else if ( this . idBase ) {
const {
instance ,
preview
} = await encodeWidget ( {
idBase : this . idBase ,
instance : this . instance ,
number : this . number ,
formData
} ) ;
this . instance = instance ;
this . hasPreview = ! isEmptyHTML ( preview ) ;
}
} catch ( error ) {
this . onError ( error ) ;
}
}
/ * *
* The widget ' s instance object .
*
* @ access private
* /
get instance ( ) {
return this . _instance ;
}
/ * *
* The widget ' s instance object .
*
* @ access private
* /
set instance ( instance ) {
if ( this . _instance !== instance ) {
this . _instance = instance ;
this . onChangeInstance ( instance ) ;
}
}
/ * *
* Whether or not the widget can be previewed .
*
* @ access public
* /
get hasPreview ( ) {
return this . _hasPreview ;
}
/ * *
* Whether or not the widget can be previewed .
*
* @ access private
* /
set hasPreview ( hasPreview ) {
if ( this . _hasPreview !== hasPreview ) {
this . _hasPreview = hasPreview ;
this . onChangeHasPreview ( hasPreview ) ;
}
}
}
let lastNumber = 0 ;
2021-11-15 13:50:17 +01:00
function el ( tagName ) {
let attributes = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : { } ;
let content = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : null ;
2021-06-15 10:52:30 +02:00
const element = document . createElement ( tagName ) ;
for ( const [ attribute , value ] of Object . entries ( attributes ) ) {
element . setAttribute ( attribute , value ) ;
}
if ( Array . isArray ( content ) ) {
for ( const child of content ) {
if ( child ) {
element . appendChild ( child ) ;
}
}
} else if ( typeof content === 'string' ) {
element . innerText = content ;
}
return element ;
}
2021-11-15 13:50:17 +01:00
async function saveWidget ( id ) {
let formData = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : null ;
2021-06-15 10:52:30 +02:00
let widget ;
if ( formData ) {
widget = await external _wp _apiFetch _default ( ) ( {
path : ` /wp/v2/widgets/ ${ id } ?context=edit ` ,
method : 'PUT' ,
data : {
form _data : formData
}
} ) ;
} else {
widget = await external _wp _apiFetch _default ( ) ( {
path : ` /wp/v2/widgets/ ${ id } ?context=edit ` ,
method : 'GET'
} ) ;
}
return {
form : widget . rendered _form
} ;
}
2021-11-15 13:50:17 +01:00
async function encodeWidget ( _ref2 ) {
let {
idBase ,
instance ,
number ,
formData = null
} = _ref2 ;
2021-06-15 10:52:30 +02:00
const response = await external _wp _apiFetch _default ( ) ( {
path : ` /wp/v2/widget-types/ ${ idBase } /encode ` ,
method : 'POST' ,
data : {
instance ,
number ,
form _data : formData
}
} ) ;
return {
instance : response . instance ,
form : response . form ,
preview : response . preview
} ;
}
function isEmptyHTML ( html ) {
const element = document . createElement ( 'div' ) ;
element . innerHTML = html ;
2021-06-15 17:30:24 +02:00
return isEmptyNode ( element ) ;
}
function isEmptyNode ( node ) {
switch ( node . nodeType ) {
case node . TEXT _NODE :
// Text nodes are empty if it's entirely whitespace.
return node . nodeValue . trim ( ) === '' ;
case node . ELEMENT _NODE :
// Elements that are "embedded content" are not empty.
// https://dev.w3.org/html5/spec-LC/content-models.html#embedded-content-0
if ( [ 'AUDIO' , 'CANVAS' , 'EMBED' , 'IFRAME' , 'IMG' , 'MATH' , 'OBJECT' , 'SVG' , 'VIDEO' ] . includes ( node . tagName ) ) {
return false ;
} // Elements with no children are empty.
if ( ! node . hasChildNodes ( ) ) {
return true ;
} // Elements with children are empty if all their children are empty.
return Array . from ( node . childNodes ) . every ( isEmptyNode ) ;
default :
return true ;
}
2021-06-15 10:52:30 +02:00
}
function serializeForm ( form ) {
return new window . URLSearchParams ( Array . from ( new window . FormData ( form ) ) ) . toString ( ) ;
}
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/form.js
2021-06-15 10:52:30 +02:00
/ * *
* External dependencies
* /
/ * *
* WordPress dependencies
* /
/ * *
* Internal dependencies
* /
2021-11-15 13:50:17 +01:00
function Form ( _ref ) {
let {
title ,
isVisible ,
id ,
idBase ,
instance ,
isWide ,
onChangeInstance ,
onChangeHasPreview
} = _ref ;
2022-04-11 14:04:30 +02:00
const ref = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
const isMediumLargeViewport = ( 0 , external _wp _compose _namespaceObject . useViewportMatch ) ( 'small' ) ; // We only want to remount the control when the instance changes
2021-06-15 10:52:30 +02:00
// *externally*. For example, if the user performs an undo. To do this, we
// keep track of changes made to instance by the control itself and then
// ignore those.
2022-04-11 14:04:30 +02:00
const outgoingInstances = ( 0 , external _wp _element _namespaceObject . useRef ) ( new Set ( ) ) ;
const incomingInstances = ( 0 , external _wp _element _namespaceObject . useRef ) ( new Set ( ) ) ;
2021-06-15 10:52:30 +02:00
const {
createNotice
2022-04-11 14:04:30 +02:00
} = ( 0 , external _wp _data _namespaceObject . useDispatch ) ( external _wp _notices _namespaceObject . store ) ;
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
2021-06-15 10:52:30 +02:00
if ( incomingInstances . current . has ( instance ) ) {
incomingInstances . current . delete ( instance ) ;
return ;
}
2022-04-11 14:04:30 +02:00
const control = new Control ( {
2021-06-15 10:52:30 +02:00
id ,
idBase ,
instance ,
onChangeInstance ( nextInstance ) {
outgoingInstances . current . add ( instance ) ;
incomingInstances . current . add ( nextInstance ) ;
onChangeInstance ( nextInstance ) ;
} ,
onChangeHasPreview ,
onError ( error ) {
2021-07-06 16:38:40 +02:00
window . console . error ( error ) ;
2022-04-11 14:04:30 +02:00
createNotice ( 'error' , ( 0 , external _wp _i18n _namespaceObject . sprintf ) (
2021-07-06 16:38:40 +02:00
/* translators: %s: the name of the affected block. */
2022-04-11 14:04:30 +02:00
( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'The "%s" block was affected by errors and may not function properly. Check the developer tools for more details.' ) , idBase || id ) ) ;
2021-06-15 10:52:30 +02:00
}
} ) ;
ref . current . appendChild ( control . element ) ;
return ( ) => {
if ( outgoingInstances . current . has ( instance ) ) {
outgoingInstances . current . delete ( instance ) ;
return ;
}
control . destroy ( ) ;
} ;
} , [ id , idBase , instance , onChangeInstance , onChangeHasPreview , isMediumLargeViewport ] ) ;
if ( isWide && isMediumLargeViewport ) {
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( "div" , {
2021-06-15 10:52:30 +02:00
className : classnames _default ( ) ( {
'wp-block-legacy-widget__container' : isVisible
} )
2022-04-11 14:04:30 +02:00
} , isVisible && ( 0 , external _wp _element _namespaceObject . createElement ) ( "h3" , {
2021-06-15 10:52:30 +02:00
className : "wp-block-legacy-widget__edit-form-title"
2022-04-11 14:04:30 +02:00
} , title ) , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Popover , {
2021-06-15 10:52:30 +02:00
focusOnMount : false ,
2022-09-20 17:43:29 +02:00
placement : "right" ,
offset : 32 ,
resize : false ,
flip : false ,
shift : true
2022-04-11 14:04:30 +02:00
} , ( 0 , external _wp _element _namespaceObject . createElement ) ( "div" , {
2021-06-15 10:52:30 +02:00
ref : ref ,
className : "wp-block-legacy-widget__edit-form" ,
hidden : ! isVisible
} ) ) ) ;
}
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( "div" , {
2021-06-15 10:52:30 +02:00
ref : ref ,
className : "wp-block-legacy-widget__edit-form" ,
hidden : ! isVisible
2022-04-11 14:04:30 +02:00
} , ( 0 , external _wp _element _namespaceObject . createElement ) ( "h3" , {
2021-06-15 10:52:30 +02:00
className : "wp-block-legacy-widget__edit-form-title"
} , title ) ) ;
}
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/preview.js
2021-06-15 10:52:30 +02:00
/ * *
* External dependencies
* /
/ * *
* WordPress dependencies
* /
2021-11-15 13:50:17 +01:00
function Preview ( _ref ) {
let {
idBase ,
instance ,
isVisible
} = _ref ;
2022-04-11 14:04:30 +02:00
const [ isLoaded , setIsLoaded ] = ( 0 , external _wp _element _namespaceObject . useState ) ( false ) ;
const [ srcDoc , setSrcDoc ] = ( 0 , external _wp _element _namespaceObject . useState ) ( '' ) ;
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
2021-11-08 15:29:21 +01:00
const abortController = typeof window . AbortController === 'undefined' ? undefined : new window . AbortController ( ) ;
async function fetchPreviewHTML ( ) {
const restRoute = ` /wp/v2/widget-types/ ${ idBase } /render ` ;
return await external _wp _apiFetch _default ( ) ( {
path : restRoute ,
method : 'POST' ,
signal : abortController === null || abortController === void 0 ? void 0 : abortController . signal ,
data : instance ? {
instance
} : { }
} ) ;
}
fetchPreviewHTML ( ) . then ( response => {
setSrcDoc ( response . preview ) ;
} ) . catch ( error => {
if ( 'AbortError' === error . name ) {
// We don't want to log aborted requests.
return ;
}
throw error ;
} ) ;
return ( ) => abortController === null || abortController === void 0 ? void 0 : abortController . abort ( ) ;
} , [ idBase , instance ] ) ; // Resize the iframe on either the load event, or when the iframe becomes visible.
2021-06-15 10:52:30 +02:00
2022-04-11 14:04:30 +02:00
const ref = ( 0 , external _wp _compose _namespaceObject . useRefEffect ) ( iframe => {
2021-07-06 16:38:40 +02:00
// Only set height if the iframe is loaded,
// or it will grow to an unexpected large height in Safari if it's hidden initially.
2021-11-08 15:29:21 +01:00
if ( ! isLoaded ) {
return ;
} // If the preview frame has another origin then this won't work.
// One possible solution is to add custom script to call `postMessage` in the preview frame.
// Or, better yet, we migrate away from iframe.
2021-06-15 10:52:30 +02:00
2021-11-08 15:29:21 +01:00
function setHeight ( ) {
2023-02-07 08:04:52 +01:00
var _iframe$contentDocume , _iframe$contentDocume2 , _iframe$contentDocume3 , _iframe$contentDocume4 ;
2021-11-08 15:29:21 +01:00
// Pick the maximum of these two values to account for margin collapsing.
2023-02-07 08:04:52 +01:00
const height = Math . max ( ( _iframe$contentDocume = ( _iframe$contentDocume2 = iframe . contentDocument . documentElement ) === null || _iframe$contentDocume2 === void 0 ? void 0 : _iframe$contentDocume2 . offsetHeight ) !== null && _iframe$contentDocume !== void 0 ? _iframe$contentDocume : 0 , ( _iframe$contentDocume3 = ( _iframe$contentDocume4 = iframe . contentDocument . body ) === null || _iframe$contentDocume4 === void 0 ? void 0 : _iframe$contentDocume4 . offsetHeight ) !== null && _iframe$contentDocume3 !== void 0 ? _iframe$contentDocume3 : 0 ) ; // Fallback to a height of 100px if the height cannot be determined.
// This ensures the block is still selectable. 100px should hopefully
// be not so big that it's annoying, and not so small that nothing
// can be seen.
iframe . style . height = ` ${ height !== 0 ? height : 100 } px ` ;
2021-07-06 16:38:40 +02:00
}
2021-11-08 15:29:21 +01:00
const {
IntersectionObserver
} = iframe . ownerDocument . defaultView ; // Observe for intersections that might cause a change in the height of
// the iframe, e.g. a Widget Area becoming expanded.
2021-11-15 13:50:17 +01:00
const intersectionObserver = new IntersectionObserver ( _ref2 => {
let [ entry ] = _ref2 ;
2021-11-08 15:29:21 +01:00
if ( entry . isIntersecting ) {
setHeight ( ) ;
}
} , {
threshold : 1
} ) ;
intersectionObserver . observe ( iframe ) ;
iframe . addEventListener ( 'load' , setHeight ) ;
return ( ) => {
intersectionObserver . disconnect ( ) ;
iframe . removeEventListener ( 'load' , setHeight ) ;
} ;
2021-07-06 16:38:40 +02:00
} , [ isLoaded ] ) ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _element _namespaceObject . Fragment , null , isVisible && ! isLoaded && ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Placeholder , null , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Spinner , null ) ) , ( 0 , external _wp _element _namespaceObject . createElement ) ( "div" , {
2021-06-15 10:52:30 +02:00
className : classnames _default ( ) ( 'wp-block-legacy-widget__edit-preview' , {
2021-07-06 16:38:40 +02:00
'is-offscreen' : ! isVisible || ! isLoaded
2021-06-15 10:52:30 +02:00
} )
2022-04-11 14:04:30 +02:00
} , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Disabled , null , ( 0 , external _wp _element _namespaceObject . createElement ) ( "iframe" , {
2021-06-15 10:52:30 +02:00
ref : ref ,
className : "wp-block-legacy-widget__edit-preview-iframe" ,
2021-11-08 15:29:21 +01:00
tabIndex : "-1" ,
2022-04-11 14:04:30 +02:00
title : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Legacy Widget Preview' ) ,
2021-11-08 15:29:21 +01:00
srcDoc : srcDoc ,
2021-07-06 16:38:40 +02:00
onLoad : event => {
// To hide the scrollbars of the preview frame for some edge cases,
// such as negative margins in the Gallery Legacy Widget.
// It can't be scrolled anyway.
// TODO: Ideally, this should be fixed in core.
event . target . contentDocument . body . style . overflow = 'hidden' ;
setIsLoaded ( true ) ;
} ,
height : 100
2021-06-15 10:52:30 +02:00
} ) ) ) ) ;
}
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/no-preview.js
2021-06-15 10:52:30 +02:00
/ * *
* WordPress dependencies
* /
2021-11-15 13:50:17 +01:00
function NoPreview ( _ref ) {
let {
name
} = _ref ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( "div" , {
2021-06-15 10:52:30 +02:00
className : "wp-block-legacy-widget__edit-no-preview"
2022-04-11 14:04:30 +02:00
} , name && ( 0 , external _wp _element _namespaceObject . createElement ) ( "h3" , null , name ) , ( 0 , external _wp _element _namespaceObject . createElement ) ( "p" , null , ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'No preview available.' ) ) ) ;
2021-06-15 10:52:30 +02:00
}
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/convert-to-blocks-button.js
2021-06-15 10:52:30 +02:00
/ * *
* WordPress dependencies
* /
2021-11-15 13:50:17 +01:00
function ConvertToBlocksButton ( _ref ) {
let {
clientId ,
rawInstance
} = _ref ;
2021-06-15 10:52:30 +02:00
const {
replaceBlocks
2022-04-11 14:04:30 +02:00
} = ( 0 , external _wp _data _namespaceObject . useDispatch ) ( external _wp _blockEditor _namespaceObject . store ) ;
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . ToolbarButton , {
2021-06-15 10:52:30 +02:00
onClick : ( ) => {
if ( rawInstance . title ) {
2022-04-11 14:04:30 +02:00
replaceBlocks ( clientId , [ ( 0 , external _wp _blocks _namespaceObject . createBlock ) ( 'core/heading' , {
2021-06-15 10:52:30 +02:00
content : rawInstance . title
2022-04-11 14:04:30 +02:00
} ) , ... ( 0 , external _wp _blocks _namespaceObject . rawHandler ) ( {
2021-06-15 10:52:30 +02:00
HTML : rawInstance . text
} ) ] ) ;
} else {
2022-04-11 14:04:30 +02:00
replaceBlocks ( clientId , ( 0 , external _wp _blocks _namespaceObject . rawHandler ) ( {
2021-06-15 10:52:30 +02:00
HTML : rawInstance . text
} ) ) ;
}
}
2022-04-11 14:04:30 +02:00
} , ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Convert to blocks' ) ) ;
2021-06-15 10:52:30 +02:00
}
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/index.js
2021-06-15 10:52:30 +02:00
/ * *
* External dependencies
* /
/ * *
* WordPress dependencies
* /
/ * *
* Internal dependencies
* /
function Edit ( props ) {
const {
id ,
idBase
} = props . attributes ;
const {
isWide = false
} = props ;
2022-04-11 14:04:30 +02:00
const blockProps = ( 0 , external _wp _blockEditor _namespaceObject . useBlockProps ) ( {
2021-06-15 10:52:30 +02:00
className : classnames _default ( ) ( {
'is-wide-widget' : isWide
} )
} ) ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( "div" , blockProps , ! id && ! idBase ? ( 0 , external _wp _element _namespaceObject . createElement ) ( Empty , props ) : ( 0 , external _wp _element _namespaceObject . createElement ) ( NotEmpty , props ) ) ;
2021-06-15 10:52:30 +02:00
}
2021-11-15 13:50:17 +01:00
function Empty ( _ref ) {
let {
attributes : {
id ,
idBase
} ,
setAttributes
} = _ref ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Placeholder , {
icon : ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _blockEditor _namespaceObject . BlockIcon , {
2021-06-15 10:52:30 +02:00
icon : library _brush
} ) ,
2022-04-11 14:04:30 +02:00
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Legacy Widget' )
2023-02-07 08:04:52 +01:00
} , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Flex , null , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . FlexBlock , null , ( 0 , external _wp _element _namespaceObject . createElement ) ( WidgetTypeSelector , {
2021-06-15 10:52:30 +02:00
selectedId : id !== null && id !== void 0 ? id : idBase ,
2021-11-15 13:50:17 +01:00
onSelect : _ref2 => {
let {
selectedId ,
isMulti
} = _ref2 ;
2021-06-15 10:52:30 +02:00
if ( ! selectedId ) {
setAttributes ( {
id : null ,
idBase : null ,
instance : null
} ) ;
} else if ( isMulti ) {
setAttributes ( {
id : null ,
idBase : selectedId ,
instance : { }
} ) ;
} else {
setAttributes ( {
id : selectedId ,
idBase : null ,
instance : null
} ) ;
}
}
2023-02-07 08:04:52 +01:00
} ) ) ) ) ;
2021-06-15 10:52:30 +02:00
}
2021-11-15 13:50:17 +01:00
function NotEmpty ( _ref3 ) {
let {
attributes : {
id ,
idBase ,
instance
} ,
setAttributes ,
clientId ,
isSelected ,
isWide = false
} = _ref3 ;
2022-04-11 14:04:30 +02:00
const [ hasPreview , setHasPreview ] = ( 0 , external _wp _element _namespaceObject . useState ) ( null ) ;
2022-04-12 17:12:47 +02:00
const widgetTypeId = id !== null && id !== void 0 ? id : idBase ;
2021-06-15 10:52:30 +02:00
const {
2022-04-12 17:12:47 +02:00
record : widgetType ,
hasResolved : hasResolvedWidgetType
2022-09-20 17:43:29 +02:00
} = ( 0 , external _wp _coreData _namespaceObject . useEntityRecord ) ( 'root' , 'widgetType' , widgetTypeId ) ;
2022-04-12 17:12:47 +02:00
const isNavigationMode = ( 0 , external _wp _data _namespaceObject . useSelect ) ( select => select ( external _wp _blockEditor _namespaceObject . store ) . isNavigationMode ( ) , [ ] ) ;
2022-04-11 14:04:30 +02:00
const setInstance = ( 0 , external _wp _element _namespaceObject . useCallback ) ( nextInstance => {
2021-06-15 10:52:30 +02:00
setAttributes ( {
instance : nextInstance
} ) ;
} , [ ] ) ;
if ( ! widgetType && hasResolvedWidgetType ) {
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Placeholder , {
icon : ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _blockEditor _namespaceObject . BlockIcon , {
2021-06-15 10:52:30 +02:00
icon : library _brush
} ) ,
2022-04-11 14:04:30 +02:00
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Legacy Widget' )
} , ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Widget is missing.' ) ) ;
2021-06-15 10:52:30 +02:00
}
if ( ! hasResolvedWidgetType ) {
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Placeholder , null , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Spinner , null ) ) ;
2021-06-15 10:52:30 +02:00
}
2021-06-28 18:01:36 +02:00
const mode = idBase && ( isNavigationMode || ! isSelected ) ? 'preview' : 'edit' ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _element _namespaceObject . Fragment , null , idBase === 'text' && ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _blockEditor _namespaceObject . BlockControls , {
2021-06-15 10:52:30 +02:00
group : "other"
2022-04-11 14:04:30 +02:00
} , ( 0 , external _wp _element _namespaceObject . createElement ) ( ConvertToBlocksButton , {
2021-06-15 10:52:30 +02:00
clientId : clientId ,
rawInstance : instance . raw
2022-04-11 14:04:30 +02:00
} ) ) , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _blockEditor _namespaceObject . InspectorControls , null , ( 0 , external _wp _element _namespaceObject . createElement ) ( InspectorCard , {
2021-06-15 10:52:30 +02:00
name : widgetType . name ,
description : widgetType . description
2022-04-11 14:04:30 +02:00
} ) ) , ( 0 , external _wp _element _namespaceObject . createElement ) ( Form , {
2021-06-15 10:52:30 +02:00
title : widgetType . name ,
isVisible : mode === 'edit' ,
id : id ,
idBase : idBase ,
instance : instance ,
isWide : isWide ,
onChangeInstance : setInstance ,
onChangeHasPreview : setHasPreview
2022-04-11 14:04:30 +02:00
} ) , idBase && ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _element _namespaceObject . Fragment , null , hasPreview === null && mode === 'preview' && ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Placeholder , null , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Spinner , null ) ) , hasPreview === true && ( 0 , external _wp _element _namespaceObject . createElement ) ( Preview , {
2021-06-15 10:52:30 +02:00
idBase : idBase ,
instance : instance ,
isVisible : mode === 'preview'
2022-04-11 14:04:30 +02:00
} ) , hasPreview === false && mode === 'preview' && ( 0 , external _wp _element _namespaceObject . createElement ) ( NoPreview , {
2021-06-15 10:52:30 +02:00
name : widgetType . name
} ) ) ) ;
}
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/transforms.js
2021-06-15 10:52:30 +02:00
/ * *
* WordPress dependencies
* /
const legacyWidgetTransforms = [ {
block : 'core/calendar' ,
widget : 'calendar'
} , {
block : 'core/search' ,
widget : 'search'
} , {
block : 'core/html' ,
2021-06-22 12:00:50 +02:00
widget : 'custom_html' ,
2021-11-15 13:50:17 +01:00
transform : _ref => {
let {
content
} = _ref ;
return {
content
} ;
}
2021-06-15 10:52:30 +02:00
} , {
block : 'core/archives' ,
widget : 'archives' ,
2021-11-15 13:50:17 +01:00
transform : _ref2 => {
let {
count ,
dropdown
} = _ref2 ;
2021-06-15 10:52:30 +02:00
return {
displayAsDropdown : ! ! dropdown ,
showPostCounts : ! ! count
} ;
}
} , {
block : 'core/latest-posts' ,
widget : 'recent-posts' ,
2021-11-15 13:50:17 +01:00
transform : _ref3 => {
let {
show _date : displayPostDate ,
number
} = _ref3 ;
2021-06-15 10:52:30 +02:00
return {
displayPostDate : ! ! displayPostDate ,
postsToShow : number
} ;
}
} , {
block : 'core/latest-comments' ,
widget : 'recent-comments' ,
2021-11-15 13:50:17 +01:00
transform : _ref4 => {
let {
number
} = _ref4 ;
2021-06-15 10:52:30 +02:00
return {
commentsToShow : number
} ;
}
} , {
block : 'core/tag-cloud' ,
widget : 'tag_cloud' ,
2021-11-15 13:50:17 +01:00
transform : _ref5 => {
let {
taxonomy ,
count
} = _ref5 ;
2021-06-15 10:52:30 +02:00
return {
showTagCounts : ! ! count ,
taxonomy
} ;
}
} , {
block : 'core/categories' ,
widget : 'categories' ,
2021-11-15 13:50:17 +01:00
transform : _ref6 => {
let {
count ,
dropdown ,
hierarchical
} = _ref6 ;
2021-06-15 10:52:30 +02:00
return {
displayAsDropdown : ! ! dropdown ,
showPostCounts : ! ! count ,
showHierarchy : ! ! hierarchical
} ;
}
} , {
block : 'core/audio' ,
widget : 'media_audio' ,
2021-11-15 13:50:17 +01:00
transform : _ref7 => {
let {
url ,
preload ,
loop ,
attachment _id : id
} = _ref7 ;
2021-06-15 10:52:30 +02:00
return {
src : url ,
id ,
preload ,
loop
} ;
}
} , {
block : 'core/video' ,
widget : 'media_video' ,
2021-11-15 13:50:17 +01:00
transform : _ref8 => {
let {
url ,
preload ,
loop ,
attachment _id : id
} = _ref8 ;
2021-06-15 10:52:30 +02:00
return {
src : url ,
id ,
preload ,
loop
} ;
}
} , {
block : 'core/image' ,
widget : 'media_image' ,
2021-11-15 13:50:17 +01:00
transform : _ref9 => {
let {
alt ,
attachment _id : id ,
caption ,
height ,
link _classes : linkClass ,
link _rel : rel ,
link _target _blank : targetBlack ,
link _type : linkDestination ,
link _url : link ,
size : sizeSlug ,
url ,
width
} = _ref9 ;
2021-06-15 10:52:30 +02:00
return {
alt ,
caption ,
height ,
id ,
link ,
linkClass ,
linkDestination ,
linkTarget : targetBlack ? '_blank' : undefined ,
rel ,
sizeSlug ,
url ,
width
} ;
}
} , {
block : 'core/gallery' ,
widget : 'media_gallery' ,
2021-11-15 13:50:17 +01:00
transform : _ref10 => {
let {
ids ,
link _type : linkTo ,
size ,
number
} = _ref10 ;
2021-06-15 10:52:30 +02:00
return {
ids ,
columns : number ,
linkTo ,
sizeSlug : size ,
images : ids . map ( id => ( {
id
} ) )
} ;
}
} , {
block : 'core/rss' ,
widget : 'rss' ,
2021-11-15 13:50:17 +01:00
transform : _ref11 => {
let {
url ,
show _author : displayAuthor ,
show _date : displayDate ,
show _summary : displayExcerpt ,
items
} = _ref11 ;
2021-06-15 10:52:30 +02:00
return {
feedURL : url ,
displayAuthor : ! ! displayAuthor ,
displayDate : ! ! displayDate ,
displayExcerpt : ! ! displayExcerpt ,
itemsToShow : items
} ;
}
2021-11-15 13:50:17 +01:00
} ] . map ( _ref12 => {
let {
block ,
widget ,
transform
} = _ref12 ;
2021-06-15 10:52:30 +02:00
return {
type : 'block' ,
blocks : [ block ] ,
2021-11-15 13:50:17 +01:00
isMatch : _ref13 => {
let {
idBase ,
instance
} = _ref13 ;
2021-06-15 10:52:30 +02:00
return idBase === widget && ! ! ( instance !== null && instance !== void 0 && instance . raw ) ;
} ,
2021-11-15 13:50:17 +01:00
transform : _ref14 => {
2021-06-15 10:52:30 +02:00
var _instance$raw ;
2021-11-15 13:50:17 +01:00
let {
instance
} = _ref14 ;
2022-04-11 14:04:30 +02:00
const transformedBlock = ( 0 , external _wp _blocks _namespaceObject . createBlock ) ( block , transform ? transform ( instance . raw ) : undefined ) ;
2021-06-15 10:52:30 +02:00
if ( ! ( ( _instance$raw = instance . raw ) !== null && _instance$raw !== void 0 && _instance$raw . title ) ) {
return transformedBlock ;
}
2022-04-11 14:04:30 +02:00
return [ ( 0 , external _wp _blocks _namespaceObject . createBlock ) ( 'core/heading' , {
2021-06-15 10:52:30 +02:00
content : instance . raw . title
} ) , transformedBlock ] ;
}
} ;
} ) ;
const transforms = {
to : legacyWidgetTransforms
} ;
/* harmony default export */ var legacy _widget _transforms = ( transforms ) ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/index.js
2021-06-15 10:52:30 +02:00
/ * *
* WordPress dependencies
* /
/ * *
* Internal dependencies
* /
2022-04-11 14:04:30 +02:00
const metadata = {
2021-06-15 10:52:30 +02:00
apiVersion : 2 ,
name : "core/legacy-widget" ,
title : "Legacy Widget" ,
category : "widgets" ,
description : "Display a legacy widget." ,
textdomain : "default" ,
attributes : {
id : {
type : "string" ,
"default" : null
} ,
idBase : {
type : "string" ,
"default" : null
} ,
instance : {
type : "object" ,
"default" : null
}
} ,
supports : {
html : false ,
customClassName : false ,
reusable : false
} ,
editorStyle : "wp-block-legacy-widget-editor"
} ;
const {
name : legacy _widget _name
2022-04-11 14:04:30 +02:00
} = metadata ;
2021-06-15 10:52:30 +02:00
2022-04-11 14:04:30 +02:00
const settings = {
2021-06-15 10:52:30 +02:00
icon : library _widget ,
edit : Edit ,
transforms : legacy _widget _transforms
} ;
2021-05-25 10:40:25 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/group.js
/ * *
* WordPress dependencies
* /
const group = ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _primitives _namespaceObject . SVG , {
viewBox : "0 0 24 24" ,
xmlns : "http://www.w3.org/2000/svg"
} , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _primitives _namespaceObject . Path , {
d : "M18 4h-7c-1.1 0-2 .9-2 2v3H6c-1.1 0-2 .9-2 2v7c0 1.1.9 2 2 2h7c1.1 0 2-.9 2-2v-3h3c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4.5 14c0 .3-.2.5-.5.5H6c-.3 0-.5-.2-.5-.5v-7c0-.3.2-.5.5-.5h3V13c0 1.1.9 2 2 2h2.5v3zm0-4.5H11c-.3 0-.5-.2-.5-.5v-2.5H13c.3 0 .5.2.5.5v2.5zm5-.5c0 .3-.2.5-.5.5h-3V11c0-1.1-.9-2-2-2h-2.5V6c0-.3.2-.5.5-.5h7c.3 0 .5.2.5.5v7z"
} ) ) ;
/* harmony default export */ var library _group = ( group ) ;
2021-11-08 15:29:21 +01:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/widget-group/edit.js
2021-11-08 15:29:21 +01:00
/ * *
* WordPress dependencies
* /
function edit _Edit ( props ) {
const {
clientId
} = props ;
const {
innerBlocks
2022-04-11 14:04:30 +02:00
} = ( 0 , external _wp _data _namespaceObject . useSelect ) ( select => select ( external _wp _blockEditor _namespaceObject . store ) . getBlock ( clientId ) , [ clientId ] ) ;
return ( 0 , external _wp _element _namespaceObject . createElement ) ( "div" , ( 0 , external _wp _blockEditor _namespaceObject . useBlockProps ) ( {
2021-11-08 15:29:21 +01:00
className : 'widget'
2022-04-11 14:04:30 +02:00
} ) , innerBlocks . length === 0 ? ( 0 , external _wp _element _namespaceObject . createElement ) ( PlaceholderContent , props ) : ( 0 , external _wp _element _namespaceObject . createElement ) ( PreviewContent , props ) ) ;
2021-11-08 15:29:21 +01:00
}
2021-11-15 13:50:17 +01:00
function PlaceholderContent ( _ref ) {
let {
clientId
} = _ref ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _element _namespaceObject . Fragment , null , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . Placeholder , {
2021-11-08 15:29:21 +01:00
className : "wp-block-widget-group__placeholder" ,
2022-04-11 14:04:30 +02:00
icon : ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _blockEditor _namespaceObject . BlockIcon , {
icon : library _group
2021-11-08 15:29:21 +01:00
} ) ,
2022-04-11 14:04:30 +02:00
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Widget Group' )
} , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _blockEditor _namespaceObject . ButtonBlockAppender , {
2021-11-08 15:29:21 +01:00
rootClientId : clientId
2022-04-11 14:04:30 +02:00
} ) ) , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _blockEditor _namespaceObject . InnerBlocks , {
2021-11-08 15:29:21 +01:00
renderAppender : false
} ) ) ;
}
2021-11-15 13:50:17 +01:00
function PreviewContent ( _ref2 ) {
2021-11-08 15:29:21 +01:00
var _attributes$title ;
2021-11-15 13:50:17 +01:00
let {
attributes ,
setAttributes
} = _ref2 ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _element _namespaceObject . Fragment , null , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _blockEditor _namespaceObject . RichText , {
2021-11-08 15:29:21 +01:00
tagName : "h2" ,
className : "widget-title" ,
allowedFormats : [ ] ,
2022-04-11 14:04:30 +02:00
placeholder : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Title' ) ,
2021-11-08 15:29:21 +01:00
value : ( _attributes$title = attributes . title ) !== null && _attributes$title !== void 0 ? _attributes$title : '' ,
onChange : title => setAttributes ( {
title
} )
2022-04-11 14:04:30 +02:00
} ) , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _blockEditor _namespaceObject . InnerBlocks , null ) ) ;
2021-11-08 15:29:21 +01:00
}
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/widget-group/save.js
2021-11-08 15:29:21 +01:00
/ * *
* WordPress dependencies
* /
2021-11-15 13:50:17 +01:00
function save ( _ref ) {
let {
attributes
} = _ref ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _element _namespaceObject . Fragment , null , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _blockEditor _namespaceObject . RichText . Content , {
2021-11-08 15:29:21 +01:00
tagName : "h2" ,
className : "widget-title" ,
value : attributes . title
2022-04-12 17:12:47 +02:00
} ) , ( 0 , external _wp _element _namespaceObject . createElement ) ( "div" , {
className : "wp-widget-group__inner-blocks"
} , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _blockEditor _namespaceObject . InnerBlocks . Content , null ) ) ) ;
2021-11-08 15:29:21 +01:00
}
2022-04-12 17:12:47 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/widget-group/deprecated.js
/ * *
* WordPress dependencies
* /
const v1 = {
attributes : {
title : {
type : 'string'
}
} ,
supports : {
html : false ,
inserter : true ,
customClassName : true ,
reusable : false
} ,
save ( _ref ) {
let {
attributes
} = _ref ;
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _element _namespaceObject . Fragment , null , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _blockEditor _namespaceObject . RichText . Content , {
tagName : "h2" ,
className : "widget-title" ,
value : attributes . title
} ) , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _blockEditor _namespaceObject . InnerBlocks . Content , null ) ) ;
}
} ;
/* harmony default export */ var deprecated = ( [ v1 ] ) ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/widget-group/index.js
2021-11-08 15:29:21 +01:00
/ * *
* WordPress dependencies
* /
/ * *
* Internal dependencies
* /
const widget _group _metadata = {
apiVersion : 2 ,
name : "core/widget-group" ,
category : "widgets" ,
attributes : {
title : {
type : "string"
}
} ,
supports : {
html : false ,
inserter : true ,
customClassName : true ,
reusable : false
} ,
editorStyle : "wp-block-widget-group-editor" ,
style : "wp-block-widget-group"
} ;
2022-04-12 17:12:47 +02:00
2021-11-08 15:29:21 +01:00
const {
name : widget _group _name
} = widget _group _metadata ;
const widget _group _settings = {
2022-04-11 14:04:30 +02:00
title : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Widget Group' ) ,
description : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Create a classic widget layout with a title that’ s styled by your theme for your widget areas.' ) ,
icon : library _group ,
2021-11-15 13:50:17 +01:00
_ _experimentalLabel : _ref => {
let {
name : label
} = _ref ;
return label ;
} ,
2021-11-08 15:29:21 +01:00
edit : edit _Edit ,
save : save ,
transforms : {
from : [ {
type : 'block' ,
isMultiBlock : true ,
blocks : [ '*' ] ,
isMatch ( attributes , blocks ) {
// Avoid transforming existing `widget-group` blocks.
return ! blocks . some ( block => block . name === 'core/widget-group' ) ;
} ,
_ _experimentalConvert ( blocks ) {
// Put the selected blocks inside the new Widget Group's innerBlocks.
let innerBlocks = [ ... blocks . map ( block => {
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _blocks _namespaceObject . createBlock ) ( block . name , block . attributes , block . innerBlocks ) ;
2021-11-08 15:29:21 +01:00
} ) ] ; // If the first block is a heading then assume this is intended
// to be the Widget's "title".
const firstHeadingBlock = innerBlocks [ 0 ] . name === 'core/heading' ? innerBlocks [ 0 ] : null ; // Remove the first heading block as we're copying
// it's content into the Widget Group's title attribute.
innerBlocks = innerBlocks . filter ( block => block !== firstHeadingBlock ) ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _blocks _namespaceObject . createBlock ) ( 'core/widget-group' , { ... ( firstHeadingBlock && {
2021-11-08 15:29:21 +01:00
title : firstHeadingBlock . attributes . content
} )
} , innerBlocks ) ;
}
} ]
2022-04-12 17:12:47 +02:00
} ,
deprecated : deprecated
2021-11-08 15:29:21 +01:00
} ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/move-to.js
2021-05-25 10:40:25 +02:00
/ * *
* WordPress dependencies
* /
2022-04-11 14:04:30 +02:00
const moveTo = ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _primitives _namespaceObject . SVG , {
2021-05-25 10:40:25 +02:00
xmlns : "http://www.w3.org/2000/svg" ,
viewBox : "0 0 24 24"
2022-04-11 14:04:30 +02:00
} , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _primitives _namespaceObject . Path , {
2021-05-25 10:40:25 +02:00
d : "M19.75 9c0-1.257-.565-2.197-1.39-2.858-.797-.64-1.827-1.017-2.815-1.247-1.802-.42-3.703-.403-4.383-.396L11 4.5V6l.177-.001c.696-.006 2.416-.02 4.028.356.887.207 1.67.518 2.216.957.52.416.829.945.829 1.688 0 .592-.167.966-.407 1.23-.255.281-.656.508-1.236.674-1.19.34-2.82.346-4.607.346h-.077c-1.692 0-3.527 0-4.942.404-.732.209-1.424.545-1.935 1.108-.526.579-.796 1.33-.796 2.238 0 1.257.565 2.197 1.39 2.858.797.64 1.827 1.017 2.815 1.247 1.802.42 3.703.403 4.383.396L13 19.5h.714V22L18 18.5 13.714 15v3H13l-.177.001c-.696.006-2.416.02-4.028-.356-.887-.207-1.67-.518-2.216-.957-.52-.416-.829-.945-.829-1.688 0-.592.167-.966.407-1.23.255-.281.656-.508 1.237-.674 1.189-.34 2.819-.346 4.606-.346h.077c1.692 0 3.527 0 4.941-.404.732-.209 1.425-.545 1.936-1.108.526-.579.796-1.33.796-2.238z"
} ) ) ;
/* harmony default export */ var move _to = ( moveTo ) ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/components/move-to-widget-area/index.js
2021-05-25 10:40:25 +02:00
/ * *
* WordPress dependencies
* /
2021-11-15 13:50:17 +01:00
function MoveToWidgetArea ( _ref ) {
let {
currentWidgetAreaId ,
widgetAreas ,
onSelect
} = _ref ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . ToolbarGroup , null , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . ToolbarItem , null , toggleProps => ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . DropdownMenu , {
2021-05-25 10:40:25 +02:00
icon : move _to ,
2022-04-11 14:04:30 +02:00
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Move to widget area' ) ,
2021-05-25 10:40:25 +02:00
toggleProps : toggleProps
2021-11-15 13:50:17 +01:00
} , _ref2 => {
let {
onClose
} = _ref2 ;
2022-04-11 14:04:30 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . MenuGroup , {
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Move to' )
} , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _components _namespaceObject . MenuItemsChoice , {
2021-11-15 13:50:17 +01:00
choices : widgetAreas . map ( widgetArea => ( {
value : widgetArea . id ,
label : widgetArea . name ,
info : widgetArea . description
} ) ) ,
value : currentWidgetAreaId ,
onSelect : value => {
onSelect ( value ) ;
onClose ( ) ;
}
} ) ) ;
} ) ) ) ;
2021-05-25 10:40:25 +02:00
}
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/components/index.js
2021-05-25 10:40:25 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/utils.js
2021-06-15 10:52:30 +02:00
// @ts-check
2021-05-25 10:40:25 +02:00
2021-06-15 10:52:30 +02:00
/ * *
* Get the internal widget id from block .
*
* @ typedef { Object } Attributes
2021-11-08 15:29:21 +01:00
* @ property { string } _ _internalWidgetId The internal widget id .
2021-06-15 10:52:30 +02:00
* @ typedef { Object } Block
2021-11-08 15:29:21 +01:00
* @ property { Attributes } attributes The attributes of the block .
2021-06-15 10:52:30 +02:00
*
2021-11-08 15:29:21 +01:00
* @ param { Block } block The block .
2021-06-15 10:52:30 +02:00
* @ return { string } The internal widget id .
* /
function getWidgetIdFromBlock ( block ) {
return block . attributes . _ _internalWidgetId ;
}
/ * *
* Add internal widget id to block ' s attributes .
*
2021-11-08 15:29:21 +01:00
* @ param { Block } block The block .
2021-06-15 10:52:30 +02:00
* @ param { string } widgetId The widget id .
* @ return { Block } The updated block .
* /
2021-05-25 10:40:25 +02:00
2021-06-15 10:52:30 +02:00
function addWidgetIdToBlock ( block , widgetId ) {
return { ... block ,
attributes : { ... ( block . attributes || { } ) ,
_ _internalWidgetId : widgetId
}
} ;
}
2021-05-25 10:40:25 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/register-legacy-widget-variations.js
2021-05-25 10:40:25 +02:00
/ * *
* WordPress dependencies
* /
function registerLegacyWidgetVariations ( settings ) {
2022-04-11 14:04:30 +02:00
const unsubscribe = ( 0 , external _wp _data _namespaceObject . subscribe ) ( ( ) => {
2021-05-25 10:40:25 +02:00
var _settings$widgetTypes , _select$getWidgetType ;
const hiddenIds = ( _settings$widgetTypes = settings === null || settings === void 0 ? void 0 : settings . widgetTypesToHideFromLegacyWidgetBlock ) !== null && _settings$widgetTypes !== void 0 ? _settings$widgetTypes : [ ] ;
2022-04-11 14:04:30 +02:00
const widgetTypes = ( _select$getWidgetType = ( 0 , external _wp _data _namespaceObject . select ) ( external _wp _coreData _namespaceObject . store ) . getWidgetTypes ( {
2021-05-25 10:40:25 +02:00
per _page : - 1
} ) ) === null || _select$getWidgetType === void 0 ? void 0 : _select$getWidgetType . filter ( widgetType => ! hiddenIds . includes ( widgetType . id ) ) ;
if ( widgetTypes ) {
unsubscribe ( ) ;
2022-04-11 14:04:30 +02:00
( 0 , external _wp _data _namespaceObject . dispatch ) ( external _wp _blocks _namespaceObject . store ) . addBlockVariations ( 'core/legacy-widget' , widgetTypes . map ( widgetType => ( {
2021-05-25 10:40:25 +02:00
name : widgetType . id ,
title : widgetType . name ,
description : widgetType . description ,
attributes : widgetType . is _multi ? {
idBase : widgetType . id ,
instance : { }
} : {
id : widgetType . id
}
} ) ) ) ;
}
} ) ;
}
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/index.js
2021-05-25 10:40:25 +02:00
/ * *
2021-06-15 10:52:30 +02:00
* WordPress dependencies
2021-05-25 10:40:25 +02:00
* /
2021-06-15 10:52:30 +02:00
2021-05-25 10:40:25 +02:00
/ * *
2021-06-15 10:52:30 +02:00
* Internal dependencies
2021-05-25 10:40:25 +02:00
* /
2021-11-08 15:29:21 +01:00
2021-06-15 10:52:30 +02:00
/ * *
* Registers the Legacy Widget block .
*
* Note that for the block to be useful , any scripts required by a widget must
* be loaded into the page .
*
2023-02-07 08:04:52 +01:00
* @ param { Object } supports Block support settings .
2021-06-15 10:52:30 +02:00
* @ see https : //developer.wordpress.org/block-editor/how-to-guides/widgets/legacy-widget-block/
* /
function registerLegacyWidgetBlock ( ) {
2023-02-07 08:04:52 +01:00
let supports = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
2021-06-15 10:52:30 +02:00
const {
metadata ,
settings ,
name
} = legacy _widget _namespaceObject ;
2022-04-11 14:04:30 +02:00
( 0 , external _wp _blocks _namespaceObject . registerBlockType ) ( {
2021-06-15 10:52:30 +02:00
name ,
... metadata
2023-02-07 08:04:52 +01:00
} , { ... settings ,
supports : { ... settings . supports ,
... supports
}
} ) ;
2021-06-15 10:52:30 +02:00
}
2021-11-08 15:29:21 +01:00
/ * *
* Registers the Widget Group block .
2023-03-07 16:31:49 +01:00
*
* @ param { Object } supports Block support settings .
2021-11-08 15:29:21 +01:00
* /
function registerWidgetGroupBlock ( ) {
2023-03-07 16:31:49 +01:00
let supports = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : { } ;
2021-11-08 15:29:21 +01:00
const {
metadata ,
settings ,
name
} = widget _group _namespaceObject ;
2022-04-11 14:04:30 +02:00
( 0 , external _wp _blocks _namespaceObject . registerBlockType ) ( {
2021-11-08 15:29:21 +01:00
name ,
... metadata
2023-03-07 16:31:49 +01:00
} , { ... settings ,
supports : { ... settings . supports ,
... supports
}
} ) ;
2021-11-08 15:29:21 +01:00
}
2021-05-25 10:40:25 +02:00
2022-04-11 14:04:30 +02:00
} ( ) ;
( window . wp = window . wp || { } ) . widgets = _ _webpack _exports _ _ ;
/******/ } ) ( )
;