@elementor/editor-variables 3.32.0-35 → 3.32.0-37

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.js CHANGED
@@ -846,13 +846,19 @@ var VariableCreation = ({ onGoBack, onClose }) => {
846
846
  action: "save"
847
847
  });
848
848
  };
849
- const hasEmptyValue = () => {
850
- return "" === value.trim() || "" === label.trim();
849
+ const hasEmptyFields = () => {
850
+ if ("" === label.trim()) {
851
+ return true;
852
+ }
853
+ if ("string" === typeof value) {
854
+ return "" === value.trim();
855
+ }
856
+ return false === Boolean(value);
851
857
  };
852
858
  const hasErrors = () => {
853
859
  return !!errorMessage;
854
860
  };
855
- const isSubmitDisabled = hasEmptyValue() || hasErrors();
861
+ const isSubmitDisabled = hasEmptyFields() || hasErrors();
856
862
  return /* @__PURE__ */ React7.createElement(import_editor_editing_panel2.PopoverBody, { height: "auto" }, /* @__PURE__ */ React7.createElement(
857
863
  import_editor_ui2.PopoverHeader,
858
864
  {
@@ -964,8 +970,8 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
964
970
  throw new Error(`Global ${variableType} variable not found`);
965
971
  }
966
972
  const userPermissions = usePermissions();
967
- const [value, setValue] = (0, import_react8.useState)(variable.value);
968
- const [label, setLabel] = (0, import_react8.useState)(variable.label);
973
+ const [value, setValue] = (0, import_react8.useState)(() => variable.value);
974
+ const [label, setLabel] = (0, import_react8.useState)(() => variable.label);
969
975
  (0, import_react8.useEffect)(() => {
970
976
  styleVariablesRepository.update({
971
977
  [editId]: {
@@ -1041,8 +1047,14 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
1041
1047
  )
1042
1048
  );
1043
1049
  }
1044
- const hasEmptyValues = () => {
1045
- return !value.trim() || !label.trim();
1050
+ const hasEmptyFields = () => {
1051
+ if ("" === label.trim()) {
1052
+ return true;
1053
+ }
1054
+ if ("string" === typeof value) {
1055
+ return "" === value.trim();
1056
+ }
1057
+ return false === Boolean(value);
1046
1058
  };
1047
1059
  const noValueChanged = () => {
1048
1060
  return value === variable.value && label === variable.label;
@@ -1050,7 +1062,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
1050
1062
  const hasErrors = () => {
1051
1063
  return !!errorMessage;
1052
1064
  };
1053
- const isSubmitDisabled = noValueChanged() || hasEmptyValues() || hasErrors();
1065
+ const isSubmitDisabled = noValueChanged() || hasEmptyFields() || hasErrors();
1054
1066
  return /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement(import_editor_editing_panel3.PopoverBody, { height: "auto" }, /* @__PURE__ */ React10.createElement(
1055
1067
  import_editor_ui3.PopoverHeader,
1056
1068
  {
@@ -1561,8 +1573,14 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
1561
1573
  setErrorMessage(ERROR_MESSAGES.UNEXPECTED_ERROR);
1562
1574
  });
1563
1575
  };
1564
- const hasEmptyValues = () => {
1565
- return !value.trim() || !label.trim();
1576
+ const hasEmptyFields = () => {
1577
+ if ("" === label.trim()) {
1578
+ return true;
1579
+ }
1580
+ if ("string" === typeof value) {
1581
+ return "" === value.trim();
1582
+ }
1583
+ return false === Boolean(value);
1566
1584
  };
1567
1585
  const noValueChanged = () => {
1568
1586
  return value === variable.value && label === variable.label;
@@ -1570,7 +1588,7 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
1570
1588
  const hasErrors = () => {
1571
1589
  return !!errorMessage;
1572
1590
  };
1573
- const isSubmitDisabled = noValueChanged() || hasEmptyValues() || hasErrors();
1591
+ const isSubmitDisabled = noValueChanged() || hasEmptyFields() || hasErrors();
1574
1592
  return /* @__PURE__ */ React18.createElement(PopoverContentRefContextProvider, null, /* @__PURE__ */ React18.createElement(import_editor_editing_panel5.PopoverBody, { height: "auto" }, /* @__PURE__ */ React18.createElement(
1575
1593
  import_editor_ui6.PopoverHeader,
1576
1594
  {