: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
function getSpacingPresetCssVar(value) {
const slug = value.match(/var:preset\|spacing\|(.+)/);
return `var(--wp--preset--spacing--${slug[1]})`;
* Returns the slug section of the given spacing preset string.
* @param {string} value Value to extract slug from.
* @return {string|undefined} The int value of the slug from given spacing preset.
function getSpacingPresetSlug(value) {
if (value === '0' || value === 'default') {
const slug = value.match(/var:preset\|spacing\|(.+)/);
return slug ? slug[1] : undefined;
* Converts spacing preset value into a Range component value .
* @param {string} presetValue Value to convert to Range value.
* @param {Array} spacingSizes Array of current spacing preset value objects.
* @return {number} The int value for use in Range control.
function getSliderValueFromPreset(presetValue, spacingSizes) {
if (presetValue === undefined) {
const slug = parseFloat(presetValue, 10) === 0 ? '0' : getSpacingPresetSlug(presetValue);
const sliderValue = spacingSizes.findIndex(spacingSize => {
return String(spacingSize.slug) === slug;
// Returning NaN rather than undefined as undefined makes range control thumb sit in center
return sliderValue !== -1 ? sliderValue : NaN;
* Gets an items with the most occurrence within an array
* https://stackoverflow.com/a/20762713
* @param {Array<any>} arr Array of items to check.
* @return {any} The item with the most occurrences.
return arr.sort((a, b) => arr.filter(v => v === a).length - arr.filter(v => v === b).length).pop();
* Gets the 'all' input value from values data.
* @param {Object} values Box spacing values
* @return {string} The most common value from all sides of box.
function getAllRawValue(values = {}) {
return mode(Object.values(values));
* Checks to determine if values are mixed.
* @param {Object} values Box values.
* @param {Array} sides Sides that values relate to.
* @return {boolean} Whether values are mixed.
function isValuesMixed(values = {}, sides = ALL_SIDES) {
return Object.values(values).length >= 1 && Object.values(values).length < sides.length || new Set(Object.values(values)).size > 1;
* Checks to determine if values are defined.
* @param {Object} values Box values.
* @return {boolean} Whether values are defined.
function isValuesDefined(values) {
if (values === undefined || values === null) {
return Object.values(values).filter(value => !!value).length > 0;
* Determines whether a particular axis has support. If no axis is
* specified, this function checks if either axis is supported.
* @param {Array} sides Supported sides.
* @param {string} axis Which axis to check.
* @return {boolean} Whether there is support for the specified axis or both axes.
function hasAxisSupport(sides, axis) {
if (!sides || !sides.length) {
const hasHorizontalSupport = sides.includes('horizontal') || sides.includes('left') && sides.includes('right');
const hasVerticalSupport = sides.includes('vertical') || sides.includes('top') && sides.includes('bottom');
if (axis === 'horizontal') {
return hasHorizontalSupport;
if (axis === 'vertical') {
return hasVerticalSupport;
return hasHorizontalSupport || hasVerticalSupport;
* Determines which menu options should be included in the SidePicker.
* @param {Array} sides Supported sides.
* @return {Object} Menu options with each option containing label & icon.
function getSupportedMenuItems(sides) {
if (!sides || !sides.length) {
// Determine the primary "side" menu options.
const hasHorizontalSupport = hasAxisSupport(sides, 'horizontal');
const hasVerticalSupport = hasAxisSupport(sides, 'vertical');
if (hasHorizontalSupport && hasVerticalSupport) {
} else if (hasHorizontalSupport) {
label: LABELS.horizontal,
} else if (hasVerticalSupport) {
// Track whether we have any individual sides so we can omit the custom
let numberOfIndividualSides = 0;
ALL_SIDES.forEach(side => {
if (sides.includes(side)) {
numberOfIndividualSides += 1;
// Add custom item if there are enough sides to warrant a separated view.
if (numberOfIndividualSides > 1) {
* Checks if the supported sides are balanced for each axis.
* - Horizontal - both left and right sides are supported.
* - Vertical - both top and bottom are supported.
* @param {Array} sides The supported sides which may be axes as well.
* @return {boolean} Whether or not the supported sides are balanced.
function hasBalancedSidesSupport(sides = []) {
sides.forEach(side => counts[side] += 1);
return (counts.top + counts.bottom) % 2 === 0 && (counts.left + counts.right) % 2 === 0;
* Determines which view the SpacingSizesControl should default to on its
* first render; Axial, Custom, or Single side.
* @param {Object} values Current side values.
* @param {Array} sides Supported sides.
* @return {string} View to display.
function getInitialView(values = {}, sides) {
const sideValues = [top, right, bottom, left].filter(Boolean);
// Axial ( Horizontal & vertical ).
// - Has axial side support
// - Has axial side values which match
// - Has no values and the supported sides are balanced
const hasMatchingAxialValues = top === bottom && left === right && (!!top || !!left);
const hasNoValuesAndBalancedSides = !sideValues.length && hasBalancedSidesSupport(sides);
if (hasAxisSupport(sides) && (hasMatchingAxialValues || hasNoValuesAndBalancedSides)) {
// - Ensure the side returned is the first side that has a value.
if (sideValues.length === 1) {
Object.entries(values).some(([key, value]) => {
return value !== undefined;
// Only single side supported and no value defined.
if (sides?.length === 1 && !sideValues.length) {
// Default to the Custom (separated sides) view.
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/gap.js
* Returns a BoxControl object value from a given blockGap style value.
* The string check is for backwards compatibility before Gutenberg supported
* split gap values (row and column) and the value was a string n + unit.
* @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.
* @return {Object|null} A value to pass to the BoxControl component.
function getGapBoxControlValueFromStyle(blockGapValue) {
const isValueString = typeof blockGapValue === 'string';
top: isValueString ? blockGapValue : blockGapValue?.top,
left: isValueString ? blockGapValue : blockGapValue?.left
* Returns a CSS value for the `gap` property from a given blockGap style.
* @param {string? | Object?} blockGapValue A block gap string or axial object value, e.g., '10px' or { top: '10px', left: '10px'}.
* @param {string?} defaultValue A default gap value.
* @return {string|null} The concatenated gap value (row and column).
function getGapCSSValue(blockGapValue, defaultValue = '0') {
const blockGapBoxControlValue = getGapBoxControlValueFromStyle(blockGapValue);
if (!blockGapBoxControlValue) {
const row = getSpacingPresetCssVar(blockGapBoxControlValue?.top) || defaultValue;
const column = getSpacingPresetCssVar(blockGapBoxControlValue?.left) || defaultValue;
return row === column ? row : `${row} ${column}`;
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-control/icons.js
const alignBottom = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SVG, {
xmlns: "http://www.w3.org/2000/svg",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
d: "M15 4H9v11h6V4zM4 18.5V20h16v-1.5H4z"
const alignCenter = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SVG, {
xmlns: "http://www.w3.org/2000/svg",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
d: "M20 11h-5V4H9v7H4v1.5h5V20h6v-7.5h5z"
const alignTop = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SVG, {
xmlns: "http://www.w3.org/2000/svg",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
d: "M9 20h6V9H9v11zM4 4v1.5h16V4H4z"
const alignStretch = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SVG, {
xmlns: "http://www.w3.org/2000/svg",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
d: "M4 4L20 4L20 5.5L4 5.5L4 4ZM10 7L14 7L14 17L10 17L10 7ZM20 18.5L4 18.5L4 20L20 20L20 18.5Z"
const spaceBetween = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SVG, {
xmlns: "http://www.w3.org/2000/svg",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
d: "M7 4H17V8L7 8V4ZM7 16L17 16V20L7 20V16ZM20 11.25H4V12.75H20V11.25Z"
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-control/ui.js
const BLOCK_ALIGNMENTS_CONTROLS = {
title: (0,external_wp_i18n_namespaceObject._x)('Align top', 'Block vertical alignment setting')
title: (0,external_wp_i18n_namespaceObject._x)('Align middle', 'Block vertical alignment setting')
title: (0,external_wp_i18n_namespaceObject._x)('Align bottom', 'Block vertical alignment setting')
title: (0,external_wp_i18n_namespaceObject._x)('Stretch to fill', 'Block vertical alignment setting')
title: (0,external_wp_i18n_namespaceObject._x)('Space between', 'Block vertical alignment setting')
const DEFAULT_CONTROLS = ['top', 'center', 'bottom'];
const DEFAULT_CONTROL = 'top';
function BlockVerticalAlignmentUI({
controls = DEFAULT_CONTROLS,
function applyOrUnset(align) {
return () => onChange(value === align ? undefined : align);
const activeAlignment = BLOCK_ALIGNMENTS_CONTROLS[value];
const defaultAlignmentControl = BLOCK_ALIGNMENTS_CONTROLS[DEFAULT_CONTROL];
const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu;
const extraProps = isToolbar ? {
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(UIComponent, {
icon: activeAlignment ? activeAlignment.icon : defaultAlignmentControl.icon,
label: (0,external_wp_i18n_namespaceObject._x)('Change vertical alignment', 'Block vertical alignment setting label'),
controls: controls.map(control => {
...BLOCK_ALIGNMENTS_CONTROLS[control],
isActive: value === control,
role: isCollapsed ? 'menuitemradio' : undefined,
onClick: applyOrUnset(control)
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-vertical-alignment-toolbar/README.md
/* harmony default export */ const ui = (BlockVerticalAlignmentUI);
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-control/index.js
const BlockVerticalAlignmentControl = props => {
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ui, {
const BlockVerticalAlignmentToolbar = props => {
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ui, {
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-vertical-alignment-control/README.md
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/justify-content-control/ui.js
'space-between': justify_space_between,
function JustifyContentUI({
allowedControls = ['left', 'center', 'right', 'space-between'],
// If the control is already selected we want a click
// again on the control to deselect the item, so we
// call onChange( undefined )
const handleClick = next => {
const icon = value ? icons[value] : icons.left;
title: (0,external_wp_i18n_namespaceObject.__)('Justify items left'),
isActive: 'left' === value,
onClick: () => handleClick('left')
title: (0,external_wp_i18n_namespaceObject.__)('Justify items center'),
isActive: 'center' === value,
onClick: () => handleClick('center')
title: (0,external_wp_i18n_namespaceObject.__)('Justify items right'),
isActive: 'right' === value,
onClick: () => handleClick('right')
icon: justify_space_between,
title: (0,external_wp_i18n_namespaceObject.__)('Space between items'),
isActive: 'space-between' === value,
onClick: () => handleClick('space-between')
title: (0,external_wp_i18n_namespaceObject.__)('Stretch items'),
isActive: 'stretch' === value,
onClick: () => handleClick('stretch')
const UIComponent = isToolbar ? external_wp_components_namespaceObject.ToolbarGroup : external_wp_components_namespaceObject.ToolbarDropdownMenu;
const extraProps = isToolbar ? {
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(UIComponent, {
popoverProps: popoverProps,
label: (0,external_wp_i18n_namespaceObject.__)('Change items justification'),
controls: allControls.filter(elem => allowedControls.includes(elem.name)),