2021-05-25 04:40:25 -04:00
this [ "wp" ] = this [ "wp" ] || { } ; this [ "wp" ] [ "widgets" ] =
/******/ ( function ( modules ) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = { } ;
/******/
/******/ // The require function
/******/ function _ _webpack _require _ _ ( moduleId ) {
/******/
/******/ // Check if module is in cache
/******/ if ( installedModules [ moduleId ] ) {
/******/ return installedModules [ moduleId ] . exports ;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules [ moduleId ] = {
/******/ i : moduleId ,
/******/ l : false ,
/******/ exports : { }
/******/ } ;
/******/
/******/ // Execute the module function
/******/ modules [ moduleId ] . call ( module . exports , module , module . exports , _ _webpack _require _ _ ) ;
/******/
/******/ // Flag the module as loaded
/******/ module . l = true ;
/******/
/******/ // Return the exports of the module
/******/ return module . exports ;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ _ _webpack _require _ _ . m = modules ;
/******/
/******/ // expose the module cache
/******/ _ _webpack _require _ _ . c = installedModules ;
/******/
/******/ // define getter function for harmony exports
/******/ _ _webpack _require _ _ . d = function ( exports , name , getter ) {
/******/ if ( ! _ _webpack _require _ _ . o ( exports , name ) ) {
/******/ Object . defineProperty ( exports , name , { enumerable : true , get : getter } ) ;
/******/ }
/******/ } ;
/******/
/******/ // 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 } ) ;
/******/ } ;
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ _ _webpack _require _ _ . t = function ( value , mode ) {
/******/ if ( mode & 1 ) value = _ _webpack _require _ _ ( value ) ;
/******/ if ( mode & 8 ) return value ;
/******/ if ( ( mode & 4 ) && typeof value === 'object' && value && value . _ _esModule ) return value ;
/******/ var ns = Object . create ( null ) ;
/******/ _ _webpack _require _ _ . r ( ns ) ;
/******/ Object . defineProperty ( ns , 'default' , { enumerable : true , value : value } ) ;
/******/ if ( mode & 2 && typeof value != 'string' ) for ( var key in value ) _ _webpack _require _ _ . d ( ns , key , function ( key ) { return value [ key ] ; } . bind ( null , key ) ) ;
/******/ return ns ;
/******/ } ;
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ _ _webpack _require _ _ . n = function ( module ) {
/******/ var getter = module && module . _ _esModule ?
/******/ function getDefault ( ) { return module [ 'default' ] ; } :
/******/ function getModuleExports ( ) { return module ; } ;
/******/ _ _webpack _require _ _ . d ( getter , 'a' , getter ) ;
/******/ return getter ;
/******/ } ;
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ _ _webpack _require _ _ . o = function ( object , property ) { return Object . prototype . hasOwnProperty . call ( object , property ) ; } ;
/******/
/******/ // __webpack_public_path__
/******/ _ _webpack _require _ _ . p = "" ;
/******/
/******/
/******/ // Load entry module and return exports
/******/ return _ _webpack _require _ _ ( _ _webpack _require _ _ . s = "4g8P" ) ;
/******/ } )
/************************************************************************/
/******/ ( {
/***/ "1ZqX" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "data" ] ; } ( ) ) ;
/***/ } ) ,
/***/ "4g8P" :
/***/ ( function ( module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) {
"use strict" ;
// ESM COMPAT FLAG
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
// EXPORTS
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "MoveToWidgetArea" , function ( ) { return /* reexport */ MoveToWidgetArea ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "getWidgetIdFromBlock" , function ( ) { return /* reexport */ getWidgetIdFromBlock ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "addWidgetIdToBlock" , function ( ) { return /* reexport */ addWidgetIdToBlock ; } ) ;
2021-06-15 04:52:30 -04:00
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "registerLegacyWidgetBlock" , function ( ) { return /* binding */ registerLegacyWidgetBlock ; } ) ;
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , "registerLegacyWidgetVariations" , function ( ) { return /* reexport */ registerLegacyWidgetVariations ; } ) ;
// NAMESPACE OBJECT: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/index.js
var legacy _widget _namespaceObject = { } ;
_ _webpack _require _ _ . r ( legacy _widget _namespaceObject ) ;
_ _webpack _require _ _ . d ( legacy _widget _namespaceObject , "metadata" , function ( ) { return legacy _widget _metadata ; } ) ;
_ _webpack _require _ _ . d ( legacy _widget _namespaceObject , "name" , function ( ) { return legacy _widget _name ; } ) ;
_ _webpack _require _ _ . d ( legacy _widget _namespaceObject , "settings" , function ( ) { return legacy _widget _settings ; } ) ;
// EXTERNAL MODULE: external ["wp","blocks"]
var external _wp _blocks _ = _ _webpack _require _ _ ( "HSyU" ) ;
2021-05-25 04:40:25 -04:00
// EXTERNAL MODULE: external ["wp","element"]
var external _wp _element _ = _ _webpack _require _ _ ( "GRId" ) ;
2021-06-15 04:52:30 -04:00
// EXTERNAL MODULE: external ["wp","primitives"]
var external _wp _primitives _ = _ _webpack _require _ _ ( "Tqx9" ) ;
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/widget.js
/ * *
* WordPress dependencies
* /
const widget _widget = Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _primitives _ [ "SVG" ] , {
2021-07-06 10:38:40 -04:00
xmlns : "http://www.w3.org/2000/svg" ,
viewBox : "0 0 24 24"
2021-06-15 04:52:30 -04:00
} , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _primitives _ [ "Path" ] , {
2021-07-06 10:38:40 -04: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 04:52:30 -04:00
} ) ) ;
/* harmony default export */ var library _widget = ( widget _widget ) ;
// EXTERNAL MODULE: ./node_modules/classnames/index.js
var classnames = _ _webpack _require _ _ ( "TSYQ" ) ;
var classnames _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( classnames ) ;
// EXTERNAL MODULE: external ["wp","blockEditor"]
var external _wp _blockEditor _ = _ _webpack _require _ _ ( "axFQ" ) ;
2021-05-25 04:40:25 -04:00
// EXTERNAL MODULE: external ["wp","components"]
var external _wp _components _ = _ _webpack _require _ _ ( "tI+e" ) ;
2021-06-15 04:52:30 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/brush.js
/ * *
* WordPress dependencies
* /
const brush = Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _primitives _ [ "SVG" ] , {
xmlns : "http://www.w3.org/2000/svg" ,
viewBox : "0 0 24 24"
} , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _primitives _ [ "Path" ] , {
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 ) ;
2021-05-25 04:40:25 -04:00
// EXTERNAL MODULE: external ["wp","i18n"]
var external _wp _i18n _ = _ _webpack _require _ _ ( "l3Sj" ) ;
2021-06-15 04:52:30 -04:00
// EXTERNAL MODULE: external ["wp","data"]
var external _wp _data _ = _ _webpack _require _ _ ( "1ZqX" ) ;
// EXTERNAL MODULE: external ["wp","coreData"]
var external _wp _coreData _ = _ _webpack _require _ _ ( "jZUy" ) ;
// CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/widget-type-selector.js
/ * *
* WordPress dependencies
* /
function WidgetTypeSelector ( {
selectedId ,
onSelect
} ) {
const widgetTypes = Object ( external _wp _data _ [ "useSelect" ] ) ( select => {
var _select$getSettings$w , _select$getSettings , _select$getWidgetType ;
const hiddenIds = ( _select$getSettings$w = ( _select$getSettings = select ( external _wp _blockEditor _ [ "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 _ [ "store" ] ) . getWidgetTypes ( {
per _page : - 1
} ) ) === null || _select$getWidgetType === void 0 ? void 0 : _select$getWidgetType . filter ( widgetType => ! hiddenIds . includes ( widgetType . id ) ) ;
} , [ ] ) ;
if ( ! widgetTypes ) {
return Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Spinner" ] , null ) ;
}
if ( widgetTypes . length === 0 ) {
return Object ( external _wp _i18n _ [ "__" ] ) ( 'There are no widgets available.' ) ;
}
return Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "SelectControl" ] , {
label : Object ( external _wp _i18n _ [ "__" ] ) ( 'Select a legacy widget to display:' ) ,
value : selectedId !== null && selectedId !== void 0 ? selectedId : '' ,
options : [ {
value : '' ,
label : Object ( external _wp _i18n _ [ "__" ] ) ( 'Select widget' )
} , ... 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
} ) ;
}
}
} ) ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/inspector-card.js
function InspectorCard ( {
name ,
description
} ) {
return Object ( external _wp _element _ [ "createElement" ] ) ( "div" , {
className : "wp-block-legacy-widget-inspector-card"
} , Object ( external _wp _element _ [ "createElement" ] ) ( "h3" , {
className : "wp-block-legacy-widget-inspector-card__name"
} , name ) , Object ( external _wp _element _ [ "createElement" ] ) ( "span" , null , description ) ) ;
}
// EXTERNAL MODULE: external ["wp","notices"]
var external _wp _notices _ = _ _webpack _require _ _ ( "onLe" ) ;
// EXTERNAL MODULE: external ["wp","compose"]
var external _wp _compose _ = _ _webpack _require _ _ ( "K9lf" ) ;
// EXTERNAL MODULE: external "lodash"
var external _lodash _ = _ _webpack _require _ _ ( "YLtl" ) ;
// EXTERNAL MODULE: external ["wp","apiFetch"]
var external _wp _apiFetch _ = _ _webpack _require _ _ ( "ywyh" ) ;
var external _wp _apiFetch _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _wp _apiFetch _ ) ;
// CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/control.js
/ * *
* External dependencies
* /
/ * *
* 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 .
* /
class control _Control {
/ * *
* Creates and loads a new control .
*
* @ access public
* @ param { Object } params
* @ param { string } params . id
* @ param { string } params . idBase
* @ param { Object } params . instance
* @ param { Function } params . onChangeInstance
* @ param { Function } params . onChangeHasPreview
* @ param { Function } params . onError
* /
constructor ( {
id ,
idBase ,
instance ,
onChangeInstance ,
onChangeHasPreview ,
onError
} ) {
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 ;
2021-06-28 12:01:36 -04:00
this . handleFormChange = Object ( external _lodash _ [ "debounce" ] ) ( this . handleFormChange . bind ( this ) , 200 ) ;
2021-06-15 04:52:30 -04: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'
} , Object ( external _wp _i18n _ [ "__" ] ) ( 'Save' ) ) ] ) ] ) ] ) ;
}
/ * *
* 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 12:01:36 -04: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 04:52:30 -04: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 ;
function el ( tagName , attributes = { } , content = null ) {
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 ;
}
async function saveWidget ( id , formData = null ) {
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
} ;
}
async function encodeWidget ( {
idBase ,
instance ,
number ,
formData = null
} ) {
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 11:30:24 -04: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 04:52:30 -04:00
}
function serializeForm ( form ) {
return new window . URLSearchParams ( Array . from ( new window . FormData ( form ) ) ) . toString ( ) ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/form.js
/ * *
* External dependencies
* /
/ * *
* WordPress dependencies
* /
/ * *
* Internal dependencies
* /
function Form ( {
title ,
isVisible ,
id ,
idBase ,
instance ,
isWide ,
onChangeInstance ,
onChangeHasPreview
} ) {
const ref = Object ( external _wp _element _ [ "useRef" ] ) ( ) ;
const isMediumLargeViewport = Object ( external _wp _compose _ [ "useViewportMatch" ] ) ( 'small' ) ; // We only want to remount the control when the instance changes
// *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.
const outgoingInstances = Object ( external _wp _element _ [ "useRef" ] ) ( new Set ( ) ) ;
const incomingInstances = Object ( external _wp _element _ [ "useRef" ] ) ( new Set ( ) ) ;
const {
createNotice
} = Object ( external _wp _data _ [ "useDispatch" ] ) ( external _wp _notices _ [ "store" ] ) ;
Object ( external _wp _element _ [ "useEffect" ] ) ( ( ) => {
if ( incomingInstances . current . has ( instance ) ) {
incomingInstances . current . delete ( instance ) ;
return ;
}
const control = new control _Control ( {
id ,
idBase ,
instance ,
onChangeInstance ( nextInstance ) {
outgoingInstances . current . add ( instance ) ;
incomingInstances . current . add ( nextInstance ) ;
onChangeInstance ( nextInstance ) ;
} ,
onChangeHasPreview ,
onError ( error ) {
2021-07-06 10:38:40 -04:00
window . console . error ( error ) ;
createNotice ( 'error' , Object ( external _wp _i18n _ [ "sprintf" ] ) (
/* translators: %s: the name of the affected block. */
Object ( external _wp _i18n _ [ "__" ] ) ( 'The "%s" block was affected by errors and may not function properly. Check the developer tools for more details.' ) , idBase || id ) ) ;
2021-06-15 04:52:30 -04: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 ) {
return Object ( external _wp _element _ [ "createElement" ] ) ( "div" , {
className : classnames _default ( ) ( {
'wp-block-legacy-widget__container' : isVisible
} )
} , isVisible && Object ( external _wp _element _ [ "createElement" ] ) ( "h3" , {
className : "wp-block-legacy-widget__edit-form-title"
} , title ) , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Popover" ] , {
focusOnMount : false ,
position : "middle right" ,
_ _unstableForceXAlignment : true
} , Object ( external _wp _element _ [ "createElement" ] ) ( "div" , {
ref : ref ,
className : "wp-block-legacy-widget__edit-form" ,
hidden : ! isVisible
} ) ) ) ;
}
return Object ( external _wp _element _ [ "createElement" ] ) ( "div" , {
ref : ref ,
className : "wp-block-legacy-widget__edit-form" ,
hidden : ! isVisible
} , Object ( external _wp _element _ [ "createElement" ] ) ( "h3" , {
className : "wp-block-legacy-widget__edit-form-title"
} , title ) ) ;
}
// EXTERNAL MODULE: external ["wp","url"]
var external _wp _url _ = _ _webpack _require _ _ ( "Mmq9" ) ;
// CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/preview.js
/ * *
* External dependencies
* /
/ * *
* WordPress dependencies
* /
function Preview ( {
idBase ,
instance ,
isVisible
} ) {
2021-07-06 10:38:40 -04:00
const [ isLoaded , setIsLoaded ] = Object ( external _wp _element _ [ "useState" ] ) ( false ) ; // Resize the iframe on either the load event, or when the iframe becomes visible.
2021-06-15 04:52:30 -04:00
const ref = Object ( external _wp _compose _ [ "useRefEffect" ] ) ( iframe => {
2021-07-06 10:38:40 -04: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.
if ( isLoaded ) {
// 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.
function setHeight ( ) {
// Pick the maximum of these two values to account for margin collapsing.
const height = Math . max ( iframe . contentDocument . documentElement . offsetHeight , iframe . contentDocument . body . offsetHeight ) ;
iframe . style . height = ` ${ height } px ` ;
2021-06-15 04:52:30 -04:00
}
2021-07-06 10:38:40 -04: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-06-15 04:52:30 -04:00
2021-07-06 10:38:40 -04:00
const intersectionObserver = new IntersectionObserver ( ( [ entry ] ) => {
if ( entry . isIntersecting ) {
setHeight ( ) ;
}
} , {
threshold : 1
} ) ;
intersectionObserver . observe ( iframe ) ;
iframe . addEventListener ( 'load' , setHeight ) ;
return ( ) => {
intersectionObserver . disconnect ( ) ;
iframe . removeEventListener ( 'load' , setHeight ) ;
} ;
}
} , [ isLoaded ] ) ;
return Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _element _ [ "Fragment" ] , null , isVisible && ! isLoaded && Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Placeholder" ] , null , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Spinner" ] , null ) ) , Object ( external _wp _element _ [ "createElement" ] ) ( "div" , {
2021-06-15 04:52:30 -04:00
className : classnames _default ( ) ( 'wp-block-legacy-widget__edit-preview' , {
2021-07-06 10:38:40 -04:00
'is-offscreen' : ! isVisible || ! isLoaded
2021-06-15 04:52:30 -04:00
} )
} , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Disabled" ] , null , Object ( external _wp _element _ [ "createElement" ] ) ( "iframe" , {
ref : ref ,
className : "wp-block-legacy-widget__edit-preview-iframe" ,
title : Object ( external _wp _i18n _ [ "__" ] ) ( 'Legacy Widget Preview' ) // TODO: This chokes when the query param is too big.
// Ideally, we'd render a <ServerSideRender>. Maybe by
// rendering one in an iframe via a portal.
,
src : Object ( external _wp _url _ [ "addQueryArgs" ] ) ( 'widgets.php' , {
'legacy-widget-preview' : {
idBase ,
instance
}
} ) ,
2021-07-06 10:38:40 -04: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 04:52:30 -04:00
} ) ) ) ) ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/no-preview.js
/ * *
* WordPress dependencies
* /
function NoPreview ( {
name
} ) {
return Object ( external _wp _element _ [ "createElement" ] ) ( "div" , {
className : "wp-block-legacy-widget__edit-no-preview"
} , name && Object ( external _wp _element _ [ "createElement" ] ) ( "h3" , null , name ) , Object ( external _wp _element _ [ "createElement" ] ) ( "p" , null , Object ( external _wp _i18n _ [ "__" ] ) ( 'No preview available.' ) ) ) ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/convert-to-blocks-button.js
/ * *
* WordPress dependencies
* /
function ConvertToBlocksButton ( {
clientId ,
rawInstance
} ) {
const {
replaceBlocks
} = Object ( external _wp _data _ [ "useDispatch" ] ) ( external _wp _blockEditor _ [ "store" ] ) ;
return Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "ToolbarButton" ] , {
onClick : ( ) => {
if ( rawInstance . title ) {
replaceBlocks ( clientId , [ Object ( external _wp _blocks _ [ "createBlock" ] ) ( 'core/heading' , {
content : rawInstance . title
} ) , ... Object ( external _wp _blocks _ [ "rawHandler" ] ) ( {
HTML : rawInstance . text
} ) ] ) ;
} else {
replaceBlocks ( clientId , Object ( external _wp _blocks _ [ "rawHandler" ] ) ( {
HTML : rawInstance . text
} ) ) ;
}
}
} , Object ( external _wp _i18n _ [ "__" ] ) ( 'Convert to blocks' ) ) ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/index.js
/ * *
* External dependencies
* /
/ * *
* WordPress dependencies
* /
/ * *
* Internal dependencies
* /
function Edit ( props ) {
const {
id ,
idBase
} = props . attributes ;
const {
isWide = false
} = props ;
const blockProps = Object ( external _wp _blockEditor _ [ "useBlockProps" ] ) ( {
className : classnames _default ( ) ( {
'is-wide-widget' : isWide
} )
} ) ;
return Object ( external _wp _element _ [ "createElement" ] ) ( "div" , blockProps , ! id && ! idBase ? Object ( external _wp _element _ [ "createElement" ] ) ( Empty , props ) : Object ( external _wp _element _ [ "createElement" ] ) ( NotEmpty , props ) ) ;
}
function Empty ( {
attributes : {
id ,
idBase
} ,
setAttributes
} ) {
return Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Placeholder" ] , {
icon : Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _blockEditor _ [ "BlockIcon" ] , {
icon : library _brush
} ) ,
label : Object ( external _wp _i18n _ [ "__" ] ) ( 'Legacy Widget' )
} , Object ( external _wp _element _ [ "createElement" ] ) ( WidgetTypeSelector , {
selectedId : id !== null && id !== void 0 ? id : idBase ,
onSelect : ( {
selectedId ,
isMulti
} ) => {
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
} ) ;
}
}
} ) ) ;
}
function NotEmpty ( {
attributes : {
id ,
idBase ,
instance
} ,
setAttributes ,
clientId ,
isSelected ,
isWide = false
} ) {
const [ hasPreview , setHasPreview ] = Object ( external _wp _element _ [ "useState" ] ) ( null ) ;
const {
widgetType ,
hasResolvedWidgetType ,
isNavigationMode
} = Object ( external _wp _data _ [ "useSelect" ] ) ( select => {
const widgetTypeId = id !== null && id !== void 0 ? id : idBase ;
return {
widgetType : select ( external _wp _coreData _ [ "store" ] ) . getWidgetType ( widgetTypeId ) ,
hasResolvedWidgetType : select ( external _wp _coreData _ [ "store" ] ) . hasFinishedResolution ( 'getWidgetType' , [ widgetTypeId ] ) ,
isNavigationMode : select ( external _wp _blockEditor _ [ "store" ] ) . isNavigationMode ( )
} ;
} , [ id , idBase ] ) ;
const setInstance = Object ( external _wp _element _ [ "useCallback" ] ) ( nextInstance => {
setAttributes ( {
instance : nextInstance
} ) ;
} , [ ] ) ;
if ( ! widgetType && hasResolvedWidgetType ) {
return Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Placeholder" ] , {
icon : Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _blockEditor _ [ "BlockIcon" ] , {
icon : library _brush
} ) ,
label : Object ( external _wp _i18n _ [ "__" ] ) ( 'Legacy Widget' )
} , Object ( external _wp _i18n _ [ "__" ] ) ( 'Widget is missing.' ) ) ;
}
if ( ! hasResolvedWidgetType ) {
return Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Placeholder" ] , null , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Spinner" ] , null ) ) ;
}
2021-06-28 12:01:36 -04:00
const mode = idBase && ( isNavigationMode || ! isSelected ) ? 'preview' : 'edit' ;
2021-06-22 06:00:50 -04:00
return Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _element _ [ "Fragment" ] , null , idBase === 'text' && Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _blockEditor _ [ "BlockControls" ] , {
2021-06-15 04:52:30 -04:00
group : "other"
} , Object ( external _wp _element _ [ "createElement" ] ) ( ConvertToBlocksButton , {
clientId : clientId ,
rawInstance : instance . raw
} ) ) , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _blockEditor _ [ "InspectorControls" ] , null , Object ( external _wp _element _ [ "createElement" ] ) ( InspectorCard , {
name : widgetType . name ,
description : widgetType . description
} ) ) , Object ( external _wp _element _ [ "createElement" ] ) ( Form , {
title : widgetType . name ,
isVisible : mode === 'edit' ,
id : id ,
idBase : idBase ,
instance : instance ,
isWide : isWide ,
onChangeInstance : setInstance ,
onChangeHasPreview : setHasPreview
} ) , idBase && Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _element _ [ "Fragment" ] , null , hasPreview === null && mode === 'preview' && Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Placeholder" ] , null , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "Spinner" ] , null ) ) , hasPreview === true && Object ( external _wp _element _ [ "createElement" ] ) ( Preview , {
idBase : idBase ,
instance : instance ,
isVisible : mode === 'preview'
} ) , hasPreview === false && mode === 'preview' && Object ( external _wp _element _ [ "createElement" ] ) ( NoPreview , {
name : widgetType . name
} ) ) ) ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/transforms.js
/ * *
* WordPress dependencies
* /
const legacyWidgetTransforms = [ {
block : 'core/calendar' ,
widget : 'calendar'
} , {
block : 'core/search' ,
widget : 'search'
} , {
block : 'core/html' ,
2021-06-22 06:00:50 -04:00
widget : 'custom_html' ,
2021-06-15 04:52:30 -04:00
transform : ( {
content
} ) => ( {
content
} )
} , {
block : 'core/archives' ,
widget : 'archives' ,
transform : ( {
count ,
dropdown
} ) => {
return {
displayAsDropdown : ! ! dropdown ,
showPostCounts : ! ! count
} ;
}
} , {
block : 'core/latest-posts' ,
widget : 'recent-posts' ,
transform : ( {
show _date : displayPostDate ,
number
} ) => {
return {
displayPostDate : ! ! displayPostDate ,
postsToShow : number
} ;
}
} , {
block : 'core/latest-comments' ,
widget : 'recent-comments' ,
transform : ( {
number
} ) => {
return {
commentsToShow : number
} ;
}
} , {
block : 'core/tag-cloud' ,
widget : 'tag_cloud' ,
transform : ( {
taxonomy ,
count
} ) => {
return {
showTagCounts : ! ! count ,
taxonomy
} ;
}
} , {
block : 'core/categories' ,
widget : 'categories' ,
transform : ( {
count ,
dropdown ,
hierarchical
} ) => {
return {
displayAsDropdown : ! ! dropdown ,
showPostCounts : ! ! count ,
showHierarchy : ! ! hierarchical
} ;
}
} , {
block : 'core/audio' ,
widget : 'media_audio' ,
transform : ( {
url ,
preload ,
loop ,
attachment _id : id
} ) => {
return {
src : url ,
id ,
preload ,
loop
} ;
}
} , {
block : 'core/video' ,
widget : 'media_video' ,
transform : ( {
url ,
preload ,
loop ,
attachment _id : id
} ) => {
return {
src : url ,
id ,
preload ,
loop
} ;
}
} , {
block : 'core/image' ,
widget : 'media_image' ,
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
} ) => {
return {
alt ,
caption ,
height ,
id ,
link ,
linkClass ,
linkDestination ,
linkTarget : targetBlack ? '_blank' : undefined ,
rel ,
sizeSlug ,
url ,
width
} ;
}
} , {
block : 'core/gallery' ,
widget : 'media_gallery' ,
transform : ( {
ids ,
link _type : linkTo ,
size ,
number
} ) => {
return {
ids ,
columns : number ,
linkTo ,
sizeSlug : size ,
images : ids . map ( id => ( {
id
} ) )
} ;
}
} , {
block : 'core/rss' ,
widget : 'rss' ,
transform : ( {
url ,
show _author : displayAuthor ,
show _date : displayDate ,
show _summary : displayExcerpt ,
items
} ) => {
return {
feedURL : url ,
displayAuthor : ! ! displayAuthor ,
displayDate : ! ! displayDate ,
displayExcerpt : ! ! displayExcerpt ,
itemsToShow : items
} ;
}
} ] . map ( ( {
block ,
widget ,
transform
} ) => {
return {
type : 'block' ,
blocks : [ block ] ,
isMatch : ( {
idBase ,
instance
} ) => {
return idBase === widget && ! ! ( instance !== null && instance !== void 0 && instance . raw ) ;
} ,
transform : ( {
instance
} ) => {
var _instance$raw ;
const transformedBlock = Object ( external _wp _blocks _ [ "createBlock" ] ) ( block , transform ? transform ( instance . raw ) : undefined ) ;
if ( ! ( ( _instance$raw = instance . raw ) !== null && _instance$raw !== void 0 && _instance$raw . title ) ) {
return transformedBlock ;
}
return [ Object ( external _wp _blocks _ [ "createBlock" ] ) ( 'core/heading' , {
content : instance . raw . title
} ) , transformedBlock ] ;
}
} ;
} ) ;
const transforms = {
to : legacyWidgetTransforms
} ;
/* harmony default export */ var legacy _widget _transforms = ( transforms ) ;
// CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/index.js
/ * *
* WordPress dependencies
* /
/ * *
* Internal dependencies
* /
const legacy _widget _metadata = {
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
} = legacy _widget _metadata ;
const legacy _widget _settings = {
icon : library _widget ,
edit : Edit ,
transforms : legacy _widget _transforms
} ;
2021-05-25 04:40:25 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/move-to.js
/ * *
* WordPress dependencies
* /
const moveTo = Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _primitives _ [ "SVG" ] , {
xmlns : "http://www.w3.org/2000/svg" ,
viewBox : "0 0 24 24"
} , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _primitives _ [ "Path" ] , {
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 ) ;
// CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/components/move-to-widget-area/index.js
/ * *
* WordPress dependencies
* /
function MoveToWidgetArea ( {
currentWidgetAreaId ,
widgetAreas ,
onSelect
} ) {
return Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "ToolbarGroup" ] , null , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "ToolbarItem" ] , null , toggleProps => Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "DropdownMenu" ] , {
icon : move _to ,
label : Object ( external _wp _i18n _ [ "__" ] ) ( 'Move to widget area' ) ,
toggleProps : toggleProps
} , ( {
onClose
} ) => Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "MenuGroup" ] , {
label : Object ( external _wp _i18n _ [ "__" ] ) ( 'Move to' )
} , Object ( external _wp _element _ [ "createElement" ] ) ( external _wp _components _ [ "MenuItemsChoice" ] , {
choices : widgetAreas . map ( widgetArea => ( {
value : widgetArea . id ,
label : widgetArea . name ,
info : widgetArea . description
} ) ) ,
value : currentWidgetAreaId ,
onSelect : value => {
onSelect ( value ) ;
onClose ( ) ;
}
} ) ) ) ) ) ;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/components/index.js
2021-06-15 04:52:30 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/utils.js
// @ts-check
2021-05-25 04:40:25 -04:00
2021-06-15 04:52:30 -04:00
/ * *
* Get the internal widget id from block .
*
* @ typedef { Object } Attributes
* @ property { string } _ _internalWidgetId The internal widget id .
* @ typedef { Object } Block
* @ property { Attributes } attributes The attributes of the block .
*
* @ param { Block } block The block .
* @ return { string } The internal widget id .
* /
function getWidgetIdFromBlock ( block ) {
return block . attributes . _ _internalWidgetId ;
}
/ * *
* Add internal widget id to block ' s attributes .
*
* @ param { Block } block The block .
* @ param { string } widgetId The widget id .
* @ return { Block } The updated block .
* /
2021-05-25 04:40:25 -04:00
2021-06-15 04:52:30 -04:00
function addWidgetIdToBlock ( block , widgetId ) {
return { ... block ,
attributes : { ... ( block . attributes || { } ) ,
_ _internalWidgetId : widgetId
}
} ;
}
2021-05-25 04:40:25 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/register-legacy-widget-variations.js
/ * *
* WordPress dependencies
* /
function registerLegacyWidgetVariations ( settings ) {
const unsubscribe = Object ( external _wp _data _ [ "subscribe" ] ) ( ( ) => {
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 : [ ] ;
const widgetTypes = ( _select$getWidgetType = Object ( external _wp _data _ [ "select" ] ) ( external _wp _coreData _ [ "store" ] ) . getWidgetTypes ( {
per _page : - 1
} ) ) === null || _select$getWidgetType === void 0 ? void 0 : _select$getWidgetType . filter ( widgetType => ! hiddenIds . includes ( widgetType . id ) ) ;
if ( widgetTypes ) {
unsubscribe ( ) ;
Object ( external _wp _data _ [ "dispatch" ] ) ( external _wp _blocks _ [ "store" ] ) . addBlockVariations ( 'core/legacy-widget' , widgetTypes . map ( widgetType => ( {
name : widgetType . id ,
title : widgetType . name ,
description : widgetType . description ,
attributes : widgetType . is _multi ? {
idBase : widgetType . id ,
instance : { }
} : {
id : widgetType . id
}
} ) ) ) ;
}
} ) ;
}
2021-06-15 04:52:30 -04:00
// CONCATENATED MODULE: ./node_modules/@wordpress/widgets/build-module/index.js
2021-05-25 04:40:25 -04:00
/ * *
2021-06-15 04:52:30 -04:00
* WordPress dependencies
2021-05-25 04:40:25 -04:00
* /
2021-06-15 04:52:30 -04:00
2021-05-25 04:40:25 -04:00
/ * *
2021-06-15 04:52:30 -04:00
* Internal dependencies
2021-05-25 04:40:25 -04:00
* /
2021-06-15 04:52:30 -04: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 .
*
* @ see https : //developer.wordpress.org/block-editor/how-to-guides/widgets/legacy-widget-block/
* /
function registerLegacyWidgetBlock ( ) {
const {
metadata ,
settings ,
name
} = legacy _widget _namespaceObject ;
Object ( external _wp _blocks _ [ "registerBlockType" ] ) ( {
name ,
... metadata
} , settings ) ;
}
2021-05-25 04:40:25 -04:00
/***/ } ) ,
/***/ "GRId" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "element" ] ; } ( ) ) ;
/***/ } ) ,
/***/ "HSyU" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "blocks" ] ; } ( ) ) ;
2021-06-15 04:52:30 -04:00
/***/ } ) ,
/***/ "K9lf" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "compose" ] ; } ( ) ) ;
/***/ } ) ,
/***/ "Mmq9" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "url" ] ; } ( ) ) ;
/***/ } ) ,
/***/ "TSYQ" :
/***/ ( function ( module , exports , _ _webpack _require _ _ ) {
var _ _WEBPACK _AMD _DEFINE _ARRAY _ _ , _ _WEBPACK _AMD _DEFINE _RESULT _ _ ; / * !
Copyright ( c ) 2018 Jed Watson .
Licensed under the MIT License ( MIT ) , see
http : //jedwatson.github.io/classnames
* /
/* global define */
( function ( ) {
'use strict' ;
var hasOwn = { } . hasOwnProperty ;
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' ) {
if ( arg . toString === Object . prototype . toString ) {
for ( var key in arg ) {
if ( hasOwn . call ( arg , key ) && arg [ key ] ) {
classes . push ( key ) ;
}
}
} else {
classes . push ( arg . toString ( ) ) ;
}
}
}
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 04:40:25 -04:00
/***/ } ) ,
/***/ "Tqx9" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "primitives" ] ; } ( ) ) ;
/***/ } ) ,
2021-06-15 04:52:30 -04:00
/***/ "YLtl" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "lodash" ] ; } ( ) ) ;
/***/ } ) ,
/***/ "axFQ" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "blockEditor" ] ; } ( ) ) ;
/***/ } ) ,
2021-05-25 04:40:25 -04:00
/***/ "jZUy" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "coreData" ] ; } ( ) ) ;
/***/ } ) ,
/***/ "l3Sj" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "i18n" ] ; } ( ) ) ;
/***/ } ) ,
2021-06-15 04:52:30 -04:00
/***/ "onLe" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "notices" ] ; } ( ) ) ;
/***/ } ) ,
2021-05-25 04:40:25 -04:00
/***/ "tI+e" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "components" ] ; } ( ) ) ;
2021-06-15 04:52:30 -04:00
/***/ } ) ,
/***/ "ywyh" :
/***/ ( function ( module , exports ) {
( function ( ) { module . exports = window [ "wp" ] [ "apiFetch" ] ; } ( ) ) ;
2021-05-25 04:40:25 -04:00
/***/ } )
/******/ } ) ;