: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
gradientBarStateDispatch({
const onMouseLeave = () => {
gradientBarStateDispatch({
type: 'STOP_INSERTER_MOVE'
const isMovingInserter = gradientBarState.id === 'MOVING_INSERTER';
const isInsertingControlPoint = gradientBarState.id === 'INSERTING_CONTROL_POINT';
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
className: dist_clsx('components-custom-gradient-picker__gradient-bar', {
'has-gradient': hasGradient
onMouseEnter: onMouseEnterAndMove,
onMouseMove: onMouseEnterAndMove,
onMouseLeave: onMouseLeave,
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
className: "components-custom-gradient-picker__gradient-bar-background",
opacity: hasGradient ? 1 : 0.4
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
ref: gradientMarkersContainerDomRef,
className: "components-custom-gradient-picker__markers-container",
children: [!disableInserter && (isMovingInserter || isInsertingControlPoint) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(control_points.InsertPoint, {
__experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar,
disableAlpha: disableAlpha,
insertPosition: gradientBarState.insertPosition,
gradientBarStateDispatch({
gradientBarStateDispatch({
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(control_points, {
__experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar,
disableAlpha: disableAlpha,
disableRemove: disableInserter,
gradientPickerDomRef: gradientMarkersContainerDomRef,
ignoreMarkerPosition: isInsertingControlPoint ? gradientBarState.insertPosition : undefined,
onStartControlPointChange: () => {
gradientBarStateDispatch({
type: 'START_CONTROL_CHANGE'
onStopControlPointChange: () => {
gradientBarStateDispatch({
type: 'STOP_CONTROL_CHANGE'
// EXTERNAL MODULE: ./node_modules/gradient-parser/build/node.js
var build_node = __webpack_require__(8924);
;// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/custom-gradient-picker/constants.js
const DEFAULT_GRADIENT = 'linear-gradient(135deg, rgba(6, 147, 227, 1) 0%, rgb(155, 81, 224) 100%)';
const DEFAULT_LINEAR_GRADIENT_ANGLE = 180;
const HORIZONTAL_GRADIENT_ORIENTATION = {
const GRADIENT_OPTIONS = [{
value: 'linear-gradient',
label: (0,external_wp_i18n_namespaceObject.__)('Linear')
value: 'radial-gradient',
label: (0,external_wp_i18n_namespaceObject.__)('Radial')
const DIRECTIONAL_ORIENTATION_ANGLE_MAP = {
;// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/custom-gradient-picker/serializer.js
function serializeGradientColor({
if (type === 'literal') {
return `${type}(${value.join(',')})`;
function serializeGradientPosition(position) {
return `${value}${type}`;
function serializeGradientColorStop({
return `${serializeGradientColor({
})} ${serializeGradientPosition(length)}`;
function serializeGradientOrientation(orientation) {
if (Array.isArray(orientation) || !orientation || orientation.type !== 'angular') {
return `${orientation.value}deg`;
function serializeGradient({
const serializedOrientation = serializeGradientOrientation(orientation);
const serializedColorStops = colorStops.sort((colorStop1, colorStop2) => {
const getNumericStopValue = colorStop => {
return colorStop?.length?.value === undefined ? 0 : parseInt(colorStop.length.value);
return getNumericStopValue(colorStop1) - getNumericStopValue(colorStop2);
}).map(serializeGradientColorStop);
return `${type}(${[serializedOrientation, ...serializedColorStops].filter(Boolean).join(',')})`;
;// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/custom-gradient-picker/utils.js
function getLinearGradientRepresentation(gradientAST) {
return serializeGradient({
orientation: HORIZONTAL_GRADIENT_ORIENTATION,
colorStops: gradientAST.colorStops
function hasUnsupportedLength(item) {
return item.length === undefined || item.length.type !== '%';
function getGradientAstWithDefault(value) {
// gradientAST will contain the gradient AST as parsed by gradient-parser npm module.
// More information of its structure available at https://www.npmjs.com/package/gradient-parser#ast.
let hasGradient = !!value;
const valueToParse = value !== null && value !== void 0 ? value : DEFAULT_GRADIENT;
gradientAST = build_node.parse(valueToParse)[0];
// eslint-disable-next-line no-console
console.warn('wp.components.CustomGradientPicker failed to parse the gradient with error', error);
gradientAST = build_node.parse(DEFAULT_GRADIENT)[0];
if (!Array.isArray(gradientAST.orientation) && gradientAST.orientation?.type === 'directional') {
gradientAST.orientation = {
value: DIRECTIONAL_ORIENTATION_ANGLE_MAP[gradientAST.orientation.value].toString()
if (gradientAST.colorStops.some(hasUnsupportedLength)) {
const step = 100 / (colorStops.length - 1);
colorStops.forEach((stop, index) => {
value: `${step * index}`,
function getGradientAstWithControlPoints(gradientAST, newControlPoints) {
colorStops: newControlPoints.map(({
value: position?.toString()
type: a < 1 ? 'rgba' : 'rgb',
value: a < 1 ? [`${r}`, `${g}`, `${b}`, `${a}`] : [`${r}`, `${g}`, `${b}`]
function getStopCssColor(colorStop) {
switch (colorStop.type) {
return `#${colorStop.value}`;
return `${colorStop.type}(${colorStop.value.join(',')})`;
// Should be unreachable if passing an AST from gradient-parser.
// See https://github.com/rafaelcaricio/gradient-parser#ast.
;// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/custom-gradient-picker/styles/custom-gradient-picker-styles.js
function custom_gradient_picker_styles_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
const SelectWrapper = /*#__PURE__*/emotion_styled_base_browser_esm(flex_block_component, true ? {
const AccessoryWrapper = /*#__PURE__*/emotion_styled_base_browser_esm(flex_block_component, true ? {
;// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/custom-gradient-picker/index.js
const GradientAnglePicker = ({
var _gradientAST$orientat;
const angle = (_gradientAST$orientat = gradientAST?.orientation?.value) !== null && _gradientAST$orientat !== void 0 ? _gradientAST$orientat : DEFAULT_LINEAR_GRADIENT_ANGLE;
const onAngleChange = newAngle => {
onChange(serializeGradient({
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(angle_picker_control, {
value: hasGradient ? angle : ''
const GradientTypePicker = ({
const onSetLinearGradient = () => {
onChange(serializeGradient({
orientation: gradientAST.orientation ? undefined : HORIZONTAL_GRADIENT_ORIENTATION,
const onSetRadialGradient = () => {
onChange(serializeGradient({
const handleOnChange = next => {
if (next === 'linear-gradient') {
if (next === 'radial-gradient') {
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(select_control, {
__nextHasNoMarginBottom: true,
className: "components-custom-gradient-picker__type-picker",
label: (0,external_wp_i18n_namespaceObject.__)('Type'),
onChange: handleOnChange,
options: GRADIENT_OPTIONS,
size: "__unstable-large",
value: hasGradient ? type : undefined
* CustomGradientPicker is a React component that renders a UI for specifying
* linear or radial gradients. Radial gradients are displayed in the picker as
* a slice of the gradient from the center to the outside.
* import { CustomGradientPicker } from '@wordpress/components';
* import { useState } from '@wordpress/element';
* const MyCustomGradientPicker = () => {
* const [ gradient, setGradient ] = useState();
* onChange={ setGradient }
function CustomGradientPicker({
__experimentalIsRenderedInSidebar = false
} = getGradientAstWithDefault(value);
// On radial gradients the bar should display a linear gradient.
// On radial gradients the bar represents a slice of the gradient from the center until the outside.
// On liner gradients the bar represents the color stops from left to right independently of the angle.
const background = getLinearGradientRepresentation(gradientAST);
// Control points color option may be hex from presets, custom colors will be rgb.
// The position should always be a percentage.
const controlPoints = gradientAST.colorStops.map(colorStop => {
color: getStopCssColor(colorStop),
// Although it's already been checked by `hasUnsupportedLength` in `getGradientAstWithDefault`,
// TypeScript doesn't know that `colorStop.length` is not undefined here.
position: parseInt(colorStop.length.value)
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(v_stack_component, {
className: "components-custom-gradient-picker",
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CustomGradientBar, {
__experimentalIsRenderedInSidebar: __experimentalIsRenderedInSidebar,
hasGradient: hasGradient,
onChange: newControlPoints => {
onChange(serializeGradient(getGradientAstWithControlPoints(gradientAST, newControlPoints)));
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(flex_component, {
className: "components-custom-gradient-picker__ui-line",
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SelectWrapper, {
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(GradientTypePicker, {
gradientAST: gradientAST,
hasGradient: hasGradient,
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(AccessoryWrapper, {
children: gradientAST.type === 'linear-gradient' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(GradientAnglePicker, {
gradientAST: gradientAST,
hasGradient: hasGradient,
/* harmony default export */ const custom_gradient_picker = (CustomGradientPicker);
;// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/gradient-picker/index.js
// The Multiple Origin Gradients have a `gradients` property (an array of
// gradient objects), while Single Origin ones have a `gradient` property.
const isMultipleOriginObject = obj => Array.isArray(obj.gradients) && !('gradient' in obj);
const isMultipleOriginArray = arr => {
return arr.length > 0 && arr.every(gradientObj => isMultipleOriginObject(gradientObj));
const gradientOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
}, index) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(build_module_circular_option_picker.Option, {
isSelected: value === gradient,
// translators: %s: gradient code e.g: "linear-gradient(90deg, rgba(98,16,153,1) 0%, rgba(172,110,22,1) 100%);".
(0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Gradient code: %s'), gradient),
color: 'rgba( 0,0,0,0 )',