@elementor/editor-variables 3.33.0-117 → 3.33.0-119

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.d.mts CHANGED
@@ -40,4 +40,6 @@ declare const registerVariableType: ({ icon, startIcon, valueField, propTypeUtil
40
40
  isCompatible?: (propType: _elementor_editor_props.PropType, variable: Variable) => boolean;
41
41
  }) => void;
42
42
 
43
- export { init, registerVariableType };
43
+ declare function registerVariableTypes(): void;
44
+
45
+ export { init, registerVariableType, registerVariableTypes };
package/dist/index.d.ts CHANGED
@@ -40,4 +40,6 @@ declare const registerVariableType: ({ icon, startIcon, valueField, propTypeUtil
40
40
  isCompatible?: (propType: _elementor_editor_props.PropType, variable: Variable) => boolean;
41
41
  }) => void;
42
42
 
43
- export { init, registerVariableType };
43
+ declare function registerVariableTypes(): void;
44
+
45
+ export { init, registerVariableType, registerVariableTypes };
package/dist/index.js CHANGED
@@ -31,7 +31,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  init: () => init,
34
- registerVariableType: () => registerVariableType
34
+ registerVariableType: () => registerVariableType,
35
+ registerVariableTypes: () => registerVariableTypes
35
36
  });
36
37
  module.exports = __toCommonJS(index_exports);
37
38
 
@@ -1110,7 +1111,15 @@ function VariablesManagerPanel() {
1110
1111
  const [deleteConfirmation, setDeleteConfirmation] = (0, import_react7.useState)(null);
1111
1112
  const [isDirty, setIsDirty] = (0, import_react7.useState)(false);
1112
1113
  const [isSaving, setIsSaving] = (0, import_react7.useState)(false);
1114
+ const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = (0, import_editor_ui2.useDialog)();
1113
1115
  usePreventUnload(isDirty);
1116
+ const handleClosePanel = () => {
1117
+ if (isDirty) {
1118
+ openSaveChangesDialog();
1119
+ return;
1120
+ }
1121
+ closePanel();
1122
+ };
1114
1123
  const handleSave = (0, import_react7.useCallback)(async () => {
1115
1124
  setIsSaving(true);
1116
1125
  const originalVariables = getVariables(false);
@@ -1151,7 +1160,7 @@ function VariablesManagerPanel() {
1151
1160
  {
1152
1161
  sx: { marginLeft: "auto" },
1153
1162
  onClose: () => {
1154
- closePanel();
1163
+ handleClosePanel();
1155
1164
  }
1156
1165
  }
1157
1166
  )), /* @__PURE__ */ React9.createElement(import_ui9.Divider, { sx: { width: "100%" } }))), /* @__PURE__ */ React9.createElement(
@@ -1190,6 +1199,27 @@ function VariablesManagerPanel() {
1190
1199
  onConfirm: () => handleDeleteVariable(deleteConfirmation.id),
1191
1200
  closeDialog: () => setDeleteConfirmation(null)
1192
1201
  }
1202
+ )), isSaveChangesDialogOpen && /* @__PURE__ */ React9.createElement(import_editor_ui2.SaveChangesDialog, null, /* @__PURE__ */ React9.createElement(import_editor_ui2.SaveChangesDialog.Title, { onClose: closeSaveChangesDialog }, (0, import_i18n6.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React9.createElement(import_editor_ui2.SaveChangesDialog.Content, null, /* @__PURE__ */ React9.createElement(import_editor_ui2.SaveChangesDialog.ContentText, null, (0, import_i18n6.__)("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React9.createElement(
1203
+ import_editor_ui2.SaveChangesDialog.Actions,
1204
+ {
1205
+ actions: {
1206
+ discard: {
1207
+ label: (0, import_i18n6.__)("Discard", "elementor"),
1208
+ action: () => {
1209
+ closeSaveChangesDialog();
1210
+ closePanel();
1211
+ }
1212
+ },
1213
+ confirm: {
1214
+ label: (0, import_i18n6.__)("Save", "elementor"),
1215
+ action: async () => {
1216
+ await handleSave();
1217
+ closeSaveChangesDialog();
1218
+ closePanel();
1219
+ }
1220
+ }
1221
+ }
1222
+ }
1193
1223
  )));
1194
1224
  }
1195
1225
  var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React9.createElement(import_ui9.IconButton, { size: "small", color: "secondary", onClick: onClose, "aria-label": "Close", ...props }, /* @__PURE__ */ React9.createElement(import_icons4.XIcon, { fontSize: "small" }));
@@ -2837,6 +2867,7 @@ function hasAssignedVariable(propValue) {
2837
2867
  // Annotate the CommonJS export names for ESM import in node:
2838
2868
  0 && (module.exports = {
2839
2869
  init,
2840
- registerVariableType
2870
+ registerVariableType,
2871
+ registerVariableTypes
2841
2872
  });
2842
2873
  //# sourceMappingURL=index.js.map