2023-08-11 18:04:29 +02:00
/******/ ( ( ) => { // webpackBootstrap
2022-04-11 14:04:30 +02:00
/******/ var _ _webpack _modules _ _ = ( {
/***/ 4403 :
2023-08-11 18:04:29 +02:00
/***/ ( ( module , exports ) => {
2022-04-11 14:04:30 +02:00
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 */
2023-08-11 18:04:29 +02:00
/******/ ( ( ) => {
2022-04-11 14:04:30 +02:00
/******/ // getDefaultExport function for compatibility with non-harmony modules
2023-08-11 18:04:29 +02:00
/******/ _ _webpack _require _ _ . n = ( module ) => {
2022-04-11 14:04:30 +02:00
/******/ var getter = module && module . _ _esModule ?
2023-08-11 18:04:29 +02:00
/******/ ( ) => ( module [ 'default' ] ) :
/******/ ( ) => ( module ) ;
2022-04-11 14:04:30 +02:00
/******/ _ _webpack _require _ _ . d ( getter , { a : getter } ) ;
/******/ return getter ;
/******/ } ;
2023-08-11 18:04:29 +02:00
/******/ } ) ( ) ;
2022-04-11 14:04:30 +02:00
/******/
/******/ /* webpack/runtime/define property getters */
2023-08-11 18:04:29 +02:00
/******/ ( ( ) => {
2022-04-11 14:04:30 +02:00
/******/ // define getter functions for harmony exports
2023-08-11 18:04:29 +02:00
/******/ _ _webpack _require _ _ . d = ( exports , definition ) => {
2022-04-11 14:04:30 +02:00
/******/ 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 ] } ) ;
/******/ }
/******/ }
/******/ } ;
2023-08-11 18:04:29 +02:00
/******/ } ) ( ) ;
2022-04-11 14:04:30 +02:00
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
2023-08-11 18:04:29 +02:00
/******/ ( ( ) => {
/******/ _ _webpack _require _ _ . o = ( obj , prop ) => ( Object . prototype . hasOwnProperty . call ( obj , prop ) )
/******/ } ) ( ) ;
2022-04-11 14:04:30 +02:00
/******/
/******/ /* webpack/runtime/make namespace object */
2023-08-11 18:04:29 +02:00
/******/ ( ( ) => {
2022-04-11 14:04:30 +02:00
/******/ // define __esModule on exports
2023-08-11 18:04:29 +02:00
/******/ _ _webpack _require _ _ . r = ( exports ) => {
2022-04-11 14:04:30 +02:00
/******/ if ( typeof Symbol !== 'undefined' && Symbol . toStringTag ) {
/******/ Object . defineProperty ( exports , Symbol . toStringTag , { value : 'Module' } ) ;
/******/ }
/******/ Object . defineProperty ( exports , '__esModule' , { value : true } ) ;
/******/ } ;
2023-08-11 18:04:29 +02:00
/******/ } ) ( ) ;
2022-04-11 14:04:30 +02:00
/******/
/************************************************************************/
var _ _webpack _exports _ _ = { } ;
// This entry need to be wrapped in an IIFE because it need to be in strict mode.
2023-08-11 18:04:29 +02:00
( ( ) => {
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 _ _ , {
2023-08-11 18:04:29 +02:00
MoveToWidgetArea : ( ) => ( /* reexport */ MoveToWidgetArea ) ,
addWidgetIdToBlock : ( ) => ( /* reexport */ addWidgetIdToBlock ) ,
getWidgetIdFromBlock : ( ) => ( /* reexport */ getWidgetIdFromBlock ) ,
registerLegacyWidgetBlock : ( ) => ( /* binding */ registerLegacyWidgetBlock ) ,
registerLegacyWidgetVariations : ( ) => ( /* reexport */ registerLegacyWidgetVariations ) ,
registerWidgetGroupBlock : ( ) => ( /* binding */ registerWidgetGroupBlock )
2022-04-11 14:04:30 +02:00
} ) ;
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 , {
2023-08-11 18:04:29 +02:00
metadata : ( ) => ( metadata ) ,
name : ( ) => ( legacy _widget _name ) ,
settings : ( ) => ( settings )
2022-04-11 14:04:30 +02:00
} ) ;
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 , {
2023-08-11 18:04:29 +02:00
metadata : ( ) => ( widget _group _metadata ) ,
name : ( ) => ( widget _group _name ) ,
settings : ( ) => ( widget _group _settings )
2022-04-11 14:04:30 +02:00
} ) ;
2021-06-15 10:52:30 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","blocks"]
2023-08-11 18:04:29 +02:00
const external _wp _blocks _namespaceObject = window [ "wp" ] [ "blocks" ] ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","element"]
2023-08-11 18:04:29 +02:00
const external _wp _element _namespaceObject = window [ "wp" ] [ "element" ] ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","primitives"]
2023-08-11 18:04:29 +02:00
const external _wp _primitives _namespaceObject = window [ "wp" ] [ "primitives" ] ;
2022-04-11 14:04:30 +02:00
; // 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
} ) ) ;
2023-08-11 18:04:29 +02:00
/* harmony default export */ const 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"]
2023-08-11 18:04:29 +02:00
const external _wp _blockEditor _namespaceObject = window [ "wp" ] [ "blockEditor" ] ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","components"]
2023-08-11 18:04:29 +02:00
const external _wp _components _namespaceObject = window [ "wp" ] [ "components" ] ;
2022-04-11 14:04:30 +02:00
; // 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"
} ) ) ;
2023-08-11 18:04:29 +02:00
/* harmony default export */ const library _brush = ( brush ) ;
2021-06-15 10:52:30 +02:00
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","i18n"]
2023-08-11 18:04:29 +02:00
const external _wp _i18n _namespaceObject = window [ "wp" ] [ "i18n" ] ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","data"]
2023-08-11 18:04:29 +02:00
const external _wp _data _namespaceObject = window [ "wp" ] [ "data" ] ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","coreData"]
2023-08-11 18:04:29 +02:00
const external _wp _coreData _namespaceObject = window [ "wp" ] [ "coreData" ] ;
2022-04-11 14:04:30 +02:00
; // 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
* /
2023-06-27 16:24:19 +02:00
function WidgetTypeSelector ( {
selectedId ,
onSelect
} ) {
2022-04-11 14:04:30 +02:00
const widgetTypes = ( 0 , external _wp _data _namespaceObject . useSelect ) ( select => {
2023-06-27 16:24:19 +02:00
var _select$getSettings$w ;
2021-06-15 10:52:30 +02:00
2023-06-27 16:24:19 +02:00
const hiddenIds = ( _select$getSettings$w = select ( external _wp _blockEditor _namespaceObject . store ) . getSettings ( ) ? . widgetTypesToHideFromLegacyWidgetBlock ) !== null && _select$getSettings$w !== void 0 ? _select$getSettings$w : [ ] ;
return select ( external _wp _coreData _namespaceObject . store ) . getWidgetTypes ( {
2021-06-15 10:52:30 +02:00
per _page : - 1
2023-06-27 16:24:19 +02:00
} ) ? . filter ( widgetType => ! hiddenIds . includes ( widgetType . id ) ) ;
2021-06-15 10:52:30 +02:00
} , [ ] ) ;
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
2023-06-27 16:24:19 +02:00
function InspectorCard ( {
name ,
description
} ) {
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"]
2023-08-11 18:04:29 +02:00
const external _wp _notices _namespaceObject = window [ "wp" ] [ "notices" ] ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","compose"]
2023-08-11 18:04:29 +02:00
const external _wp _compose _namespaceObject = window [ "wp" ] [ "compose" ] ;
2022-04-11 14:04:30 +02:00
; // CONCATENATED MODULE: external ["wp","apiFetch"]
2023-08-11 18:04:29 +02:00
const external _wp _apiFetch _namespaceObject = window [ "wp" ] [ "apiFetch" ] ;
2022-04-11 14:04:30 +02:00
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
* /
2023-06-27 16:24:19 +02:00
constructor ( {
id ,
idBase ,
instance ,
onChangeInstance ,
onChangeHasPreview ,
onError
} ) {
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 ;
2023-06-27 16:24:19 +02:00
function el ( tagName , attributes = { } , content = 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 ;
}
2023-06-27 16:24:19 +02:00
async function saveWidget ( id , formData = 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
} ;
}
2023-06-27 16:24:19 +02:00
async function encodeWidget ( {
idBase ,
instance ,
number ,
formData = null
} ) {
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
* /
2023-06-27 16:24:19 +02:00
function Form ( {
title ,
isVisible ,
id ,
idBase ,
instance ,
isWide ,
onChangeInstance ,
onChangeHasPreview
} ) {
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
* /
2023-06-27 16:24:19 +02:00
function Preview ( {
idBase ,
instance ,
isVisible
} ) {
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' ,
2023-06-27 16:24:19 +02:00
signal : abortController ? . signal ,
2021-11-08 15:29:21 +01:00
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 ;
} ) ;
2023-06-27 16:24:19 +02:00
return ( ) => abortController ? . abort ( ) ;
2021-11-08 15:29:21 +01:00
} , [ 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-06-27 16:24:19 +02:00
var _iframe$contentDocume , _iframe$contentDocume2 ;
2023-02-07 08:04:52 +01:00
2021-11-08 15:29:21 +01:00
// Pick the maximum of these two values to account for margin collapsing.
2023-06-27 16:24:19 +02:00
const height = Math . max ( ( _iframe$contentDocume = iframe . contentDocument . documentElement ? . offsetHeight ) !== null && _iframe$contentDocume !== void 0 ? _iframe$contentDocume : 0 , ( _iframe$contentDocume2 = iframe . contentDocument . body ? . offsetHeight ) !== null && _iframe$contentDocume2 !== void 0 ? _iframe$contentDocume2 : 0 ) ; // Fallback to a height of 100px if the height cannot be determined.
2023-02-07 08:04:52 +01:00
// 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.
2023-06-27 16:24:19 +02:00
const intersectionObserver = new IntersectionObserver ( ( [ entry ] ) => {
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
* /
2023-06-27 16:24:19 +02:00
function NoPreview ( {
name
} ) {
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
* /
2023-06-27 16:24:19 +02:00
function ConvertToBlocksButton ( {
clientId ,
rawInstance
} ) {
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
} )
} ) ;
2023-06-27 16:24:19 +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
}
2023-06-27 16:24:19 +02:00
function Empty ( {
attributes : {
id ,
idBase
} ,
setAttributes
} ) {
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 ,
2023-06-27 16:24:19 +02:00
onSelect : ( {
selectedId ,
isMulti
} ) => {
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
}
2023-06-27 16:24:19 +02:00
function NotEmpty ( {
attributes : {
id ,
idBase ,
instance
} ,
setAttributes ,
clientId ,
isSelected ,
isWide = false
} ) {
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' ,
2023-06-27 16:24:19 +02:00
transform : ( {
content
} ) => ( {
content
} )
2021-06-15 10:52:30 +02:00
} , {
block : 'core/archives' ,
widget : 'archives' ,
2023-06-27 16:24:19 +02:00
transform : ( {
count ,
dropdown
} ) => {
2021-06-15 10:52:30 +02:00
return {
displayAsDropdown : ! ! dropdown ,
showPostCounts : ! ! count
} ;
}
} , {
block : 'core/latest-posts' ,
widget : 'recent-posts' ,
2023-06-27 16:24:19 +02:00
transform : ( {
show _date : displayPostDate ,
number
} ) => {
2021-06-15 10:52:30 +02:00
return {
displayPostDate : ! ! displayPostDate ,
postsToShow : number
} ;
}
} , {
block : 'core/latest-comments' ,
widget : 'recent-comments' ,
2023-06-27 16:24:19 +02:00
transform : ( {
number
} ) => {
2021-06-15 10:52:30 +02:00
return {
commentsToShow : number
} ;
}
} , {
block : 'core/tag-cloud' ,
widget : 'tag_cloud' ,
2023-06-27 16:24:19 +02:00
transform : ( {
taxonomy ,
count
} ) => {
2021-06-15 10:52:30 +02:00
return {
showTagCounts : ! ! count ,
taxonomy
} ;
}
} , {
block : 'core/categories' ,
widget : 'categories' ,
2023-06-27 16:24:19 +02:00
transform : ( {
count ,
dropdown ,
hierarchical
} ) => {
2021-06-15 10:52:30 +02:00
return {
displayAsDropdown : ! ! dropdown ,
showPostCounts : ! ! count ,
showHierarchy : ! ! hierarchical
} ;
}
} , {
block : 'core/audio' ,
widget : 'media_audio' ,
2023-06-27 16:24:19 +02:00
transform : ( {
url ,
preload ,
loop ,
attachment _id : id
} ) => {
2021-06-15 10:52:30 +02:00
return {
src : url ,
id ,
preload ,
loop
} ;
}
} , {
block : 'core/video' ,
widget : 'media_video' ,
2023-06-27 16:24:19 +02:00
transform : ( {
url ,
preload ,
loop ,
attachment _id : id
} ) => {
2021-06-15 10:52:30 +02:00
return {
src : url ,
id ,
preload ,
loop
} ;
}
} , {
block : 'core/image' ,
widget : 'media_image' ,
2023-06-27 16:24:19 +02:00
transform : ( {
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
} ) => {
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' ,
2023-06-27 16:24:19 +02:00
transform : ( {
ids ,
link _type : linkTo ,
size ,
number
} ) => {
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' ,
2023-06-27 16:24:19 +02:00
transform : ( {
url ,
show _author : displayAuthor ,
show _date : displayDate ,
show _summary : displayExcerpt ,
items
} ) => {
2021-06-15 10:52:30 +02:00
return {
feedURL : url ,
displayAuthor : ! ! displayAuthor ,
displayDate : ! ! displayDate ,
displayExcerpt : ! ! displayExcerpt ,
itemsToShow : items
} ;
}
2023-06-27 16:24:19 +02:00
} ] . map ( ( {
block ,
widget ,
transform
} ) => {
2021-06-15 10:52:30 +02:00
return {
type : 'block' ,
blocks : [ block ] ,
2023-06-27 16:24:19 +02:00
isMatch : ( {
idBase ,
instance
} ) => {
return idBase === widget && ! ! instance ? . raw ;
2021-06-15 10:52:30 +02:00
} ,
2023-06-27 16:24:19 +02:00
transform : ( {
instance
} ) => {
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
2023-06-27 16:24:19 +02:00
if ( ! instance . raw ? . title ) {
2021-06-15 10:52:30 +02:00
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
} ;
2023-08-11 18:04:29 +02:00
/* harmony default export */ const legacy _widget _transforms = ( transforms ) ;
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/index.js
2021-06-15 10:52:30 +02:00
/ * *
* WordPress dependencies
* /
/ * *
* Internal dependencies
* /
2022-04-11 14:04:30 +02:00
const metadata = {
2023-06-27 16:24:19 +02:00
apiVersion : 3 ,
2021-06-15 10:52:30 +02:00
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"
} ) ) ;
2023-08-11 18:04:29 +02:00
/* harmony default export */ const 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 ] ) ;
2023-06-27 16:24:19 +02:00
return ( 0 , external _wp _element _namespaceObject . createElement ) ( "div" , { ... ( 0 , external _wp _blockEditor _namespaceObject . useBlockProps ) ( {
className : 'widget'
} )
} , 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
}
2023-06-27 16:24:19 +02:00
function PlaceholderContent ( {
clientId
} ) {
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
} ) ) ;
}
2023-06-27 16:24:19 +02:00
function PreviewContent ( {
attributes ,
setAttributes
} ) {
2021-11-08 15:29:21 +01:00
var _attributes$title ;
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
* /
2023-06-27 16:24:19 +02:00
function save ( {
attributes
} ) {
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
} ,
2023-06-27 16:24:19 +02:00
save ( {
attributes
} ) {
2022-04-12 17:12:47 +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 , {
tagName : "h2" ,
className : "widget-title" ,
value : attributes . title
} ) , ( 0 , external _wp _element _namespaceObject . createElement ) ( external _wp _blockEditor _namespaceObject . InnerBlocks . Content , null ) ) ;
}
} ;
2023-08-11 18:04:29 +02:00
/* harmony default export */ const deprecated = ( [ v1 ] ) ;
2022-04-12 17:12:47 +02:00
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 = {
2023-06-27 16:24:19 +02:00
apiVersion : 3 ,
2021-11-08 15:29:21 +01:00
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 ,
2023-06-27 16:24:19 +02:00
_ _experimentalLabel : ( {
name : label
} ) => 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"
} ) ) ;
2023-08-11 18:04:29 +02:00
/* harmony default export */ const move _to = ( moveTo ) ;
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/move-to-widget-area/index.js
2021-05-25 10:40:25 +02:00
/ * *
* WordPress dependencies
* /
2023-06-27 16:24:19 +02:00
function MoveToWidgetArea ( {
currentWidgetAreaId ,
widgetAreas ,
onSelect
} ) {
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
2023-06-27 16:24:19 +02:00
} , ( {
onClose
} ) => ( 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 , {
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 ) ( ( ) => {
2023-06-27 16:24:19 +02:00
var _settings$widgetTypes ;
2021-05-25 10:40:25 +02:00
2023-06-27 16:24:19 +02:00
const hiddenIds = ( _settings$widgetTypes = settings ? . widgetTypesToHideFromLegacyWidgetBlock ) !== null && _settings$widgetTypes !== void 0 ? _settings$widgetTypes : [ ] ;
const widgetTypes = ( 0 , external _wp _data _namespaceObject . select ) ( external _wp _coreData _namespaceObject . store ) . getWidgetTypes ( {
2021-05-25 10:40:25 +02:00
per _page : - 1
2023-06-27 16:24:19 +02:00
} ) ? . filter ( widgetType => ! hiddenIds . includes ( widgetType . id ) ) ;
2021-05-25 10:40:25 +02:00
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/
* /
2023-06-27 16:24:19 +02:00
function registerLegacyWidgetBlock ( supports = { } ) {
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
* /
2023-06-27 16:24:19 +02:00
function registerWidgetGroupBlock ( supports = { } ) {
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
2023-08-11 18:04:29 +02:00
} ) ( ) ;
2022-04-11 14:04:30 +02:00
( window . wp = window . wp || { } ) . widgets = _ _webpack _exports _ _ ;
/******/ } ) ( )
;