@elementor/editor-controls 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -257,7 +257,7 @@ var ImageMediaControl = createControl(() => {
257
257
  const { data: attachment, isFetching } = useWpMediaAttachment(id?.value || null);
258
258
  const src = attachment?.url ?? url?.value ?? null;
259
259
  const { open } = useWpMediaFrame({
260
- types: ["image"],
260
+ types: ["image", "image/svg+xml"],
261
261
  multiple: false,
262
262
  selected: id?.value || null,
263
263
  onSelect: (selectedAttachment) => {
@@ -1027,7 +1027,7 @@ function EqualUnequalSizesControl({
1027
1027
  }
1028
1028
  return splitEqualValue() ?? null;
1029
1029
  };
1030
- return /* @__PURE__ */ React23.createElement(React23.Fragment, null, /* @__PURE__ */ React23.createElement(Grid4, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap", ref: controlRef }, /* @__PURE__ */ React23.createElement(Grid4, { item: true, xs: 6 }, /* @__PURE__ */ React23.createElement(ControlLabel, null, label)), /* @__PURE__ */ React23.createElement(Grid4, { item: true, xs: 6 }, /* @__PURE__ */ React23.createElement(Stack6, { direction: "row", alignItems: "center", gap: 1 }, /* @__PURE__ */ React23.createElement(SizeControl, { placeholder: __6("MIXED", "elementor") }), /* @__PURE__ */ React23.createElement(
1030
+ return /* @__PURE__ */ React23.createElement(React23.Fragment, null, /* @__PURE__ */ React23.createElement(Grid4, { container: true, gap: 2, alignItems: "center", flexWrap: "nowrap", ref: controlRef }, /* @__PURE__ */ React23.createElement(Grid4, { item: true, xs: 6 }, /* @__PURE__ */ React23.createElement(ControlLabel, null, label)), /* @__PURE__ */ React23.createElement(Grid4, { item: true, xs: 6 }, /* @__PURE__ */ React23.createElement(Stack6, { direction: "row", alignItems: "center", gap: 1 }, /* @__PURE__ */ React23.createElement(SizeControl, { placeholder: __6("Mixed", "elementor") }), /* @__PURE__ */ React23.createElement(
1031
1031
  ToggleButton2,
1032
1032
  {
1033
1033
  size: "tiny",
@@ -1062,38 +1062,39 @@ var MultiSizeValueControl = ({ item }) => /* @__PURE__ */ React23.createElement(
1062
1062
 
1063
1063
  // src/controls/linked-dimensions-control.tsx
1064
1064
  import * as React24 from "react";
1065
- import { linkedDimensionsPropTypeUtil } from "@elementor/editor-props";
1065
+ import {
1066
+ dimensionsPropTypeUtil,
1067
+ sizePropTypeUtil as sizePropTypeUtil3
1068
+ } from "@elementor/editor-props";
1066
1069
  import { DetachIcon, LinkIcon, SideBottomIcon, SideLeftIcon, SideRightIcon, SideTopIcon } from "@elementor/icons";
1067
1070
  import { Grid as Grid5, Stack as Stack7, ToggleButton as ToggleButton3 } from "@elementor/ui";
1068
1071
  import { __ as __7 } from "@wordpress/i18n";
1069
1072
  var LinkedDimensionsControl = createControl(({ label }) => {
1070
- const { value, setValue, propType } = useBoundProp(linkedDimensionsPropTypeUtil);
1071
- const { top, right, bottom, left, isLinked = true } = value || {};
1072
- const setLinkedValue = (newValue, _, meta) => {
1073
+ const { value: dimensionsValue, setValue: setDimensionsValue, propType } = useBoundProp(dimensionsPropTypeUtil);
1074
+ const { value: sizeValue, setValue: setSizeValue } = useBoundProp(sizePropTypeUtil3);
1075
+ const isLinked = !dimensionsValue && !sizeValue ? true : !!sizeValue;
1076
+ const setValue = (newValue) => {
1073
1077
  if (!isLinked) {
1074
- return setValue(newValue);
1078
+ setDimensionsValue(newValue);
1079
+ return;
1075
1080
  }
1076
- const newDimension = newValue[meta?.bind];
1077
- setValue({
1078
- isLinked,
1079
- top: newDimension,
1080
- right: newDimension,
1081
- bottom: newDimension,
1082
- left: newDimension
1083
- });
1081
+ setSizeValue(newValue.top);
1084
1082
  };
1085
- const toggleLinked = () => {
1086
- const updatedValue = {
1087
- isLinked: !isLinked,
1088
- top,
1089
- right: !isLinked ? top : right,
1090
- bottom: !isLinked ? top : bottom,
1091
- left: !isLinked ? top : left
1092
- };
1093
- setValue(updatedValue);
1083
+ const onLinkToggle = () => {
1084
+ if (!isLinked) {
1085
+ setSizeValue(dimensionsValue?.top.value);
1086
+ return;
1087
+ }
1088
+ const value = sizeValue ? sizePropTypeUtil3.create(sizeValue) : null;
1089
+ setDimensionsValue({
1090
+ top: value,
1091
+ right: value,
1092
+ bottom: value,
1093
+ left: value
1094
+ });
1094
1095
  };
1095
1096
  const LinkedIcon = isLinked ? LinkIcon : DetachIcon;
1096
- return /* @__PURE__ */ React24.createElement(PropProvider, { propType, value, setValue: setLinkedValue }, /* @__PURE__ */ React24.createElement(Stack7, { direction: "row", gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React24.createElement(ControlLabel, null, label), /* @__PURE__ */ React24.createElement(
1097
+ return /* @__PURE__ */ React24.createElement(PropProvider, { propType, value: dimensionsValue, setValue }, /* @__PURE__ */ React24.createElement(Stack7, { direction: "row", gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React24.createElement(ControlLabel, null, label), /* @__PURE__ */ React24.createElement(
1097
1098
  ToggleButton3,
1098
1099
  {
1099
1100
  "aria-label": __7("Link Inputs", "elementor"),
@@ -1101,12 +1102,45 @@ var LinkedDimensionsControl = createControl(({ label }) => {
1101
1102
  value: "check",
1102
1103
  selected: isLinked,
1103
1104
  sx: { marginLeft: "auto" },
1104
- onChange: toggleLinked
1105
+ onChange: onLinkToggle
1105
1106
  },
1106
1107
  /* @__PURE__ */ React24.createElement(LinkedIcon, { fontSize: "tiny" })
1107
- )), /* @__PURE__ */ React24.createElement(Stack7, { direction: "row", gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React24.createElement(Grid5, { container: true, gap: 1, alignItems: "center" }, /* @__PURE__ */ React24.createElement(Grid5, { item: true, xs: 12 }, /* @__PURE__ */ React24.createElement(ControlLabel, null, __7("Top", "elementor"))), /* @__PURE__ */ React24.createElement(Grid5, { item: true, xs: 12 }, /* @__PURE__ */ React24.createElement(Control3, { bind: "top", startIcon: /* @__PURE__ */ React24.createElement(SideTopIcon, { fontSize: "tiny" }) }))), /* @__PURE__ */ React24.createElement(Grid5, { container: true, gap: 1, alignItems: "center" }, /* @__PURE__ */ React24.createElement(Grid5, { item: true, xs: 12 }, /* @__PURE__ */ React24.createElement(ControlLabel, null, __7("Right", "elementor"))), /* @__PURE__ */ React24.createElement(Grid5, { item: true, xs: 12 }, /* @__PURE__ */ React24.createElement(Control3, { bind: "right", startIcon: /* @__PURE__ */ React24.createElement(SideRightIcon, { fontSize: "tiny" }) })))), /* @__PURE__ */ React24.createElement(Stack7, { direction: "row", gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React24.createElement(Grid5, { container: true, gap: 1, alignItems: "center" }, /* @__PURE__ */ React24.createElement(Grid5, { item: true, xs: 12 }, /* @__PURE__ */ React24.createElement(ControlLabel, null, __7("Bottom", "elementor"))), /* @__PURE__ */ React24.createElement(Grid5, { item: true, xs: 12 }, /* @__PURE__ */ React24.createElement(Control3, { bind: "bottom", startIcon: /* @__PURE__ */ React24.createElement(SideBottomIcon, { fontSize: "tiny" }) }))), /* @__PURE__ */ React24.createElement(Grid5, { container: true, gap: 1, alignItems: "center" }, /* @__PURE__ */ React24.createElement(Grid5, { item: true, xs: 12 }, /* @__PURE__ */ React24.createElement(ControlLabel, null, __7("Left", "elementor"))), /* @__PURE__ */ React24.createElement(Grid5, { item: true, xs: 12 }, /* @__PURE__ */ React24.createElement(Control3, { bind: "left", startIcon: /* @__PURE__ */ React24.createElement(SideLeftIcon, { fontSize: "tiny" }) })))));
1108
+ )), /* @__PURE__ */ React24.createElement(Stack7, { direction: "row", gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React24.createElement(Grid5, { container: true, gap: 1, alignItems: "center" }, /* @__PURE__ */ React24.createElement(Grid5, { item: true, xs: 12 }, /* @__PURE__ */ React24.createElement(ControlLabel, null, __7("Top", "elementor"))), /* @__PURE__ */ React24.createElement(Grid5, { item: true, xs: 12 }, /* @__PURE__ */ React24.createElement(
1109
+ Control3,
1110
+ {
1111
+ bind: "top",
1112
+ startIcon: /* @__PURE__ */ React24.createElement(SideTopIcon, { fontSize: "tiny" }),
1113
+ isLinked
1114
+ }
1115
+ ))), /* @__PURE__ */ React24.createElement(Grid5, { container: true, gap: 1, alignItems: "center" }, /* @__PURE__ */ React24.createElement(Grid5, { item: true, xs: 12 }, /* @__PURE__ */ React24.createElement(ControlLabel, null, __7("Right", "elementor"))), /* @__PURE__ */ React24.createElement(Grid5, { item: true, xs: 12 }, /* @__PURE__ */ React24.createElement(
1116
+ Control3,
1117
+ {
1118
+ bind: "right",
1119
+ startIcon: /* @__PURE__ */ React24.createElement(SideRightIcon, { fontSize: "tiny" }),
1120
+ isLinked
1121
+ }
1122
+ )))), /* @__PURE__ */ React24.createElement(Stack7, { direction: "row", gap: 2, flexWrap: "nowrap" }, /* @__PURE__ */ React24.createElement(Grid5, { container: true, gap: 1, alignItems: "center" }, /* @__PURE__ */ React24.createElement(Grid5, { item: true, xs: 12 }, /* @__PURE__ */ React24.createElement(ControlLabel, null, __7("Bottom", "elementor"))), /* @__PURE__ */ React24.createElement(Grid5, { item: true, xs: 12 }, /* @__PURE__ */ React24.createElement(
1123
+ Control3,
1124
+ {
1125
+ bind: "bottom",
1126
+ startIcon: /* @__PURE__ */ React24.createElement(SideBottomIcon, { fontSize: "tiny" }),
1127
+ isLinked
1128
+ }
1129
+ ))), /* @__PURE__ */ React24.createElement(Grid5, { container: true, gap: 1, alignItems: "center" }, /* @__PURE__ */ React24.createElement(Grid5, { item: true, xs: 12 }, /* @__PURE__ */ React24.createElement(ControlLabel, null, __7("Left", "elementor"))), /* @__PURE__ */ React24.createElement(Grid5, { item: true, xs: 12 }, /* @__PURE__ */ React24.createElement(
1130
+ Control3,
1131
+ {
1132
+ bind: "left",
1133
+ startIcon: /* @__PURE__ */ React24.createElement(SideLeftIcon, { fontSize: "tiny" }),
1134
+ isLinked
1135
+ }
1136
+ )))));
1108
1137
  });
1109
- var Control3 = ({ bind, startIcon }) => /* @__PURE__ */ React24.createElement(PropKeyProvider, { bind }, /* @__PURE__ */ React24.createElement(SizeControl, { startIcon }));
1138
+ var Control3 = ({ bind, startIcon, isLinked }) => {
1139
+ if (isLinked) {
1140
+ return /* @__PURE__ */ React24.createElement(SizeControl, { startIcon });
1141
+ }
1142
+ return /* @__PURE__ */ React24.createElement(PropKeyProvider, { bind }, /* @__PURE__ */ React24.createElement(SizeControl, { startIcon }));
1143
+ };
1110
1144
 
1111
1145
  // src/controls/font-family-control.tsx
1112
1146
  import { Fragment as Fragment3, useId as useId3, useState as useState4 } from "react";
@@ -1262,7 +1296,7 @@ var UrlControl = createControl(({ placeholder }) => {
1262
1296
 
1263
1297
  // src/controls/link-control.tsx
1264
1298
  import * as React27 from "react";
1265
- import { booleanPropTypeUtil, linkPropTypeUtil, stringPropTypeUtil as stringPropTypeUtil7 } from "@elementor/editor-props";
1299
+ import { booleanPropTypeUtil, linkPropTypeUtil, urlPropTypeUtil as urlPropTypeUtil2 } from "@elementor/editor-props";
1266
1300
  import { MinusIcon, PlusIcon as PlusIcon2 } from "@elementor/icons";
1267
1301
  import { useSessionStorage } from "@elementor/session";
1268
1302
  import { Collapse, Divider as Divider2, Grid as Grid6, IconButton as IconButton4, Stack as Stack9, Switch } from "@elementor/ui";
@@ -1305,7 +1339,7 @@ var LinkControl = createControl((props) => {
1305
1339
  {
1306
1340
  allowCustomValues: Object.keys(options).length ? allowCustomValues : true,
1307
1341
  options,
1308
- propType: stringPropTypeUtil7,
1342
+ propType: urlPropTypeUtil2,
1309
1343
  placeholder
1310
1344
  }
1311
1345
  )), /* @__PURE__ */ React27.createElement(PropKeyProvider, { bind: "isTargetBlank" }, /* @__PURE__ */ React27.createElement(SwitchControl, null))))));