2024-01-31 07:59:56 -05:00
/******/ ( ( ) => { // webpackBootstrap
2024-05-23 15:39:28 -04:00
/******/ "use strict" ;
/******/ // The require scope
/******/ var _ _webpack _require _ _ = { } ;
2022-04-11 08:04:30 -04:00
/******/
2021-05-25 04:40:25 -04:00
/************************************************************************/
2022-04-11 08:04:30 -04:00
/******/ /* webpack/runtime/compat get default export */
2024-01-31 07:59:56 -05:00
/******/ ( ( ) => {
2022-04-11 08:04:30 -04:00
/******/ // getDefaultExport function for compatibility with non-harmony modules
2024-01-31 07:59:56 -05:00
/******/ _ _webpack _require _ _ . n = ( module ) => {
2022-04-11 08:04:30 -04:00
/******/ var getter = module && module . _ _esModule ?
2024-01-31 07:59:56 -05:00
/******/ ( ) => ( module [ 'default' ] ) :
/******/ ( ) => ( module ) ;
2022-04-11 08:04:30 -04:00
/******/ _ _webpack _require _ _ . d ( getter , { a : getter } ) ;
/******/ return getter ;
/******/ } ;
2024-01-31 07:59:56 -05:00
/******/ } ) ( ) ;
2022-04-11 08:04:30 -04:00
/******/
/******/ /* webpack/runtime/define property getters */
2024-01-31 07:59:56 -05:00
/******/ ( ( ) => {
2022-04-11 08:04:30 -04:00
/******/ // define getter functions for harmony exports
2024-01-31 07:59:56 -05:00
/******/ _ _webpack _require _ _ . d = ( exports , definition ) => {
2022-04-11 08:04:30 -04: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 ] } ) ;
/******/ }
/******/ }
/******/ } ;
2024-01-31 07:59:56 -05:00
/******/ } ) ( ) ;
2022-04-11 08:04:30 -04:00
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
2024-01-31 07:59:56 -05:00
/******/ ( ( ) => {
/******/ _ _webpack _require _ _ . o = ( obj , prop ) => ( Object . prototype . hasOwnProperty . call ( obj , prop ) )
/******/ } ) ( ) ;
2022-04-11 08:04:30 -04:00
/******/
/******/ /* webpack/runtime/make namespace object */
2024-01-31 07:59:56 -05:00
/******/ ( ( ) => {
2022-04-11 08:04:30 -04:00
/******/ // define __esModule on exports
2024-01-31 07:59:56 -05:00
/******/ _ _webpack _require _ _ . r = ( exports ) => {
2022-04-11 08:04:30 -04:00
/******/ if ( typeof Symbol !== 'undefined' && Symbol . toStringTag ) {
/******/ Object . defineProperty ( exports , Symbol . toStringTag , { value : 'Module' } ) ;
/******/ }
/******/ Object . defineProperty ( exports , '__esModule' , { value : true } ) ;
/******/ } ;
2024-01-31 07:59:56 -05:00
/******/ } ) ( ) ;
2022-04-11 08:04:30 -04:00
/******/
/************************************************************************/
var _ _webpack _exports _ _ = { } ;
2021-05-25 04:40:25 -04:00
// ESM COMPAT FLAG
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
// EXPORTS
2022-04-11 08:04:30 -04:00
_ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
2024-01-31 07:59:56 -05:00
MoveToWidgetArea : ( ) => ( /* reexport */ MoveToWidgetArea ) ,
addWidgetIdToBlock : ( ) => ( /* reexport */ addWidgetIdToBlock ) ,
getWidgetIdFromBlock : ( ) => ( /* reexport */ getWidgetIdFromBlock ) ,
registerLegacyWidgetBlock : ( ) => ( /* binding */ registerLegacyWidgetBlock ) ,
registerLegacyWidgetVariations : ( ) => ( /* reexport */ registerLegacyWidgetVariations ) ,
registerWidgetGroupBlock : ( ) => ( /* binding */ registerWidgetGroupBlock )
2022-04-11 08:04:30 -04:00
} ) ;
2021-06-15 04:52:30 -04: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 08:04:30 -04:00
_ _webpack _require _ _ . d ( legacy _widget _namespaceObject , {
2024-12-13 14:06:24 -05:00
yu : ( ) => ( metadata ) ,
UU : ( ) => ( legacy _widget _name ) ,
W0 : ( ) => ( settings )
2022-04-11 08:04:30 -04:00
} ) ;
2021-06-15 04:52:30 -04:00
2021-11-08 09:29:21 -05: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 08:04:30 -04:00
_ _webpack _require _ _ . d ( widget _group _namespaceObject , {
2024-12-13 14:06:24 -05:00
yu : ( ) => ( widget _group _metadata ) ,
UU : ( ) => ( widget _group _name ) ,
W0 : ( ) => ( widget _group _settings )
2022-04-11 08:04:30 -04:00
} ) ;
2021-06-15 04:52:30 -04:00
2024-12-13 14:06:24 -05:00
; // external ["wp","blocks"]
2024-01-31 07:59:56 -05:00
const external _wp _blocks _namespaceObject = window [ "wp" ] [ "blocks" ] ;
2024-12-13 14:06:24 -05:00
; // external ["wp","primitives"]
2024-01-31 07:59:56 -05:00
const external _wp _primitives _namespaceObject = window [ "wp" ] [ "primitives" ] ;
2024-12-13 14:06:24 -05:00
; // external "ReactJSXRuntime"
2024-05-31 14:59:00 -04:00
const external _ReactJSXRuntime _namespaceObject = window [ "ReactJSXRuntime" ] ;
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/icons/build-module/library/widget.js
2021-06-15 04:52:30 -04:00
/ * *
* WordPress dependencies
* /
2024-05-31 14:59:00 -04:00
const widget = /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _primitives _namespaceObject . SVG , {
2021-07-06 10:38:40 -04:00
xmlns : "http://www.w3.org/2000/svg" ,
2024-05-31 14:59:00 -04:00
viewBox : "0 0 24 24" ,
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _primitives _namespaceObject . Path , {
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"
} )
} ) ;
2024-01-31 07:59:56 -05:00
/* harmony default export */ const library _widget = ( widget ) ;
2021-06-15 04:52:30 -04:00
2024-12-13 14:06:24 -05:00
; // ./node_modules/clsx/dist/clsx.mjs
2024-05-23 15:39:28 -04:00
function r ( e ) { var t , f , n = "" ; if ( "string" == typeof e || "number" == typeof e ) n += e ; else if ( "object" == typeof e ) if ( Array . isArray ( e ) ) { var o = e . length ; for ( t = 0 ; t < o ; t ++ ) e [ t ] && ( f = r ( e [ t ] ) ) && ( n && ( n += " " ) , n += f ) } else for ( f in e ) e [ f ] && ( n && ( n += " " ) , n += f ) ; return n } function clsx ( ) { for ( var e , t , f = 0 , n = "" , o = arguments . length ; f < o ; f ++ ) ( e = arguments [ f ] ) && ( t = r ( e ) ) && ( n && ( n += " " ) , n += t ) ; return n } /* harmony default export */ const dist _clsx = ( clsx ) ;
2024-12-13 14:06:24 -05:00
; // external ["wp","blockEditor"]
2024-01-31 07:59:56 -05:00
const external _wp _blockEditor _namespaceObject = window [ "wp" ] [ "blockEditor" ] ;
2024-12-13 14:06:24 -05:00
; // external ["wp","components"]
2024-01-31 07:59:56 -05:00
const external _wp _components _namespaceObject = window [ "wp" ] [ "components" ] ;
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/icons/build-module/library/brush.js
2021-06-15 04:52:30 -04:00
/ * *
* WordPress dependencies
* /
2024-05-31 14:59:00 -04:00
const brush = /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _primitives _namespaceObject . SVG , {
2021-06-15 04:52:30 -04:00
xmlns : "http://www.w3.org/2000/svg" ,
2024-05-31 14:59:00 -04:00
viewBox : "0 0 24 24" ,
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _primitives _namespaceObject . 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"
} )
} ) ;
2024-01-31 07:59:56 -05:00
/* harmony default export */ const library _brush = ( brush ) ;
2021-06-15 04:52:30 -04:00
2024-12-13 14:06:24 -05:00
; // external ["wp","i18n"]
2024-01-31 07:59:56 -05:00
const external _wp _i18n _namespaceObject = window [ "wp" ] [ "i18n" ] ;
2024-12-13 14:06:24 -05:00
; // external ["wp","element"]
2024-01-31 07:59:56 -05:00
const external _wp _element _namespaceObject = window [ "wp" ] [ "element" ] ;
2024-12-13 14:06:24 -05:00
; // external ["wp","data"]
2024-01-31 07:59:56 -05:00
const external _wp _data _namespaceObject = window [ "wp" ] [ "data" ] ;
2024-12-13 14:06:24 -05:00
; // external ["wp","coreData"]
2024-01-31 07:59:56 -05:00
const external _wp _coreData _namespaceObject = window [ "wp" ] [ "coreData" ] ;
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/widget-type-selector.js
2021-06-15 04:52:30 -04:00
/ * *
* WordPress dependencies
* /
2024-05-31 14:59:00 -04:00
2023-06-27 10:24:19 -04:00
function WidgetTypeSelector ( {
selectedId ,
onSelect
} ) {
2022-04-11 08:04:30 -04:00
const widgetTypes = ( 0 , external _wp _data _namespaceObject . useSelect ) ( select => {
2023-06-27 10:24:19 -04:00
var _select$getSettings$w ;
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 04:52:30 -04:00
per _page : - 1
2023-06-27 10:24:19 -04:00
} ) ? . filter ( widgetType => ! hiddenIds . includes ( widgetType . id ) ) ;
2021-06-15 04:52:30 -04:00
} , [ ] ) ;
if ( ! widgetTypes ) {
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . Spinner , { } ) ;
2021-06-15 04:52:30 -04:00
}
if ( widgetTypes . length === 0 ) {
2022-04-11 08:04:30 -04:00
return ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'There are no widgets available.' ) ;
2021-06-15 04:52:30 -04:00
}
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . SelectControl , {
2024-09-19 21:55:35 -04:00
_ _next40pxDefaultSize : true ,
2023-02-07 02:04:52 -05:00
_ _nextHasNoMarginBottom : true ,
2024-09-19 21:55:35 -04:00
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Legacy widget' ) ,
2021-06-15 04:52:30 -04:00
value : selectedId !== null && selectedId !== void 0 ? selectedId : '' ,
options : [ {
value : '' ,
2022-04-11 08:04:30 -04:00
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Select widget' )
2021-06-15 04:52:30 -04: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
} ) ;
}
}
} ) ;
}
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/inspector-card.js
2021-06-15 04:52:30 -04:00
2024-05-31 14:59:00 -04:00
2023-06-27 10:24:19 -04:00
function InspectorCard ( {
name ,
description
} ) {
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( "div" , {
className : "wp-block-legacy-widget-inspector-card" ,
children : [ /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( "h3" , {
className : "wp-block-legacy-widget-inspector-card__name" ,
children : name
} ) , /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( "span" , {
children : description
} ) ]
} ) ;
2021-06-15 04:52:30 -04:00
}
2024-12-13 14:06:24 -05:00
; // external ["wp","notices"]
2024-01-31 07:59:56 -05:00
const external _wp _notices _namespaceObject = window [ "wp" ] [ "notices" ] ;
2024-12-13 14:06:24 -05:00
; // external ["wp","compose"]
2024-01-31 07:59:56 -05:00
const external _wp _compose _namespaceObject = window [ "wp" ] [ "compose" ] ;
2024-12-13 14:06:24 -05:00
; // external ["wp","apiFetch"]
2024-01-31 07:59:56 -05:00
const external _wp _apiFetch _namespaceObject = window [ "wp" ] [ "apiFetch" ] ;
2022-04-11 08:04:30 -04:00
var external _wp _apiFetch _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( external _wp _apiFetch _namespaceObject ) ;
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/control.js
2024-09-19 21:55:35 -04:00
/* wp:polyfill */
2021-06-15 04:52:30 -04:00
/ * *
* WordPress dependencies
* /
2023-09-26 10:23:26 -04:00
2021-06-15 04:52:30 -04:00
/ * *
* 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 08:04:30 -04:00
class Control {
2021-06-15 04:52:30 -04:00
/ * *
* Creates and loads a new control .
*
* @ access public
2021-11-08 09:29:21 -05:00
* @ param { Object } params
* @ param { string } params . id
* @ param { string } params . idBase
* @ param { Object } params . instance
2021-06-15 04:52:30 -04:00
* @ param { Function } params . onChangeInstance
* @ param { Function } params . onChangeHasPreview
* @ param { Function } params . onError
* /
2023-06-27 10:24:19 -04:00
constructor ( {
id ,
idBase ,
instance ,
onChangeInstance ,
onChangeHasPreview ,
onError
} ) {
2021-06-15 04:52:30 -04:00
this . id = id ;
this . idBase = idBase ;
this . _instance = instance ;
this . _hasPreview = null ;
this . onChangeInstance = onChangeInstance ;
this . onChangeHasPreview = onChangeHasPreview ;
2023-09-26 10:23:26 -04:00
this . onError = onError ;
// We can't use the real widget number as this is calculated by the
2021-06-15 04:52:30 -04:00
// server and we may not ever *actually* save this widget. Instead, use
// a fake but unique number.
this . number = ++ lastNumber ;
2023-02-07 02:04:52 -05:00
this . handleFormChange = ( 0 , external _wp _compose _namespaceObject . 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 ( ) ;
}
2023-09-26 10:23:26 -04:00
2021-06-15 04:52:30 -04:00
/ * *
* Clean up the control so that it can be garabge collected .
*
* @ access public
* /
destroy ( ) {
this . unbindEvents ( ) ;
2023-09-26 10:23:26 -04:00
this . element . remove ( ) ;
// TODO: How do we make third party widget scripts remove their event
2021-06-15 04:52:30 -04:00
// listeners?
}
2023-09-26 10:23:26 -04:00
2021-06-15 04:52:30 -04:00
/ * *
* 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'
2023-09-26 10:23:26 -04:00
} , [
// These hidden form inputs are what most widgets' scripts
2021-06-15 04:52:30 -04:00
// 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'
2023-09-26 10:23:26 -04:00
} ) ,
// Non-multi widgets can be saved via a Save button.
2021-06-15 04:52:30 -04:00
this . id && el ( 'button' , {
class : 'button is-primary' ,
type : 'submit'
2022-04-11 08:04:30 -04:00
} , ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Save' ) ) ] ) ] ) ] ) ;
2021-06-15 04:52:30 -04:00
}
2023-09-26 10:23:26 -04:00
2021-06-15 04:52:30 -04: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 ) ;
}
}
2023-09-26 10:23:26 -04:00
2021-06-15 04:52:30 -04:00
/ * *
* 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 ) ;
}
}
2023-09-26 10:23:26 -04:00
2021-06-15 04:52:30 -04:00
/ * *
* 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 ;
2023-09-26 10:23:26 -04:00
this . hasPreview = ! isEmptyHTML ( preview ) ;
2021-06-15 04:52:30 -04:00
2023-09-26 10:23:26 -04:00
// If we don't have an instance, perform a save right away. This
// happens when creating a new Legacy Widget block.
2021-06-15 04:52:30 -04:00
if ( ! this . instance . hash ) {
const {
instance
} = await encodeWidget ( {
idBase : this . idBase ,
instance : this . instance ,
number : this . number ,
formData : serializeForm ( this . form )
} ) ;
this . instance = instance ;
}
2023-09-26 10:23:26 -04:00
}
// Trigger 'widget-added' when widget is ready. This event is what
2021-06-15 04:52:30 -04:00
// 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 ) ;
}
}
2023-09-26 10:23:26 -04:00
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 ( ) ;
}
}
2023-09-26 10:23:26 -04:00
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 ( ) ;
}
2023-09-26 10:23:26 -04:00
2021-06-15 04:52:30 -04:00
/ * *
* 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 ) ;
}
}
2023-09-26 10:23:26 -04:00
2021-06-15 04:52:30 -04:00
/ * *
* The widget ' s instance object .
*
* @ access private
* /
get instance ( ) {
return this . _instance ;
}
2023-09-26 10:23:26 -04:00
2021-06-15 04:52:30 -04:00
/ * *
* The widget ' s instance object .
*
* @ access private
* /
set instance ( instance ) {
if ( this . _instance !== instance ) {
this . _instance = instance ;
this . onChangeInstance ( instance ) ;
}
}
2023-09-26 10:23:26 -04:00
2021-06-15 04:52:30 -04:00
/ * *
* Whether or not the widget can be previewed .
*
* @ access public
* /
get hasPreview ( ) {
return this . _hasPreview ;
}
2023-09-26 10:23:26 -04:00
2021-06-15 04:52:30 -04:00
/ * *
* 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 10:24:19 -04:00
function el ( tagName , attributes = { } , content = null ) {
2021-06-15 04:52:30 -04: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 10:24:19 -04:00
async function saveWidget ( id , formData = null ) {
2021-06-15 04:52:30 -04: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 10:24:19 -04:00
async function encodeWidget ( {
idBase ,
instance ,
number ,
formData = null
} ) {
2021-06-15 04:52:30 -04: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 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 ;
2023-09-26 10:23:26 -04:00
}
// Elements with no children are empty.
2021-06-15 11:30:24 -04:00
if ( ! node . hasChildNodes ( ) ) {
return true ;
2023-09-26 10:23:26 -04:00
}
// Elements with children are empty if all their children are empty.
2021-06-15 11:30:24 -04:00
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 ( ) ;
}
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/form.js
2021-06-15 04:52:30 -04:00
/ * *
* External dependencies
* /
/ * *
* WordPress dependencies
* /
/ * *
* Internal dependencies
* /
2024-05-31 14:59:00 -04:00
2023-06-27 10:24:19 -04:00
function Form ( {
title ,
isVisible ,
id ,
idBase ,
instance ,
isWide ,
onChangeInstance ,
onChangeHasPreview
} ) {
2022-04-11 08:04:30 -04:00
const ref = ( 0 , external _wp _element _namespaceObject . useRef ) ( ) ;
2023-09-26 10:23:26 -04:00
const isMediumLargeViewport = ( 0 , external _wp _compose _namespaceObject . useViewportMatch ) ( 'small' ) ;
// We only want to remount the control when the instance changes
2021-06-15 04:52:30 -04: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 08:04:30 -04:00
const outgoingInstances = ( 0 , external _wp _element _namespaceObject . useRef ) ( new Set ( ) ) ;
const incomingInstances = ( 0 , external _wp _element _namespaceObject . useRef ) ( new Set ( ) ) ;
2021-06-15 04:52:30 -04:00
const {
createNotice
2022-04-11 08:04:30 -04:00
} = ( 0 , external _wp _data _namespaceObject . useDispatch ) ( external _wp _notices _namespaceObject . store ) ;
( 0 , external _wp _element _namespaceObject . useEffect ) ( ( ) => {
2021-06-15 04:52:30 -04:00
if ( incomingInstances . current . has ( instance ) ) {
incomingInstances . current . delete ( instance ) ;
return ;
}
2022-04-11 08:04:30 -04:00
const control = new Control ( {
2021-06-15 04:52:30 -04:00
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 ) ;
2023-09-26 10:23:26 -04:00
createNotice ( 'error' , ( 0 , external _wp _i18n _namespaceObject . sprintf ) ( /* translators: %s: the name of the affected block. */
2022-04-11 08:04:30 -04: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 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 ) {
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( "div" , {
2024-05-23 15:39:28 -04:00
className : dist _clsx ( {
2021-06-15 04:52:30 -04:00
'wp-block-legacy-widget__container' : isVisible
2024-05-31 14:59:00 -04:00
} ) ,
children : [ isVisible && /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( "h3" , {
className : "wp-block-legacy-widget__edit-form-title" ,
children : title
} ) , /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . Popover , {
focusOnMount : false ,
placement : "right" ,
offset : 32 ,
resize : false ,
flip : false ,
shift : true ,
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( "div" , {
ref : ref ,
className : "wp-block-legacy-widget__edit-form" ,
hidden : ! isVisible
} )
} ) ]
} ) ;
2021-06-15 04:52:30 -04:00
}
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( "div" , {
2021-06-15 04:52:30 -04:00
ref : ref ,
className : "wp-block-legacy-widget__edit-form" ,
2024-05-31 14:59:00 -04:00
hidden : ! isVisible ,
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( "h3" , {
className : "wp-block-legacy-widget__edit-form-title" ,
children : title
} )
} ) ;
2021-06-15 04:52:30 -04:00
}
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/preview.js
2021-06-15 04:52:30 -04:00
/ * *
* External dependencies
* /
2023-09-26 10:23:26 -04:00
2021-06-15 04:52:30 -04:00
/ * *
* WordPress dependencies
* /
2024-05-31 14:59:00 -04:00
2023-06-27 10:24:19 -04:00
function Preview ( {
idBase ,
instance ,
isVisible
} ) {
2022-04-11 08:04:30 -04: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 09:29:21 -05: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 10:24:19 -04:00
signal : abortController ? . signal ,
2021-11-08 09:29:21 -05: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 10:24:19 -04:00
return ( ) => abortController ? . abort ( ) ;
2023-09-26 10:23:26 -04:00
} , [ idBase , instance ] ) ;
2021-06-15 04:52:30 -04:00
2023-09-26 10:23:26 -04:00
// Resize the iframe on either the load event, or when the iframe becomes visible.
2022-04-11 08:04:30 -04:00
const ref = ( 0 , external _wp _compose _namespaceObject . 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.
2021-11-08 09:29:21 -05:00
if ( ! isLoaded ) {
return ;
2023-09-26 10:23:26 -04:00
}
// If the preview frame has another origin then this won't work.
2021-11-08 09:29:21 -05:00
// 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 ( ) {
2023-06-27 10:24:19 -04:00
var _iframe$contentDocume , _iframe$contentDocume2 ;
2021-11-08 09:29:21 -05:00
// Pick the maximum of these two values to account for margin collapsing.
2023-09-26 10:23:26 -04: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 02:04:52 -05: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 10:38:40 -04:00
}
2021-11-08 09:29:21 -05:00
const {
IntersectionObserver
2023-09-26 10:23:26 -04:00
} = iframe . ownerDocument . defaultView ;
2021-11-08 09:29:21 -05:00
2023-09-26 10:23:26 -04:00
// Observe for intersections that might cause a change in the height of
// the iframe, e.g. a Widget Area becoming expanded.
2023-06-27 10:24:19 -04:00
const intersectionObserver = new IntersectionObserver ( ( [ entry ] ) => {
2021-11-08 09:29:21 -05:00
if ( entry . isIntersecting ) {
setHeight ( ) ;
}
} , {
threshold : 1
} ) ;
intersectionObserver . observe ( iframe ) ;
iframe . addEventListener ( 'load' , setHeight ) ;
return ( ) => {
intersectionObserver . disconnect ( ) ;
iframe . removeEventListener ( 'load' , setHeight ) ;
} ;
2021-07-06 10:38:40 -04:00
} , [ isLoaded ] ) ;
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _ReactJSXRuntime _namespaceObject . Fragment , {
children : [ isVisible && ! isLoaded && /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . Placeholder , {
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . Spinner , { } )
} ) , /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( "div" , {
className : dist _clsx ( 'wp-block-legacy-widget__edit-preview' , {
'is-offscreen' : ! isVisible || ! isLoaded
} ) ,
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . Disabled , {
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( "iframe" , {
ref : ref ,
className : "wp-block-legacy-widget__edit-preview-iframe" ,
tabIndex : "-1" ,
title : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Legacy Widget Preview' ) ,
srcDoc : srcDoc ,
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
}
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/no-preview.js
2021-06-15 04:52:30 -04:00
/ * *
* WordPress dependencies
* /
2024-05-31 14:59:00 -04:00
2023-06-27 10:24:19 -04:00
function NoPreview ( {
name
} ) {
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( "div" , {
className : "wp-block-legacy-widget__edit-no-preview" ,
children : [ name && /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( "h3" , {
children : name
} ) , /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( "p" , {
children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'No preview available.' )
} ) ]
} ) ;
2021-06-15 04:52:30 -04:00
}
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/convert-to-blocks-button.js
2021-06-15 04:52:30 -04:00
/ * *
* WordPress dependencies
* /
2024-05-31 14:59:00 -04:00
2023-06-27 10:24:19 -04:00
function ConvertToBlocksButton ( {
clientId ,
rawInstance
} ) {
2021-06-15 04:52:30 -04:00
const {
replaceBlocks
2022-04-11 08:04:30 -04:00
} = ( 0 , external _wp _data _namespaceObject . useDispatch ) ( external _wp _blockEditor _namespaceObject . store ) ;
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . ToolbarButton , {
2021-06-15 04:52:30 -04:00
onClick : ( ) => {
if ( rawInstance . title ) {
2022-04-11 08:04:30 -04:00
replaceBlocks ( clientId , [ ( 0 , external _wp _blocks _namespaceObject . createBlock ) ( 'core/heading' , {
2021-06-15 04:52:30 -04:00
content : rawInstance . title
2022-04-11 08:04:30 -04:00
} ) , ... ( 0 , external _wp _blocks _namespaceObject . rawHandler ) ( {
2021-06-15 04:52:30 -04:00
HTML : rawInstance . text
} ) ] ) ;
} else {
2022-04-11 08:04:30 -04:00
replaceBlocks ( clientId , ( 0 , external _wp _blocks _namespaceObject . rawHandler ) ( {
2021-06-15 04:52:30 -04:00
HTML : rawInstance . text
} ) ) ;
}
2024-05-31 14:59:00 -04:00
} ,
children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Convert to blocks' )
} ) ;
2021-06-15 04:52:30 -04:00
}
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/edit/index.js
2021-06-15 04:52:30 -04:00
/ * *
* External dependencies
* /
2023-09-26 10:23:26 -04:00
2021-06-15 04:52:30 -04:00
/ * *
* WordPress dependencies
* /
/ * *
* Internal dependencies
* /
2024-05-31 14:59:00 -04:00
2021-06-15 04:52:30 -04:00
function Edit ( props ) {
const {
id ,
idBase
} = props . attributes ;
const {
isWide = false
} = props ;
2022-04-11 08:04:30 -04:00
const blockProps = ( 0 , external _wp _blockEditor _namespaceObject . useBlockProps ) ( {
2024-05-23 15:39:28 -04:00
className : dist _clsx ( {
2021-06-15 04:52:30 -04:00
'is-wide-widget' : isWide
} )
} ) ;
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( "div" , {
... blockProps ,
children : ! id && ! idBase ? /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( Empty , {
... props
} ) : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( NotEmpty , {
... props
} )
} ) ;
2021-06-15 04:52:30 -04:00
}
2023-06-27 10:24:19 -04:00
function Empty ( {
attributes : {
id ,
idBase
} ,
setAttributes
} ) {
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . Placeholder , {
icon : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . BlockIcon , {
2021-06-15 04:52:30 -04:00
icon : library _brush
} ) ,
2024-05-31 14:59:00 -04:00
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Legacy Widget' ) ,
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . Flex , {
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . FlexBlock , {
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( 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
} ) ;
}
}
} )
} )
} )
} ) ;
2021-06-15 04:52:30 -04:00
}
2023-06-27 10:24:19 -04:00
function NotEmpty ( {
attributes : {
id ,
idBase ,
instance
} ,
setAttributes ,
clientId ,
isSelected ,
isWide = false
} ) {
2022-04-11 08:04:30 -04:00
const [ hasPreview , setHasPreview ] = ( 0 , external _wp _element _namespaceObject . useState ) ( null ) ;
2022-04-12 11:12:47 -04:00
const widgetTypeId = id !== null && id !== void 0 ? id : idBase ;
2021-06-15 04:52:30 -04:00
const {
2022-04-12 11:12:47 -04:00
record : widgetType ,
hasResolved : hasResolvedWidgetType
2022-09-20 11:43:29 -04:00
} = ( 0 , external _wp _coreData _namespaceObject . useEntityRecord ) ( 'root' , 'widgetType' , widgetTypeId ) ;
2022-04-12 11:12:47 -04:00
const isNavigationMode = ( 0 , external _wp _data _namespaceObject . useSelect ) ( select => select ( external _wp _blockEditor _namespaceObject . store ) . isNavigationMode ( ) , [ ] ) ;
2022-04-11 08:04:30 -04:00
const setInstance = ( 0 , external _wp _element _namespaceObject . useCallback ) ( nextInstance => {
2021-06-15 04:52:30 -04:00
setAttributes ( {
instance : nextInstance
} ) ;
} , [ ] ) ;
if ( ! widgetType && hasResolvedWidgetType ) {
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . Placeholder , {
icon : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . BlockIcon , {
2021-06-15 04:52:30 -04:00
icon : library _brush
} ) ,
2024-05-31 14:59:00 -04:00
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Legacy Widget' ) ,
children : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Widget is missing.' )
} ) ;
2021-06-15 04:52:30 -04:00
}
if ( ! hasResolvedWidgetType ) {
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . Placeholder , {
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . Spinner , { } )
} ) ;
2021-06-15 04:52:30 -04:00
}
2021-06-28 12:01:36 -04:00
const mode = idBase && ( isNavigationMode || ! isSelected ) ? 'preview' : 'edit' ;
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _ReactJSXRuntime _namespaceObject . Fragment , {
children : [ idBase === 'text' && /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . BlockControls , {
group : "other" ,
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( ConvertToBlocksButton , {
clientId : clientId ,
rawInstance : instance . raw
} )
} ) , /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . InspectorControls , {
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( InspectorCard , {
name : widgetType . name ,
description : widgetType . description
} )
} ) , /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( Form , {
title : widgetType . name ,
isVisible : mode === 'edit' ,
id : id ,
idBase : idBase ,
instance : instance ,
isWide : isWide ,
onChangeInstance : setInstance ,
onChangeHasPreview : setHasPreview
} ) , idBase && /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _ReactJSXRuntime _namespaceObject . Fragment , {
children : [ hasPreview === null && mode === 'preview' && /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . Placeholder , {
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . Spinner , { } )
} ) , hasPreview === true && /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( Preview , {
idBase : idBase ,
instance : instance ,
isVisible : mode === 'preview'
} ) , hasPreview === false && mode === 'preview' && /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( NoPreview , {
name : widgetType . name
} ) ]
} ) ]
} ) ;
2021-06-15 04:52:30 -04:00
}
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/transforms.js
2021-06-15 04:52:30 -04:00
/ * *
* 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' ,
2023-06-27 10:24:19 -04:00
transform : ( {
content
} ) => ( {
content
} )
2021-06-15 04:52:30 -04:00
} , {
block : 'core/archives' ,
widget : 'archives' ,
2023-06-27 10:24:19 -04:00
transform : ( {
count ,
dropdown
} ) => {
2021-06-15 04:52:30 -04:00
return {
displayAsDropdown : ! ! dropdown ,
showPostCounts : ! ! count
} ;
}
} , {
block : 'core/latest-posts' ,
widget : 'recent-posts' ,
2023-06-27 10:24:19 -04:00
transform : ( {
show _date : displayPostDate ,
number
} ) => {
2021-06-15 04:52:30 -04:00
return {
displayPostDate : ! ! displayPostDate ,
postsToShow : number
} ;
}
} , {
block : 'core/latest-comments' ,
widget : 'recent-comments' ,
2023-06-27 10:24:19 -04:00
transform : ( {
number
} ) => {
2021-06-15 04:52:30 -04:00
return {
commentsToShow : number
} ;
}
} , {
block : 'core/tag-cloud' ,
widget : 'tag_cloud' ,
2023-06-27 10:24:19 -04:00
transform : ( {
taxonomy ,
count
} ) => {
2021-06-15 04:52:30 -04:00
return {
showTagCounts : ! ! count ,
taxonomy
} ;
}
} , {
block : 'core/categories' ,
widget : 'categories' ,
2023-06-27 10:24:19 -04:00
transform : ( {
count ,
dropdown ,
hierarchical
} ) => {
2021-06-15 04:52:30 -04:00
return {
displayAsDropdown : ! ! dropdown ,
showPostCounts : ! ! count ,
showHierarchy : ! ! hierarchical
} ;
}
} , {
block : 'core/audio' ,
widget : 'media_audio' ,
2023-06-27 10:24:19 -04:00
transform : ( {
url ,
preload ,
loop ,
attachment _id : id
} ) => {
2021-06-15 04:52:30 -04:00
return {
src : url ,
id ,
preload ,
loop
} ;
}
} , {
block : 'core/video' ,
widget : 'media_video' ,
2023-06-27 10:24:19 -04:00
transform : ( {
url ,
preload ,
loop ,
attachment _id : id
} ) => {
2021-06-15 04:52:30 -04:00
return {
src : url ,
id ,
preload ,
loop
} ;
}
} , {
block : 'core/image' ,
widget : 'media_image' ,
2023-06-27 10:24:19 -04: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 04:52:30 -04: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 10:24:19 -04:00
transform : ( {
ids ,
link _type : linkTo ,
size ,
number
} ) => {
2021-06-15 04:52:30 -04:00
return {
ids ,
columns : number ,
linkTo ,
sizeSlug : size ,
images : ids . map ( id => ( {
id
} ) )
} ;
}
} , {
block : 'core/rss' ,
widget : 'rss' ,
2023-06-27 10:24:19 -04:00
transform : ( {
url ,
show _author : displayAuthor ,
show _date : displayDate ,
show _summary : displayExcerpt ,
items
} ) => {
2021-06-15 04:52:30 -04:00
return {
feedURL : url ,
displayAuthor : ! ! displayAuthor ,
displayDate : ! ! displayDate ,
displayExcerpt : ! ! displayExcerpt ,
itemsToShow : items
} ;
}
2023-06-27 10:24:19 -04:00
} ] . map ( ( {
block ,
widget ,
transform
} ) => {
2021-06-15 04:52:30 -04:00
return {
type : 'block' ,
blocks : [ block ] ,
2023-06-27 10:24:19 -04:00
isMatch : ( {
idBase ,
instance
} ) => {
return idBase === widget && ! ! instance ? . raw ;
2021-06-15 04:52:30 -04:00
} ,
2023-06-27 10:24:19 -04:00
transform : ( {
instance
} ) => {
2022-04-11 08:04:30 -04:00
const transformedBlock = ( 0 , external _wp _blocks _namespaceObject . createBlock ) ( block , transform ? transform ( instance . raw ) : undefined ) ;
2023-06-27 10:24:19 -04:00
if ( ! instance . raw ? . title ) {
2021-06-15 04:52:30 -04:00
return transformedBlock ;
}
2022-04-11 08:04:30 -04:00
return [ ( 0 , external _wp _blocks _namespaceObject . createBlock ) ( 'core/heading' , {
2021-06-15 04:52:30 -04:00
content : instance . raw . title
} ) , transformedBlock ] ;
}
} ;
} ) ;
const transforms = {
to : legacyWidgetTransforms
} ;
2024-01-31 07:59:56 -05:00
/* harmony default export */ const legacy _widget _transforms = ( transforms ) ;
2021-06-15 04:52:30 -04:00
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/blocks/legacy-widget/index.js
2021-06-15 04:52:30 -04:00
/ * *
* WordPress dependencies
* /
2023-09-26 10:23:26 -04:00
2021-06-15 04:52:30 -04:00
/ * *
* Internal dependencies
* /
2022-04-11 08:04:30 -04:00
const metadata = {
Editor: Update the WordPress packages to the Gutenberg 16.7 RC2 version.
This patch, somewhat small brings a lot to WordPress.
This includes features like:
- DataViews.
- Customization tools like box shadow, background size and repeat.
- UI improvements in the site editor.
- Preferences sharing between the post and site editors.
- Unified panels and editors between post and site editors.
- Improved template mode in the post editor.
- Iterations to multiple interactive blocks.
- Preparing the blocks and UI for pattern overrides.
- and a lot more.
Props luisherranz, gziolo, isabel_brison, costdev, jonsurrell, peterwilsoncc, get_dave, antonvlasenko, desrosj.
See #60315.
Built from https://develop.svn.wordpress.org/trunk@57377
git-svn-id: http://core.svn.wordpress.org/trunk@56883 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-01-29 16:07:12 -05:00
$schema : "https://schemas.wp.org/trunk/block.json" ,
2023-06-27 10:24:19 -04:00
apiVersion : 3 ,
2021-06-15 04:52:30 -04: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 08:04:30 -04:00
} = metadata ;
2021-06-15 04:52:30 -04:00
2022-04-11 08:04:30 -04:00
const settings = {
2021-06-15 04:52:30 -04:00
icon : library _widget ,
edit : Edit ,
transforms : legacy _widget _transforms
} ;
2021-05-25 04:40:25 -04:00
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/icons/build-module/library/group.js
2022-04-11 08:04:30 -04:00
/ * *
* WordPress dependencies
* /
2024-05-31 14:59:00 -04:00
const group = /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _primitives _namespaceObject . SVG , {
2022-04-11 08:04:30 -04:00
viewBox : "0 0 24 24" ,
2024-05-31 14:59:00 -04:00
xmlns : "http://www.w3.org/2000/svg" ,
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( 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"
} )
} ) ;
2024-01-31 07:59:56 -05:00
/* harmony default export */ const library _group = ( group ) ;
2021-11-08 09:29:21 -05:00
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/blocks/widget-group/edit.js
2021-11-08 09:29:21 -05:00
/ * *
* WordPress dependencies
* /
2024-05-31 14:59:00 -04:00
2021-11-08 09:29:21 -05:00
function edit _Edit ( props ) {
const {
clientId
} = props ;
const {
innerBlocks
2022-04-11 08:04:30 -04:00
} = ( 0 , external _wp _data _namespaceObject . useSelect ) ( select => select ( external _wp _blockEditor _namespaceObject . store ) . getBlock ( clientId ) , [ clientId ] ) ;
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( "div" , {
2023-09-26 10:23:26 -04:00
... ( 0 , external _wp _blockEditor _namespaceObject . useBlockProps ) ( {
2023-06-27 10:24:19 -04:00
className : 'widget'
2024-05-31 14:59:00 -04:00
} ) ,
children : innerBlocks . length === 0 ? /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( PlaceholderContent , {
... props
} ) : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( PreviewContent , {
... props
2023-06-27 10:24:19 -04:00
} )
2024-05-31 14:59:00 -04:00
} ) ;
2021-11-08 09:29:21 -05:00
}
2023-06-27 10:24:19 -04:00
function PlaceholderContent ( {
clientId
} ) {
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _ReactJSXRuntime _namespaceObject . Fragment , {
children : [ /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . Placeholder , {
className : "wp-block-widget-group__placeholder" ,
icon : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . BlockIcon , {
icon : library _group
} ) ,
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Widget Group' ) ,
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . ButtonBlockAppender , {
rootClientId : clientId
} )
} ) , /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . InnerBlocks , {
renderAppender : false
} ) ]
} ) ;
2021-11-08 09:29:21 -05:00
}
2023-06-27 10:24:19 -04:00
function PreviewContent ( {
attributes ,
setAttributes
} ) {
2021-11-08 09:29:21 -05:00
var _attributes$title ;
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _ReactJSXRuntime _namespaceObject . Fragment , {
children : [ /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . RichText , {
tagName : "h2" ,
identifier : "title" ,
className : "widget-title" ,
allowedFormats : [ ] ,
placeholder : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Title' ) ,
value : ( _attributes$title = attributes . title ) !== null && _attributes$title !== void 0 ? _attributes$title : '' ,
onChange : title => setAttributes ( {
title
} )
} ) , /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . InnerBlocks , { } ) ]
} ) ;
2021-11-08 09:29:21 -05:00
}
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/blocks/widget-group/save.js
2021-11-08 09:29:21 -05:00
/ * *
* WordPress dependencies
* /
2024-05-31 14:59:00 -04:00
2023-06-27 10:24:19 -04:00
function save ( {
attributes
} ) {
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _ReactJSXRuntime _namespaceObject . Fragment , {
children : [ /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . RichText . Content , {
tagName : "h2" ,
className : "widget-title" ,
value : attributes . title
} ) , /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( "div" , {
className : "wp-widget-group__inner-blocks" ,
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . InnerBlocks . Content , { } )
} ) ]
} ) ;
2021-11-08 09:29:21 -05:00
}
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/blocks/widget-group/deprecated.js
2022-04-12 11:12:47 -04:00
/ * *
* WordPress dependencies
* /
2024-05-31 14:59:00 -04:00
2022-04-12 11:12:47 -04:00
const v1 = {
attributes : {
title : {
type : 'string'
}
} ,
supports : {
html : false ,
inserter : true ,
customClassName : true ,
reusable : false
} ,
2023-06-27 10:24:19 -04:00
save ( {
attributes
} ) {
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsxs ) ( external _ReactJSXRuntime _namespaceObject . Fragment , {
children : [ /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . RichText . Content , {
tagName : "h2" ,
className : "widget-title" ,
value : attributes . title
} ) , /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _blockEditor _namespaceObject . InnerBlocks . Content , { } ) ]
} ) ;
2022-04-12 11:12:47 -04:00
}
} ;
2024-01-31 07:59:56 -05:00
/* harmony default export */ const deprecated = ( [ v1 ] ) ;
2022-04-12 11:12:47 -04:00
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/blocks/widget-group/index.js
2021-11-08 09:29:21 -05:00
/ * *
* WordPress dependencies
* /
2023-09-26 10:23:26 -04:00
2021-11-08 09:29:21 -05:00
/ * *
* Internal dependencies
* /
const widget _group _metadata = {
Editor: Update the WordPress packages to the Gutenberg 16.7 RC2 version.
This patch, somewhat small brings a lot to WordPress.
This includes features like:
- DataViews.
- Customization tools like box shadow, background size and repeat.
- UI improvements in the site editor.
- Preferences sharing between the post and site editors.
- Unified panels and editors between post and site editors.
- Improved template mode in the post editor.
- Iterations to multiple interactive blocks.
- Preparing the blocks and UI for pattern overrides.
- and a lot more.
Props luisherranz, gziolo, isabel_brison, costdev, jonsurrell, peterwilsoncc, get_dave, antonvlasenko, desrosj.
See #60315.
Built from https://develop.svn.wordpress.org/trunk@57377
git-svn-id: http://core.svn.wordpress.org/trunk@56883 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2024-01-29 16:07:12 -05:00
$schema : "https://schemas.wp.org/trunk/block.json" ,
2023-06-27 10:24:19 -04:00
apiVersion : 3 ,
2021-11-08 09:29:21 -05:00
name : "core/widget-group" ,
2024-05-23 15:39:28 -04:00
title : "Widget Group" ,
2021-11-08 09:29:21 -05:00
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 11:12:47 -04:00
2021-11-08 09:29:21 -05:00
const {
name : widget _group _name
} = widget _group _metadata ;
const widget _group _settings = {
2022-04-11 08:04:30 -04: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 10:24:19 -04:00
_ _experimentalLabel : ( {
name : label
} ) => label ,
2021-11-08 09:29:21 -05: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 08:04:30 -04:00
return ( 0 , external _wp _blocks _namespaceObject . createBlock ) ( block . name , block . attributes , block . innerBlocks ) ;
2023-09-26 10:23:26 -04:00
} ) ] ;
// If the first block is a heading then assume this is intended
2021-11-08 09:29:21 -05:00
// to be the Widget's "title".
2023-09-26 10:23:26 -04:00
const firstHeadingBlock = innerBlocks [ 0 ] . name === 'core/heading' ? innerBlocks [ 0 ] : null ;
2021-11-08 09:29:21 -05:00
2023-09-26 10:23:26 -04:00
// Remove the first heading block as we're copying
2021-11-08 09:29:21 -05:00
// it's content into the Widget Group's title attribute.
innerBlocks = innerBlocks . filter ( block => block !== firstHeadingBlock ) ;
2023-09-26 10:23:26 -04:00
return ( 0 , external _wp _blocks _namespaceObject . createBlock ) ( 'core/widget-group' , {
... ( firstHeadingBlock && {
2021-11-08 09:29:21 -05:00
title : firstHeadingBlock . attributes . content
} )
} , innerBlocks ) ;
}
} ]
2022-04-12 11:12:47 -04:00
} ,
deprecated : deprecated
2021-11-08 09:29:21 -05:00
} ;
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/icons/build-module/library/move-to.js
2021-05-25 04:40:25 -04:00
/ * *
* WordPress dependencies
* /
2024-05-31 14:59:00 -04:00
const moveTo = /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _primitives _namespaceObject . SVG , {
2021-05-25 04:40:25 -04:00
xmlns : "http://www.w3.org/2000/svg" ,
2024-05-31 14:59:00 -04:00
viewBox : "0 0 24 24" ,
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _primitives _namespaceObject . 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"
} )
} ) ;
2024-01-31 07:59:56 -05:00
/* harmony default export */ const move _to = ( moveTo ) ;
2021-05-25 04:40:25 -04:00
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/components/move-to-widget-area/index.js
2021-05-25 04:40:25 -04:00
/ * *
* WordPress dependencies
* /
2024-05-31 14:59:00 -04:00
2023-06-27 10:24:19 -04:00
function MoveToWidgetArea ( {
currentWidgetAreaId ,
widgetAreas ,
onSelect
} ) {
2024-05-31 14:59:00 -04:00
return /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . ToolbarGroup , {
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . ToolbarItem , {
children : toggleProps => /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . DropdownMenu , {
icon : move _to ,
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Move to widget area' ) ,
toggleProps : toggleProps ,
children : ( {
onClose
} ) => /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( external _wp _components _namespaceObject . MenuGroup , {
label : ( 0 , external _wp _i18n _namespaceObject . _ _ ) ( 'Move to' ) ,
children : /*#__PURE__*/ ( 0 , external _ReactJSXRuntime _namespaceObject . jsx ) ( 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 04:40:25 -04:00
}
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/components/index.js
2021-05-25 04:40:25 -04:00
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/utils.js
2021-06-15 04:52:30 -04:00
// @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
2021-11-08 09:29:21 -05:00
* @ property { string } _ _internalWidgetId The internal widget id .
2021-06-15 04:52:30 -04:00
* @ typedef { Object } Block
2021-11-08 09:29:21 -05:00
* @ property { Attributes } attributes The attributes of the block .
2021-06-15 04:52:30 -04:00
*
2021-11-08 09:29:21 -05:00
* @ param { Block } block The block .
2021-06-15 04:52:30 -04:00
* @ return { string } The internal widget id .
* /
function getWidgetIdFromBlock ( block ) {
return block . attributes . _ _internalWidgetId ;
}
2023-09-26 10:23:26 -04:00
2021-06-15 04:52:30 -04:00
/ * *
* Add internal widget id to block ' s attributes .
*
2021-11-08 09:29:21 -05:00
* @ param { Block } block The block .
2021-06-15 04:52:30 -04:00
* @ param { string } widgetId The widget id .
* @ return { Block } The updated block .
* /
function addWidgetIdToBlock ( block , widgetId ) {
2023-09-26 10:23:26 -04:00
return {
... block ,
attributes : {
... ( block . attributes || { } ) ,
2021-06-15 04:52:30 -04:00
_ _internalWidgetId : widgetId
}
} ;
}
2021-05-25 04:40:25 -04:00
2024-12-13 14:06:24 -05:00
; // ./node_modules/@wordpress/widgets/build-module/register-legacy-widget-variations.js
2021-05-25 04:40:25 -04:00
/ * *
* WordPress dependencies
* /
function registerLegacyWidgetVariations ( settings ) {
2022-04-11 08:04:30 -04:00
const unsubscribe = ( 0 , external _wp _data _namespaceObject . subscribe ) ( ( ) => {
2023-06-27 10:24:19 -04:00
var _settings$widgetTypes ;
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 04:40:25 -04:00
per _page : - 1
2023-06-27 10:24:19 -04:00
} ) ? . filter ( widgetType => ! hiddenIds . includes ( widgetType . id ) ) ;
2021-05-25 04:40:25 -04:00
if ( widgetTypes ) {
unsubscribe ( ) ;
2022-04-11 08:04:30 -04:00
( 0 , external _wp _data _namespaceObject . dispatch ) ( external _wp _blocks _namespaceObject . store ) . addBlockVariations ( 'core/legacy-widget' , widgetTypes . map ( widgetType => ( {
2021-05-25 04:40:25 -04:00
name : widgetType . id ,
title : widgetType . name ,
description : widgetType . description ,
attributes : widgetType . is _multi ? {
idBase : widgetType . id ,
instance : { }
} : {
id : widgetType . id
}
} ) ) ) ;
}
} ) ;
}
2024-12-13 14:06:24 -05:00
; // ./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
2023-09-26 10:23:26 -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-11-08 09:29:21 -05: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 .
*
2023-02-07 02:04:52 -05:00
* @ param { Object } supports Block support settings .
2021-06-15 04:52:30 -04:00
* @ see https : //developer.wordpress.org/block-editor/how-to-guides/widgets/legacy-widget-block/
* /
2023-06-27 10:24:19 -04:00
function registerLegacyWidgetBlock ( supports = { } ) {
2021-06-15 04:52:30 -04:00
const {
2024-12-13 14:06:24 -05:00
/* metadata */ "yu" : metadata ,
/* settings */ "W0" : settings ,
/* name */ "UU" : name
2021-06-15 04:52:30 -04:00
} = legacy _widget _namespaceObject ;
2022-04-11 08:04:30 -04:00
( 0 , external _wp _blocks _namespaceObject . registerBlockType ) ( {
2021-06-15 04:52:30 -04:00
name ,
... metadata
2023-09-26 10:23:26 -04:00
} , {
... settings ,
supports : {
... settings . supports ,
2023-02-07 02:04:52 -05:00
... supports
}
} ) ;
2021-06-15 04:52:30 -04:00
}
2023-09-26 10:23:26 -04:00
2021-11-08 09:29:21 -05:00
/ * *
* Registers the Widget Group block .
2023-03-07 10:31:49 -05:00
*
* @ param { Object } supports Block support settings .
2021-11-08 09:29:21 -05:00
* /
2023-06-27 10:24:19 -04:00
function registerWidgetGroupBlock ( supports = { } ) {
2021-11-08 09:29:21 -05:00
const {
2024-12-13 14:06:24 -05:00
/* metadata */ "yu" : metadata ,
/* settings */ "W0" : settings ,
/* name */ "UU" : name
2021-11-08 09:29:21 -05:00
} = widget _group _namespaceObject ;
2022-04-11 08:04:30 -04:00
( 0 , external _wp _blocks _namespaceObject . registerBlockType ) ( {
2021-11-08 09:29:21 -05:00
name ,
... metadata
2023-09-26 10:23:26 -04:00
} , {
... settings ,
supports : {
... settings . supports ,
2023-03-07 10:31:49 -05:00
... supports
}
} ) ;
2021-11-08 09:29:21 -05:00
}
2021-05-25 04:40:25 -04:00
2022-04-11 08:04:30 -04:00
( window . wp = window . wp || { } ) . widgets = _ _webpack _exports _ _ ;
/******/ } ) ( )
;