var customGradientBarReducerInitialState = {
function CustomGradientBar(_ref) {
var background = _ref.background,
hasGradient = _ref.hasGradient,
controlPoints = _ref.value,
onChange = _ref.onChange;
var gradientPickerDomRef = Object(external_wp_element_["useRef"])();
var _useReducer = Object(external_wp_element_["useReducer"])(customGradientBarReducer, customGradientBarReducerInitialState),
_useReducer2 = Object(slicedToArray["a" /* default */])(_useReducer, 2),
gradientBarState = _useReducer2[0],
gradientBarStateDispatch = _useReducer2[1];
var onMouseEnterAndMove = function onMouseEnterAndMove(event) {
var insertPosition = getHorizontalRelativeGradientPosition(event.clientX, gradientPickerDomRef.current, INSERT_POINT_WIDTH); // If the insert point is close to an existing control point don't show it.
if (Object(external_lodash_["some"])(controlPoints, function (_ref2) {
var position = _ref2.position;
return Math.abs(insertPosition - position) < MINIMUM_DISTANCE_BETWEEN_INSERTER_AND_POINT;
if (gradientBarState.id === 'MOVING_INSERTER') {
gradientBarStateDispatch({
type: 'STOP_INSERTER_MOVE'
gradientBarStateDispatch({
insertPosition: insertPosition
var onMouseLeave = function onMouseLeave() {
gradientBarStateDispatch({
type: 'STOP_INSERTER_MOVE'
var isMovingInserter = gradientBarState.id === 'MOVING_INSERTER';
var isInsertingControlPoint = gradientBarState.id === 'INSERTING_CONTROL_POINT';
return Object(external_wp_element_["createElement"])("div", {
ref: gradientPickerDomRef,
className: classnames_default()('components-custom-gradient-picker__gradient-bar', {
'has-gradient': hasGradient
onMouseEnter: onMouseEnterAndMove,
onMouseMove: onMouseEnterAndMove,
onMouseLeave: onMouseLeave
}, Object(external_wp_element_["createElement"])("div", {
className: "components-custom-gradient-picker__markers-container"
}, (isMovingInserter || isInsertingControlPoint) && Object(external_wp_element_["createElement"])(control_points.InsertPoint, {
insertPosition: gradientBarState.insertPosition,
onOpenInserter: function onOpenInserter() {
gradientBarStateDispatch({
onCloseInserter: function onCloseInserter() {
gradientBarStateDispatch({
}), Object(external_wp_element_["createElement"])(control_points, {
gradientPickerDomRef: gradientPickerDomRef,
ignoreMarkerPosition: isInsertingControlPoint ? gradientBarState.insertPosition : undefined,
onStartControlPointChange: function onStartControlPointChange() {
gradientBarStateDispatch({
type: 'START_CONTROL_CHANGE'
onStopControlPointChange: function onStopControlPointChange() {
gradientBarStateDispatch({
type: 'STOP_CONTROL_CHANGE'
// EXTERNAL MODULE: ./node_modules/gradient-parser/build/node.js
var build_node = __webpack_require__("Jx1U");
var node_default = /*#__PURE__*/__webpack_require__.n(build_node);
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/custom-gradient-picker/constants.js
var DEFAULT_GRADIENT = 'linear-gradient(135deg, rgba(6, 147, 227, 1) 0%, rgb(155, 81, 224) 100%)';
var DEFAULT_LINEAR_GRADIENT_ANGLE = 180;
var HORIZONTAL_GRADIENT_ORIENTATION = {
var GRADIENT_OPTIONS = [{
value: 'linear-gradient',
label: Object(external_wp_i18n_["__"])('Linear')
value: 'radial-gradient',
label: Object(external_wp_i18n_["__"])('Radial')
var DIRECTIONAL_ORIENTATION_ANGLE_MAP = {
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/custom-gradient-picker/serializer.js
function serializeGradientColor(_ref) {
if (type === 'literal') {
return "#".concat(value);
return "".concat(type, "(").concat(value.join(','), ")");
function serializeGradientPosition(position) {
var value = position.value,
return "".concat(value).concat(type);
function serializeGradientColorStop(_ref2) {
return "".concat(serializeGradientColor({
}), " ").concat(serializeGradientPosition(length));
function serializeGradientOrientation(orientation) {
if (!orientation || orientation.type !== 'angular') {
return "".concat(orientation.value, "deg");
function serializeGradient(_ref3) {
orientation = _ref3.orientation,
colorStops = _ref3.colorStops;
var serializedOrientation = serializeGradientOrientation(orientation);
var serializedColorStops = colorStops.sort(function (colorStop1, colorStop2) {
return Object(external_lodash_["get"])(colorStop1, ['length', 'value'], 0) - Object(external_lodash_["get"])(colorStop2, ['length', 'value'], 0);
}).map(serializeGradientColorStop);
return "".concat(type, "(").concat(Object(external_lodash_["compact"])([serializedOrientation].concat(Object(toConsumableArray["a" /* default */])(serializedColorStops))).join(','), ")");
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/custom-gradient-picker/utils.js
function custom_gradient_picker_utils_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function custom_gradient_picker_utils_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { custom_gradient_picker_utils_ownKeys(Object(source), true).forEach(function (key) { Object(esm_defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { custom_gradient_picker_utils_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function getLinearGradientRepresentationOfARadial(gradientAST) {
return serializeGradient({
orientation: HORIZONTAL_GRADIENT_ORIENTATION,
colorStops: gradientAST.colorStops
function hasUnsupportedLength(item) {
return item.length === undefined || item.length.type !== '%';
function getGradientAstWithDefault(value) {
var _gradientAST$orientat;
// 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.
gradientAST = node_default.a.parse(value)[0];
gradientAST.value = value;
gradientAST = node_default.a.parse(DEFAULT_GRADIENT)[0];
gradientAST.value = DEFAULT_GRADIENT;
if (((_gradientAST$orientat = gradientAST.orientation) === null || _gradientAST$orientat === void 0 ? void 0 : _gradientAST$orientat.type) === 'directional') {
gradientAST.orientation.type = 'angular';
gradientAST.orientation.value = DIRECTIONAL_ORIENTATION_ANGLE_MAP[gradientAST.orientation.value].toString();
if (gradientAST.colorStops.some(hasUnsupportedLength)) {
var _gradientAST = gradientAST,
colorStops = _gradientAST.colorStops;
var step = 100 / (colorStops.length - 1);
colorStops.forEach(function (stop, index) {
gradientAST.value = serializeGradient(gradientAST);
function getGradientAstWithControlPoints(gradientAST, newControlPoints) {
return custom_gradient_picker_utils_objectSpread(custom_gradient_picker_utils_objectSpread({}, gradientAST), {}, {
colorStops: newControlPoints.map(function (_ref) {
var position = _ref.position,
var _tinycolor$toRgb = tinycolor_default()(color).toRgb(),
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 "#".concat(colorStop.value);
return "".concat(colorStop.type, "(").concat(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)."; }
var SelectWrapper = /*#__PURE__*/styled_base_browser_esm(block, {
var AccessoryWrapper = /*#__PURE__*/styled_base_browser_esm(block, {
label: "AccessoryWrapper"
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/custom-gradient-picker/index.js
function custom_gradient_picker_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function custom_gradient_picker_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { custom_gradient_picker_ownKeys(Object(source), true).forEach(function (key) { Object(esm_defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { custom_gradient_picker_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var custom_gradient_picker_GradientAnglePicker = function GradientAnglePicker(_ref) {
var gradientAST = _ref.gradientAST,
hasGradient = _ref.hasGradient,
onChange = _ref.onChange;
var angle = Object(external_lodash_["get"])(gradientAST, ['orientation', 'value'], DEFAULT_LINEAR_GRADIENT_ANGLE);
var onAngleChange = function onAngleChange(newAngle) {
onChange(serializeGradient(custom_gradient_picker_objectSpread(custom_gradient_picker_objectSpread({}, gradientAST), {}, {
return Object(external_wp_element_["createElement"])(AnglePickerControl, {
hideLabelFromVision: true,
value: hasGradient ? angle : ''
var custom_gradient_picker_GradientTypePicker = function GradientTypePicker(_ref2) {
var gradientAST = _ref2.gradientAST,
hasGradient = _ref2.hasGradient,
onChange = _ref2.onChange;
var type = gradientAST.type;
var onSetLinearGradient = function onSetLinearGradient() {
onChange(serializeGradient(custom_gradient_picker_objectSpread(custom_gradient_picker_objectSpread(custom_gradient_picker_objectSpread({}, gradientAST), gradientAST.orientation ? {} : {
orientation: HORIZONTAL_GRADIENT_ORIENTATION
var onSetRadialGradient = function onSetRadialGradient() {
onChange(serializeGradient(custom_gradient_picker_objectSpread(custom_gradient_picker_objectSpread({}, Object(external_lodash_["omit"])(gradientAST, ['orientation'])), {}, {
var handleOnChange = function handleOnChange(next) {
if (next === 'linear-gradient') {
if (next === 'radial-gradient') {
return Object(external_wp_element_["createElement"])(select_control, {
className: "components-custom-gradient-picker__type-picker",
label: Object(external_wp_i18n_["__"])('Type'),
onChange: handleOnChange,
options: GRADIENT_OPTIONS,
value: hasGradient && type
function CustomGradientPicker(_ref3) {
_onChange = _ref3.onChange;
var gradientAST = 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.
var background = gradientAST.type === 'radial-gradient' ? getLinearGradientRepresentationOfARadial(gradientAST) : gradientAST.value;
var hasGradient = gradientAST.value !== DEFAULT_GRADIENT; // Control points color option may be hex from presets, custom colors will be rgb.
// The position should always be a percentage.
var controlPoints = gradientAST.colorStops.map(function (colorStop) {
color: getStopCssColor(colorStop),
position: parseInt(colorStop.length.value)
return Object(external_wp_element_["createElement"])("div", {
className: "components-custom-gradient-picker"
}, Object(external_wp_element_["createElement"])(CustomGradientBar, {
hasGradient: hasGradient,
onChange: function onChange(newControlPoints) {
_onChange(serializeGradient(getGradientAstWithControlPoints(gradientAST, newControlPoints)));
}), Object(external_wp_element_["createElement"])(flex_Flex, {
className: "components-custom-gradient-picker__ui-line"
}, Object(external_wp_element_["createElement"])(SelectWrapper, null, Object(external_wp_element_["createElement"])(custom_gradient_picker_GradientTypePicker, {
gradientAST: gradientAST,
hasGradient: hasGradient,
})), Object(external_wp_element_["createElement"])(AccessoryWrapper, null, gradientAST.type === 'linear-gradient' && Object(external_wp_element_["createElement"])(custom_gradient_picker_GradientAnglePicker, {
gradientAST: gradientAST,
hasGradient: hasGradient,
// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/gradient-picker/index.js
function GradientPicker(_ref) {
var className = _ref.className,
gradients = _ref.gradients,
onChange = _ref.onChange,
_ref$clearable = _ref.clearable,
clearable = _ref$clearable === void 0 ? true : _ref$clearable,
_ref$disableCustomGra = _ref.disableCustomGradients,
disableCustomGradients = _ref$disableCustomGra === void 0 ? false : _ref$disableCustomGra;
var clearGradient = Object(external_wp_element_["useCallback"])(function () {
return onChange(undefined);
var gradientOptions = Object(external_wp_element_["useMemo"])(function () {
return Object(external_lodash_["map"])(gradients, function (_ref2) {
var gradient = _ref2.gradient,
return Object(external_wp_element_["createElement"])(CircularOptionPicker.Option, {
isSelected: value === gradient,
tooltipText: name || // translators: %s: gradient code e.g: "linear-gradient(90deg, rgba(98,16,153,1) 0%, rgba(172,110,22,1) 100%);".
Object(external_wp_i18n_["sprintf"])(Object(external_wp_i18n_["__"])('Gradient code: %s'), gradient),
color: 'rgba( 0,0,0,0 )',
onClick: value === gradient ? clearGradient : function () {
return onChange(gradient);
"aria-label": name ? // translators: %s: The name of the gradient e.g: "Angular red to blue".
Object(external_wp_i18n_["sprintf"])(Object(external_wp_i18n_["__"])('Gradient: %s'), name) : // translators: %s: gradient code e.g: "linear-gradient(90deg, rgba(98,16,153,1) 0%, rgba(172,110,22,1) 100%);".
Object(external_wp_i18n_["sprintf"])(Object(external_wp_i18n_["__"])('Gradient code: %s'), gradient)
}, [gradients, value, onChange, clearGradient]);