@elementor/editor-variables 4.2.0-880 → 4.2.0-882

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
@@ -49,7 +49,6 @@ var import_react13 = require("react");
49
49
  var import_editor_current_user2 = require("@elementor/editor-current-user");
50
50
  var import_editor_panels = require("@elementor/editor-panels");
51
51
  var import_editor_ui5 = require("@elementor/editor-ui");
52
- var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
53
52
  var import_icons5 = require("@elementor/icons");
54
53
  var import_ui14 = require("@elementor/ui");
55
54
  var import_i18n10 = require("@wordpress/i18n");
@@ -245,19 +244,19 @@ var apiClient = {
245
244
  value
246
245
  });
247
246
  },
248
- update: (id2, label, value, type) => {
247
+ update: (id, label, value, type) => {
249
248
  return (0, import_http_client.httpService)().put(BASE_PATH + "/update", {
250
- id: id2,
249
+ id,
251
250
  label,
252
251
  value,
253
252
  type
254
253
  });
255
254
  },
256
- delete: (id2) => {
257
- return (0, import_http_client.httpService)().post(BASE_PATH + "/delete", { id: id2 });
255
+ delete: (id) => {
256
+ return (0, import_http_client.httpService)().post(BASE_PATH + "/delete", { id });
258
257
  },
259
- restore: (id2, label, value, type) => {
260
- const payload = { id: id2 };
258
+ restore: (id, label, value, type) => {
259
+ const payload = { id };
261
260
  if (label) {
262
261
  payload.label = label;
263
262
  }
@@ -280,34 +279,34 @@ var generateTempId = () => {
280
279
  const random = Math.random().toString(36).substring(2, 8);
281
280
  return `tmp-${timestamp}-${random}`;
282
281
  };
283
- var isTempId = (id2) => {
284
- return id2.startsWith("tmp-");
282
+ var isTempId = (id) => {
283
+ return id.startsWith("tmp-");
285
284
  };
286
285
  var buildOperationsArray = (originalVariables, currentVariables, deletedVariables) => {
287
286
  const operations = [];
288
- Object.entries(currentVariables).forEach(([id2, variable]) => {
289
- if (isTempId(id2)) {
287
+ Object.entries(currentVariables).forEach(([id, variable]) => {
288
+ if (isTempId(id)) {
290
289
  operations.push({
291
290
  type: "create",
292
291
  variable: {
293
292
  ...variable,
294
- id: id2
293
+ id
295
294
  }
296
295
  });
297
- } else if (originalVariables[id2]) {
298
- const original = originalVariables[id2];
296
+ } else if (originalVariables[id]) {
297
+ const original = originalVariables[id];
299
298
  const syncChanged = original.sync_to_v3 !== variable.sync_to_v3;
300
299
  if (original.deleted && !variable.deleted) {
301
300
  operations.push({
302
301
  type: "restore",
303
- id: id2,
302
+ id,
304
303
  ...original.label !== variable.label && { label: variable.label },
305
304
  ...original.value !== variable.value && { value: variable.value }
306
305
  });
307
306
  } else if (!variable.deleted && (original.label !== variable.label || original.value !== variable.value || original.order !== variable.order || original.type !== variable.type || syncChanged)) {
308
307
  operations.push({
309
308
  type: "update",
310
- id: id2,
309
+ id,
311
310
  variable: {
312
311
  ...original.label !== variable.label && { label: variable.label },
313
312
  ...original.value !== variable.value && { value: variable.value },
@@ -319,15 +318,15 @@ var buildOperationsArray = (originalVariables, currentVariables, deletedVariable
319
318
  }
320
319
  }
321
320
  });
322
- deletedVariables.forEach((id2) => {
321
+ deletedVariables.forEach((id) => {
323
322
  operations.push({
324
323
  type: "delete",
325
- id: id2
324
+ id
326
325
  });
327
326
  });
328
327
  return operations.filter((op) => {
329
- const id2 = op.id || op.variable?.id;
330
- return id2 && !(isTempId(id2) && currentVariables[id2]?.deleted);
328
+ const id = op.id || op.variable?.id;
329
+ return id && !(isTempId(id) && currentVariables[id]?.deleted);
331
330
  });
332
331
  };
333
332
 
@@ -363,15 +362,15 @@ var Storage = class {
363
362
  localStorage.setItem(STORAGE_KEY, JSON.stringify(this.state.variables));
364
363
  this.notifyChange();
365
364
  }
366
- add(id2, variable) {
365
+ add(id, variable) {
367
366
  this.load();
368
- this.state.variables[id2] = variable;
367
+ this.state.variables[id] = variable;
369
368
  localStorage.setItem(STORAGE_KEY, JSON.stringify(this.state.variables));
370
369
  this.notifyChange();
371
370
  }
372
- update(id2, variable) {
371
+ update(id, variable) {
373
372
  this.load();
374
- this.state.variables[id2] = variable;
373
+ this.state.variables[id] = variable;
375
374
  localStorage.setItem(STORAGE_KEY, JSON.stringify(this.state.variables));
376
375
  this.notifyChange();
377
376
  }
@@ -527,8 +526,8 @@ var service = {
527
526
  };
528
527
  });
529
528
  },
530
- update: (id2, { label, value, type }) => {
531
- return apiClient.update(id2, label, value, type).then((response) => {
529
+ update: (id, { label, value, type }) => {
530
+ return apiClient.update(id, label, value, type).then((response) => {
532
531
  const { success, data: payload } = response.data;
533
532
  if (!success) {
534
533
  const errorMessage = payload?.message || (0, import_i18n2.__)("Unexpected response from server", "elementor");
@@ -549,8 +548,8 @@ var service = {
549
548
  };
550
549
  });
551
550
  },
552
- delete: (id2) => {
553
- return apiClient.delete(id2).then((response) => {
551
+ delete: (id) => {
552
+ return apiClient.delete(id).then((response) => {
554
553
  const { success, data: payload } = response.data;
555
554
  if (!success) {
556
555
  throw new Error("Unexpected response from server");
@@ -570,8 +569,8 @@ var service = {
570
569
  };
571
570
  });
572
571
  },
573
- restore: (id2, label, value, type) => {
574
- return apiClient.restore(id2, label, value, type).then((response) => {
572
+ restore: (id, label, value, type) => {
573
+ return apiClient.restore(id, label, value, type).then((response) => {
575
574
  const { success, data: payload } = response.data;
576
575
  if (!success) {
577
576
  throw new Error("Unexpected response from server");
@@ -641,8 +640,8 @@ var handleWatermark = (operation, newWatermark) => {
641
640
  };
642
641
 
643
642
  // src/transformers/utils/resolve-css-variable.ts
644
- var resolveCssVariable = (id2, variable) => {
645
- let name = id2;
643
+ var resolveCssVariable = (id, variable) => {
644
+ let name = id;
646
645
  let fallbackValue = "";
647
646
  if (variable) {
648
647
  fallbackValue = variable.value;
@@ -661,14 +660,14 @@ var resolveCssVariable = (id2, variable) => {
661
660
  };
662
661
 
663
662
  // src/transformers/inheritance-transformer.tsx
664
- var inheritanceTransformer = (0, import_editor_canvas.createTransformer)((id2) => {
663
+ var inheritanceTransformer = (0, import_editor_canvas.createTransformer)((id) => {
665
664
  const variables = service.variables();
666
- const variable = variables[id2];
665
+ const variable = variables[id];
667
666
  if (!variable) {
668
667
  return /* @__PURE__ */ React.createElement("span", null, (0, import_i18n3.__)("Missing variable", "elementor"));
669
668
  }
670
669
  const showColorIndicator = variable.type === colorVariablePropTypeUtil.key;
671
- const css = resolveCssVariable(id2, variable);
670
+ const css = resolveCssVariable(id, variable);
672
671
  return /* @__PURE__ */ React.createElement(import_ui2.Stack, { direction: "row", spacing: 0.5, sx: { paddingInline: "1px" }, alignItems: "center" }, showColorIndicator && /* @__PURE__ */ React.createElement(ColorIndicator, { size: "inherit", value: variable.value }), /* @__PURE__ */ React.createElement(import_ui2.Typography, { variant: "caption", overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis" }, css));
673
672
  });
674
673
 
@@ -684,8 +683,8 @@ var variableTransformer = (0, import_editor_canvas2.createTransformer)((idOrLabe
684
683
  const count = parseInt((targetVariable.value ?? "").trim(), 10);
685
684
  return (0, import_editor_canvas2.formatGridTrackRepeat)(count);
686
685
  }
687
- const id2 = service.findIdByLabel(targetVariable.label);
688
- return resolveCssVariable(id2, targetVariable);
686
+ const id = service.findIdByLabel(targetVariable.label);
687
+ return resolveCssVariable(id, targetVariable);
689
688
  });
690
689
 
691
690
  // src/variables-registry/create-variable-type-registry.ts
@@ -1018,7 +1017,7 @@ var normalizeVariables = (propKey) => {
1018
1017
  const matchingTypes = getMatchingTypes(propKey);
1019
1018
  return variablesToList(variables).filter((variable) => matchingTypes.includes(variable.type)).map(toNormalizedVariable);
1020
1019
  };
1021
- var extractId = ({ id: id2 }) => id2;
1020
+ var extractId = ({ id }) => id;
1022
1021
  var createVariable = (newVariable) => {
1023
1022
  return service.create(newVariable).then(extractId);
1024
1023
  };
@@ -1077,8 +1076,17 @@ var useVariablesManagerState = () => {
1077
1076
  }, []);
1078
1077
  const handleOnChange = (0, import_react5.useCallback)(
1079
1078
  (newVariables) => {
1080
- setVariables({ ...variables, ...newVariables });
1081
- setIsDirty(true);
1079
+ const hasChanges = Object.entries(newVariables).some(([id, newVar]) => {
1080
+ const existingVar = variables[id];
1081
+ if (!existingVar) {
1082
+ return true;
1083
+ }
1084
+ return existingVar.label !== newVar.label || existingVar.value !== newVar.value || existingVar.order !== newVar.order || existingVar.type !== newVar.type || (existingVar.sync_to_v3 ?? false) !== (newVar.sync_to_v3 ?? false);
1085
+ });
1086
+ if (hasChanges) {
1087
+ setVariables({ ...variables, ...newVariables });
1088
+ setIsDirty(true);
1089
+ }
1082
1090
  },
1083
1091
  [variables]
1084
1092
  );
@@ -1429,7 +1437,7 @@ var LabelField = ({
1429
1437
  value,
1430
1438
  error,
1431
1439
  onChange,
1432
- id: id2,
1440
+ id,
1433
1441
  onErrorChange,
1434
1442
  size = "tiny",
1435
1443
  focusOnShow = false,
@@ -1457,7 +1465,7 @@ var LabelField = ({
1457
1465
  import_ui9.TextField,
1458
1466
  {
1459
1467
  ref: fieldRef,
1460
- id: id2,
1468
+ id,
1461
1469
  size,
1462
1470
  fullWidth: true,
1463
1471
  value: label,
@@ -1808,7 +1816,7 @@ var VariableRow = (props) => {
1808
1816
  value,
1809
1817
  onChange,
1810
1818
  onPropTypeKeyChange: (type) => {
1811
- if (!isDisabled) {
1819
+ if (!isDisabled && type !== row.type) {
1812
1820
  handleOnChange({
1813
1821
  ...variables,
1814
1822
  [row.id]: { ...variables[row.id], type }
@@ -1878,22 +1886,22 @@ var VariablesManagerTable = ({
1878
1886
  }
1879
1887
  }
1880
1888
  }, [autoEditVariableId]);
1881
- const handleRowRef = (id2) => (ref) => {
1889
+ const handleRowRef = (id) => (ref) => {
1882
1890
  if (ref) {
1883
- variableRowRefs.current.set(id2, ref);
1891
+ variableRowRefs.current.set(id, ref);
1884
1892
  } else {
1885
- variableRowRefs.current.delete(id2);
1893
+ variableRowRefs.current.delete(id);
1886
1894
  }
1887
1895
  };
1888
1896
  const ids = Object.keys(variables).sort(sortVariablesOrder(variables));
1889
- const rows = ids.map((id2) => {
1890
- const variable = variables[id2];
1897
+ const rows = ids.map((id) => {
1898
+ const variable = variables[id];
1891
1899
  const variableType = getVariableType(variable.type);
1892
1900
  if (!variableType) {
1893
1901
  return null;
1894
1902
  }
1895
1903
  return {
1896
- id: id2,
1904
+ id,
1897
1905
  type: variable.type,
1898
1906
  name: variable.label,
1899
1907
  value: variable.value,
@@ -1906,12 +1914,12 @@ var VariablesManagerTable = ({
1906
1914
  };
1907
1915
  const handleReorder = (newIds) => {
1908
1916
  const updatedVariables = { ...variables };
1909
- newIds.forEach((id2, index) => {
1910
- const current = updatedVariables[id2];
1917
+ newIds.forEach((id, index) => {
1918
+ const current = updatedVariables[id];
1911
1919
  if (!current) {
1912
1920
  return;
1913
1921
  }
1914
- updatedVariables[id2] = Object.assign({}, current, { order: index + 1 });
1922
+ updatedVariables[id] = Object.assign({}, current, { order: index + 1 });
1915
1923
  });
1916
1924
  handleOnChange(updatedVariables);
1917
1925
  };
@@ -1956,47 +1964,14 @@ function sortVariablesOrder(variables) {
1956
1964
  }
1957
1965
 
1958
1966
  // src/components/variables-manager/variables-manager-panel.tsx
1959
- var id = "variables-manager";
1960
1967
  var STOP_SYNC_MESSAGE_KEY = "stop-sync-variable";
1961
- var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
1962
- id,
1963
- component: VariablesManagerPanel,
1964
- allowedEditModes: ["edit", id],
1965
- onOpen: () => {
1966
- (0, import_editor_v1_adapters2.changeEditMode)(id);
1967
- },
1968
- onClose: async () => {
1969
- (0, import_editor_v1_adapters2.changeEditMode)("edit");
1970
- },
1971
- isOpenPreviousElement: true
1972
- });
1973
1968
  function VariablesManagerPanelEmbedded({
1974
1969
  onRequestClose,
1975
1970
  onExposeCloseAttempt
1976
1971
  }) {
1977
- return /* @__PURE__ */ React14.createElement(
1978
- VariablesManagerPanelRoot,
1979
- {
1980
- embedded: true,
1981
- onRequestClose,
1982
- onExposeCloseAttempt
1983
- }
1984
- );
1972
+ return /* @__PURE__ */ React14.createElement(VariablesManagerPanelContent, { onRequestClose, onExposeCloseAttempt });
1985
1973
  }
1986
- function VariablesManagerPanel() {
1987
- return /* @__PURE__ */ React14.createElement(VariablesManagerPanelRoot, null);
1988
- }
1989
- function VariablesManagerPanelRoot({
1990
- embedded = false,
1991
- onRequestClose,
1992
- onExposeCloseAttempt
1993
- } = {}) {
1994
- const { close: closeStandalonePanel } = usePanelActions();
1995
- const closePanel = (0, import_react13.useMemo)(
1996
- () => embedded ? onRequestClose ?? (async () => {
1997
- }) : closeStandalonePanel,
1998
- [embedded, onRequestClose, closeStandalonePanel]
1999
- );
1974
+ function VariablesManagerPanelContent({ onRequestClose, onExposeCloseAttempt }) {
2000
1975
  const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = (0, import_editor_ui5.useDialog)();
2001
1976
  const [isStopSyncSuppressed] = (0, import_editor_current_user2.useSuppressedMessage)(STOP_SYNC_MESSAGE_KEY);
2002
1977
  const createMenuState = (0, import_ui14.usePopupState)({
@@ -2030,15 +2005,15 @@ function VariablesManagerPanelRoot({
2030
2005
  openSaveChangesDialog();
2031
2006
  return;
2032
2007
  }
2033
- void closePanel();
2034
- }, [isDirty, openSaveChangesDialog, closePanel]);
2008
+ void onRequestClose();
2009
+ }, [isDirty, openSaveChangesDialog, onRequestClose]);
2035
2010
  (0, import_react13.useEffect)(() => {
2036
- if (!embedded || !onExposeCloseAttempt) {
2011
+ if (!onExposeCloseAttempt) {
2037
2012
  return;
2038
2013
  }
2039
2014
  onExposeCloseAttempt(() => handleClosePanel());
2040
2015
  return () => onExposeCloseAttempt(null);
2041
- }, [embedded, onExposeCloseAttempt, handleClosePanel]);
2016
+ }, [onExposeCloseAttempt, handleClosePanel]);
2042
2017
  const handleCreateVariable = (0, import_react13.useCallback)(
2043
2018
  (type, defaultName, defaultValue) => {
2044
2019
  const newId = createVariable2(type, defaultName, defaultValue);
@@ -2156,144 +2131,7 @@ function VariablesManagerPanelRoot({
2156
2131
  [variables, handleStartSync, handleStopSync, duplicateVariable, startAutoEdit]
2157
2132
  );
2158
2133
  const hasVariables = Object.keys(variables).length > 0;
2159
- const variablesSearchFieldSx = embedded ? {
2160
- flex: 1,
2161
- minWidth: 0,
2162
- px: 0,
2163
- py: 0,
2164
- display: "flex",
2165
- alignItems: "center",
2166
- alignSelf: "stretch"
2167
- } : {
2168
- display: "flex",
2169
- flex: 1
2170
- };
2171
- const searchField = /* @__PURE__ */ React14.createElement(
2172
- import_editor_ui5.SearchField,
2173
- {
2174
- placeholder: (0, import_i18n10.__)("Search", "elementor"),
2175
- value: searchValue,
2176
- onSearch: handleSearch,
2177
- sx: variablesSearchFieldSx
2178
- }
2179
- );
2180
- const bodyInner = /* @__PURE__ */ React14.createElement(React14.Fragment, null, hasVariables && /* @__PURE__ */ React14.createElement(
2181
- VariablesManagerTable,
2182
- {
2183
- menuActions: buildMenuActions,
2184
- variables,
2185
- onChange: handleOnChange,
2186
- autoEditVariableId,
2187
- onAutoEditComplete: handleAutoEditComplete,
2188
- onFieldError: setIsSaveDisabled
2189
- }
2190
- ), !hasVariables && searchValue && /* @__PURE__ */ React14.createElement(
2191
- NoSearchResults,
2192
- {
2193
- searchValue,
2194
- onClear: () => handleSearch(""),
2195
- icon: /* @__PURE__ */ React14.createElement(import_icons5.ColorFilterIcon, { fontSize: "large" })
2196
- }
2197
- ), !hasVariables && !searchValue && /* @__PURE__ */ React14.createElement(
2198
- EmptyState,
2199
- {
2200
- title: (0, import_i18n10.__)("Create your first variable", "elementor"),
2201
- message: (0, import_i18n10.__)(
2202
- "Variables are saved attributes that you can apply anywhere on your site.",
2203
- "elementor"
2204
- ),
2205
- icon: /* @__PURE__ */ React14.createElement(import_icons5.ColorFilterIcon, { fontSize: "large" }),
2206
- onAdd: createMenuState.open
2207
- }
2208
- ));
2209
- const saveFooter = /* @__PURE__ */ React14.createElement(import_editor_panels.PanelFooter, null, /* @__PURE__ */ React14.createElement(
2210
- import_ui14.Infotip,
2211
- {
2212
- placement: "right",
2213
- open: !!serverError,
2214
- content: serverError ? /* @__PURE__ */ React14.createElement(
2215
- import_ui14.Alert,
2216
- {
2217
- severity: serverError.severity ?? "error",
2218
- action: serverError.action?.label ? /* @__PURE__ */ React14.createElement(import_ui14.AlertAction, { onClick: serverError.action.callback }, serverError.action.label) : void 0,
2219
- onClose: !serverError.action?.label ? () => {
2220
- setServerError(null);
2221
- setIsSaveDisabled(false);
2222
- } : void 0,
2223
- icon: serverError.IconComponent ? /* @__PURE__ */ React14.createElement(serverError.IconComponent, null) : /* @__PURE__ */ React14.createElement(import_icons5.AlertTriangleFilledIcon, null)
2224
- },
2225
- /* @__PURE__ */ React14.createElement(import_ui14.AlertTitle, null, serverError.message),
2226
- serverError.action?.message
2227
- ) : null,
2228
- arrow: false,
2229
- slotProps: {
2230
- popper: {
2231
- modifiers: [
2232
- {
2233
- name: "offset",
2234
- options: { offset: [-10, 10] }
2235
- }
2236
- ]
2237
- }
2238
- }
2239
- },
2240
- /* @__PURE__ */ React14.createElement(
2241
- import_ui14.Button,
2242
- {
2243
- fullWidth: true,
2244
- size: "small",
2245
- color: "global",
2246
- variant: "contained",
2247
- disabled: isSaveDisabled || !isDirty || isSaving,
2248
- onClick: handleSaveClick,
2249
- loading: isSaving
2250
- },
2251
- (0, import_i18n10.__)("Save changes", "elementor")
2252
- )
2253
- ));
2254
- const dialogs = /* @__PURE__ */ React14.createElement(React14.Fragment, null, deleteConfirmation && /* @__PURE__ */ React14.createElement(
2255
- DeleteConfirmationDialog,
2256
- {
2257
- open: true,
2258
- label: deleteConfirmation.label,
2259
- onConfirm: () => handleDeleteVariableWithConfirmation(deleteConfirmation.id),
2260
- closeDialog: () => setDeleteConfirmation(null)
2261
- }
2262
- ), stopSyncConfirmation && /* @__PURE__ */ React14.createElement(
2263
- StopSyncConfirmationDialog,
2264
- {
2265
- open: true,
2266
- onClose: () => setStopSyncConfirmation(null),
2267
- onConfirm: () => {
2268
- commitStopSync(stopSyncConfirmation);
2269
- setStopSyncConfirmation(null);
2270
- }
2271
- }
2272
- ), isSaveChangesDialogOpen && /* @__PURE__ */ React14.createElement(import_editor_ui5.SaveChangesDialog, null, /* @__PURE__ */ React14.createElement(import_editor_ui5.SaveChangesDialog.Title, { onClose: closeSaveChangesDialog }, (0, import_i18n10.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React14.createElement(import_editor_ui5.SaveChangesDialog.Content, null, /* @__PURE__ */ React14.createElement(import_editor_ui5.SaveChangesDialog.ContentText, null, (0, import_i18n10.__)("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React14.createElement(
2273
- import_editor_ui5.SaveChangesDialog.Actions,
2274
- {
2275
- actions: {
2276
- discard: {
2277
- label: (0, import_i18n10.__)("Discard", "elementor"),
2278
- action: () => {
2279
- closeSaveChangesDialog();
2280
- void closePanel();
2281
- }
2282
- },
2283
- confirm: {
2284
- label: (0, import_i18n10.__)("Save", "elementor"),
2285
- action: async () => {
2286
- const result = await handleSaveClick();
2287
- closeSaveChangesDialog();
2288
- if (result?.success) {
2289
- void closePanel();
2290
- }
2291
- }
2292
- }
2293
- }
2294
- }
2295
- )));
2296
- const panelChrome = embedded ? /* @__PURE__ */ React14.createElement(
2134
+ return /* @__PURE__ */ React14.createElement(React14.Fragment, null, /* @__PURE__ */ React14.createElement(
2297
2135
  import_ui14.Stack,
2298
2136
  {
2299
2137
  direction: "column",
@@ -2318,7 +2156,23 @@ function VariablesManagerPanelRoot({
2318
2156
  pb: 1
2319
2157
  }
2320
2158
  },
2321
- searchField,
2159
+ /* @__PURE__ */ React14.createElement(
2160
+ import_editor_ui5.SearchField,
2161
+ {
2162
+ placeholder: (0, import_i18n10.__)("Search", "elementor"),
2163
+ value: searchValue,
2164
+ onSearch: handleSearch,
2165
+ sx: {
2166
+ flex: 1,
2167
+ minWidth: 0,
2168
+ px: 0,
2169
+ py: 0,
2170
+ display: "flex",
2171
+ alignItems: "center",
2172
+ alignSelf: "stretch"
2173
+ }
2174
+ }
2175
+ ),
2322
2176
  /* @__PURE__ */ React14.createElement(import_ui14.Box, { sx: { display: "flex", flexShrink: 0, alignItems: "center" } }, /* @__PURE__ */ React14.createElement(
2323
2177
  VariableManagerCreateMenu,
2324
2178
  {
@@ -2340,46 +2194,125 @@ function VariablesManagerPanelRoot({
2340
2194
  minHeight: 0
2341
2195
  }
2342
2196
  },
2343
- bodyInner
2197
+ hasVariables && /* @__PURE__ */ React14.createElement(
2198
+ VariablesManagerTable,
2199
+ {
2200
+ menuActions: buildMenuActions,
2201
+ variables,
2202
+ onChange: handleOnChange,
2203
+ autoEditVariableId,
2204
+ onAutoEditComplete: handleAutoEditComplete,
2205
+ onFieldError: setIsSaveDisabled
2206
+ }
2207
+ ),
2208
+ !hasVariables && searchValue && /* @__PURE__ */ React14.createElement(
2209
+ NoSearchResults,
2210
+ {
2211
+ searchValue,
2212
+ onClear: () => handleSearch(""),
2213
+ icon: /* @__PURE__ */ React14.createElement(import_icons5.ColorFilterIcon, { fontSize: "large" })
2214
+ }
2215
+ ),
2216
+ !hasVariables && !searchValue && /* @__PURE__ */ React14.createElement(
2217
+ EmptyState,
2218
+ {
2219
+ title: (0, import_i18n10.__)("Create your first variable", "elementor"),
2220
+ message: (0, import_i18n10.__)(
2221
+ "Variables are saved attributes that you can apply anywhere on your site.",
2222
+ "elementor"
2223
+ ),
2224
+ icon: /* @__PURE__ */ React14.createElement(import_icons5.ColorFilterIcon, { fontSize: "large" }),
2225
+ onAdd: createMenuState.open
2226
+ }
2227
+ )
2344
2228
  ),
2345
- saveFooter
2346
- ) : /* @__PURE__ */ React14.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React14.createElement(
2347
- import_editor_panels.PanelHeader,
2348
- {
2349
- sx: {
2350
- height: "unset"
2351
- }
2352
- },
2353
- /* @__PURE__ */ React14.createElement(import_ui14.Stack, { width: "100%", direction: "column", alignItems: "center" }, /* @__PURE__ */ React14.createElement(import_ui14.Stack, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React14.createElement(import_ui14.Stack, { width: "100%", direction: "row", gap: 1 }, /* @__PURE__ */ React14.createElement(import_editor_panels.PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React14.createElement(import_icons5.ColorFilterIcon, { fontSize: "inherit" }), (0, import_i18n10.__)("Variables Manager", "elementor"))), /* @__PURE__ */ React14.createElement(import_ui14.Stack, { direction: "row", gap: 0.5, alignItems: "center" }, /* @__PURE__ */ React14.createElement(
2354
- VariableManagerCreateMenu,
2229
+ /* @__PURE__ */ React14.createElement(import_editor_panels.PanelFooter, null, /* @__PURE__ */ React14.createElement(
2230
+ import_ui14.Infotip,
2355
2231
  {
2356
- onCreate: handleCreateVariable,
2357
- variables,
2358
- menuState: createMenuState
2359
- }
2360
- ), /* @__PURE__ */ React14.createElement(
2361
- import_ui14.CloseButton,
2362
- {
2363
- "aria-label": "Close",
2364
- slotProps: { icon: { fontSize: SIZE } },
2365
- onClick: () => {
2366
- handleClosePanel();
2232
+ placement: "right",
2233
+ open: !!serverError,
2234
+ content: serverError ? /* @__PURE__ */ React14.createElement(
2235
+ import_ui14.Alert,
2236
+ {
2237
+ severity: serverError.severity ?? "error",
2238
+ action: serverError.action?.label ? /* @__PURE__ */ React14.createElement(import_ui14.AlertAction, { onClick: serverError.action.callback }, serverError.action.label) : void 0,
2239
+ onClose: !serverError.action?.label ? () => {
2240
+ setServerError(null);
2241
+ setIsSaveDisabled(false);
2242
+ } : void 0,
2243
+ icon: serverError.IconComponent ? /* @__PURE__ */ React14.createElement(serverError.IconComponent, null) : /* @__PURE__ */ React14.createElement(import_icons5.AlertTriangleFilledIcon, null)
2244
+ },
2245
+ /* @__PURE__ */ React14.createElement(import_ui14.AlertTitle, null, serverError.message),
2246
+ serverError.action?.message
2247
+ ) : null,
2248
+ arrow: false,
2249
+ slotProps: {
2250
+ popper: {
2251
+ modifiers: [
2252
+ {
2253
+ name: "offset",
2254
+ options: { offset: [-10, 10] }
2255
+ }
2256
+ ]
2257
+ }
2367
2258
  }
2259
+ },
2260
+ /* @__PURE__ */ React14.createElement(
2261
+ import_ui14.Button,
2262
+ {
2263
+ fullWidth: true,
2264
+ size: "small",
2265
+ color: "global",
2266
+ variant: "contained",
2267
+ disabled: isSaveDisabled || !isDirty || isSaving,
2268
+ onClick: handleSaveClick,
2269
+ loading: isSaving
2270
+ },
2271
+ (0, import_i18n10.__)("Save changes", "elementor")
2272
+ )
2273
+ ))
2274
+ ), deleteConfirmation && /* @__PURE__ */ React14.createElement(
2275
+ DeleteConfirmationDialog,
2276
+ {
2277
+ open: true,
2278
+ label: deleteConfirmation.label,
2279
+ onConfirm: () => handleDeleteVariableWithConfirmation(deleteConfirmation.id),
2280
+ closeDialog: () => setDeleteConfirmation(null)
2281
+ }
2282
+ ), stopSyncConfirmation && /* @__PURE__ */ React14.createElement(
2283
+ StopSyncConfirmationDialog,
2284
+ {
2285
+ open: true,
2286
+ onClose: () => setStopSyncConfirmation(null),
2287
+ onConfirm: () => {
2288
+ commitStopSync(stopSyncConfirmation);
2289
+ setStopSyncConfirmation(null);
2368
2290
  }
2369
- ))), /* @__PURE__ */ React14.createElement(import_ui14.Stack, { width: "100%", direction: "row", gap: 1 }, searchField), /* @__PURE__ */ React14.createElement(import_ui14.Divider, { sx: { width: "100%" } }))
2370
- ), /* @__PURE__ */ React14.createElement(
2371
- import_editor_panels.PanelBody,
2291
+ }
2292
+ ), isSaveChangesDialogOpen && /* @__PURE__ */ React14.createElement(import_editor_ui5.SaveChangesDialog, null, /* @__PURE__ */ React14.createElement(import_editor_ui5.SaveChangesDialog.Title, { onClose: closeSaveChangesDialog }, (0, import_i18n10.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React14.createElement(import_editor_ui5.SaveChangesDialog.Content, null, /* @__PURE__ */ React14.createElement(import_editor_ui5.SaveChangesDialog.ContentText, null, (0, import_i18n10.__)("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React14.createElement(
2293
+ import_editor_ui5.SaveChangesDialog.Actions,
2372
2294
  {
2373
- sx: {
2374
- display: "flex",
2375
- flexDirection: "column",
2376
- height: "100%"
2295
+ actions: {
2296
+ discard: {
2297
+ label: (0, import_i18n10.__)("Discard", "elementor"),
2298
+ action: () => {
2299
+ closeSaveChangesDialog();
2300
+ void onRequestClose();
2301
+ }
2302
+ },
2303
+ confirm: {
2304
+ label: (0, import_i18n10.__)("Save", "elementor"),
2305
+ action: async () => {
2306
+ const result = await handleSaveClick();
2307
+ closeSaveChangesDialog();
2308
+ if (result?.success) {
2309
+ void onRequestClose();
2310
+ }
2311
+ }
2312
+ }
2377
2313
  }
2378
- },
2379
- bodyInner
2380
- ), saveFooter);
2381
- const core = /* @__PURE__ */ React14.createElement(React14.Fragment, null, panelChrome, dialogs);
2382
- return embedded ? core : /* @__PURE__ */ React14.createElement(import_editor_ui5.ThemeProvider, null, core);
2314
+ }
2315
+ )));
2383
2316
  }
2384
2317
  var usePreventUnload = (isDirty) => {
2385
2318
  (0, import_react13.useEffect)(() => {
@@ -2417,9 +2350,7 @@ var StopSyncConfirmationDialog = ({ open, onClose, onConfirm }) => {
2417
2350
  var import_editor = require("@elementor/editor");
2418
2351
  var import_editor_controls18 = require("@elementor/editor-controls");
2419
2352
  var import_editor_mcp2 = require("@elementor/editor-mcp");
2420
- var import_editor_panels2 = require("@elementor/editor-panels");
2421
2353
  var import_editor_props10 = require("@elementor/editor-props");
2422
- var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
2423
2354
  var import_menus = require("@elementor/menus");
2424
2355
 
2425
2356
  // src/components/global-styles-import-listener.tsx
@@ -2438,75 +2369,12 @@ function GlobalStylesImportListener() {
2438
2369
  return null;
2439
2370
  }
2440
2371
 
2441
- // src/components/open-panel-from-event.tsx
2442
- var import_react15 = require("react");
2443
- var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
2444
- var EVENT_NAME = "elementor/open-variables-manager";
2445
- var DEFAULT_PANEL_ROUTE = "panel/elements/categories";
2446
- function OpenPanelFromEvent() {
2447
- const { open } = usePanelActions();
2448
- const pendingRef = (0, import_react15.useRef)(false);
2449
- const [readyToOpen, setReadyToOpen] = (0, import_react15.useState)(false);
2450
- (0, import_react15.useEffect)(() => {
2451
- if (readyToOpen) {
2452
- setReadyToOpen(false);
2453
- open();
2454
- }
2455
- }, [readyToOpen, open]);
2456
- (0, import_react15.useEffect)(() => {
2457
- return (0, import_editor_v1_adapters3.__privateListenTo)((0, import_editor_v1_adapters3.routeOpenEvent)(DEFAULT_PANEL_ROUTE), () => {
2458
- if (pendingRef.current) {
2459
- pendingRef.current = false;
2460
- setReadyToOpen(true);
2461
- }
2462
- });
2463
- }, []);
2464
- (0, import_react15.useEffect)(() => {
2465
- const handler = () => {
2466
- pendingRef.current = true;
2467
- (0, import_editor_v1_adapters3.__privateOpenRoute)(DEFAULT_PANEL_ROUTE);
2468
- };
2469
- window.addEventListener(EVENT_NAME, handler);
2470
- return () => window.removeEventListener(EVENT_NAME, handler);
2471
- }, []);
2472
- return null;
2473
- }
2474
-
2475
- // src/components/open-panel-from-url.tsx
2476
- var import_react16 = require("react");
2477
- var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
2478
- var ACTIVE_PANEL_PARAM = "active-panel";
2479
- var PANEL_ID = "variables-manager";
2480
- var DEFAULT_PANEL_ROUTE2 = "panel/elements";
2481
- function OpenPanelFromUrl() {
2482
- const { open } = usePanelActions();
2483
- const hasOpened = (0, import_react16.useRef)(false);
2484
- (0, import_react16.useEffect)(() => {
2485
- const urlParams = new URLSearchParams(window.location.search);
2486
- const activePanel = urlParams.get(ACTIVE_PANEL_PARAM);
2487
- if (activePanel !== PANEL_ID) {
2488
- return;
2489
- }
2490
- const cleanup = (0, import_editor_v1_adapters4.__privateListenTo)((0, import_editor_v1_adapters4.routeOpenEvent)(DEFAULT_PANEL_ROUTE2), () => {
2491
- if (hasOpened.current) {
2492
- return;
2493
- }
2494
- hasOpened.current = true;
2495
- requestAnimationFrame(() => {
2496
- open();
2497
- });
2498
- });
2499
- return cleanup;
2500
- }, [open]);
2501
- return null;
2502
- }
2503
-
2504
2372
  // src/controls/variable-control.tsx
2505
2373
  var React33 = __toESM(require("react"));
2506
2374
  var import_editor_controls13 = require("@elementor/editor-controls");
2507
2375
 
2508
2376
  // src/components/ui/variable/assigned-variable.tsx
2509
- var import_react23 = require("react");
2377
+ var import_react21 = require("react");
2510
2378
  var React24 = __toESM(require("react"));
2511
2379
  var import_editor_controls8 = require("@elementor/editor-controls");
2512
2380
  var import_icons12 = require("@elementor/icons");
@@ -2530,25 +2398,25 @@ function createUnlinkHandler(variable, propTypeKey, setValue) {
2530
2398
 
2531
2399
  // src/components/variable-selection-popover.tsx
2532
2400
  var React22 = __toESM(require("react"));
2533
- var import_react22 = require("react");
2534
- var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
2401
+ var import_react20 = require("react");
2402
+ var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
2535
2403
 
2536
2404
  // src/context/variable-selection-popover.context.tsx
2537
2405
  var React15 = __toESM(require("react"));
2538
- var import_react17 = require("react");
2406
+ var import_react15 = require("react");
2539
2407
  var import_ui15 = require("@elementor/ui");
2540
- var PopoverContentRefContext = (0, import_react17.createContext)(null);
2408
+ var PopoverContentRefContext = (0, import_react15.createContext)(null);
2541
2409
  var PopoverContentRefContextProvider = ({ children }) => {
2542
- const [anchorRef, setAnchorRef] = (0, import_react17.useState)(null);
2410
+ const [anchorRef, setAnchorRef] = (0, import_react15.useState)(null);
2543
2411
  return /* @__PURE__ */ React15.createElement(PopoverContentRefContext.Provider, { value: anchorRef }, /* @__PURE__ */ React15.createElement(import_ui15.Box, { ref: setAnchorRef }, children));
2544
2412
  };
2545
2413
  var usePopoverContentRef = () => {
2546
- return (0, import_react17.useContext)(PopoverContentRefContext);
2414
+ return (0, import_react15.useContext)(PopoverContentRefContext);
2547
2415
  };
2548
2416
 
2549
2417
  // src/components/variable-creation.tsx
2550
2418
  var React17 = __toESM(require("react"));
2551
- var import_react18 = require("react");
2419
+ var import_react16 = require("react");
2552
2420
  var import_editor_controls5 = require("@elementor/editor-controls");
2553
2421
  var import_editor_ui6 = require("@elementor/editor-ui");
2554
2422
  var import_icons6 = require("@elementor/icons");
@@ -2598,8 +2466,8 @@ var unwrapValue = (input) => {
2598
2466
  // src/components/ui/form-field.tsx
2599
2467
  var React16 = __toESM(require("react"));
2600
2468
  var import_ui16 = require("@elementor/ui");
2601
- var FormField = ({ id: id2, label, errorMsg, noticeMsg, children }) => {
2602
- return /* @__PURE__ */ React16.createElement(import_ui16.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React16.createElement(import_ui16.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React16.createElement(import_ui16.FormLabel, { htmlFor: id2, size: "tiny" }, label)), /* @__PURE__ */ React16.createElement(import_ui16.Grid, { item: true, xs: 12 }, children, errorMsg && /* @__PURE__ */ React16.createElement(import_ui16.FormHelperText, { error: true }, errorMsg), noticeMsg && /* @__PURE__ */ React16.createElement(import_ui16.FormHelperText, null, noticeMsg)));
2469
+ var FormField = ({ id, label, errorMsg, noticeMsg, children }) => {
2470
+ return /* @__PURE__ */ React16.createElement(import_ui16.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React16.createElement(import_ui16.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React16.createElement(import_ui16.FormLabel, { htmlFor: id, size: "tiny" }, label)), /* @__PURE__ */ React16.createElement(import_ui16.Grid, { item: true, xs: 12 }, children, errorMsg && /* @__PURE__ */ React16.createElement(import_ui16.FormHelperText, { error: true }, errorMsg), noticeMsg && /* @__PURE__ */ React16.createElement(import_ui16.FormHelperText, null, noticeMsg)));
2603
2471
  };
2604
2472
 
2605
2473
  // src/components/variable-creation.tsx
@@ -2609,11 +2477,11 @@ var VariableCreation = ({ onGoBack, onClose }) => {
2609
2477
  const { setVariableValue: setVariable, path } = useVariableBoundProp();
2610
2478
  const { propType } = (0, import_editor_controls5.useBoundProp)();
2611
2479
  const initialValue = useInitialValue();
2612
- const [value, setValue] = (0, import_react18.useState)(initialValue);
2613
- const [label, setLabel] = (0, import_react18.useState)("");
2614
- const [errorMessage, setErrorMessage] = (0, import_react18.useState)("");
2615
- const [valueFieldError, setValueFieldError] = (0, import_react18.useState)("");
2616
- const [propTypeKey, setPropTypeKey] = (0, import_react18.useState)(propTypeUtil.key);
2480
+ const [value, setValue] = (0, import_react16.useState)(initialValue);
2481
+ const [label, setLabel] = (0, import_react16.useState)("");
2482
+ const [errorMessage, setErrorMessage] = (0, import_react16.useState)("");
2483
+ const [valueFieldError, setValueFieldError] = (0, import_react16.useState)("");
2484
+ const [propTypeKey, setPropTypeKey] = (0, import_react16.useState)(propTypeUtil.key);
2617
2485
  const { labelFieldError, setLabelFieldError } = useLabelError();
2618
2486
  const resetFields = () => {
2619
2487
  setValue("");
@@ -2734,7 +2602,7 @@ var VariableCreation = ({ onGoBack, onClose }) => {
2734
2602
 
2735
2603
  // src/components/variable-edit.tsx
2736
2604
  var React19 = __toESM(require("react"));
2737
- var import_react20 = require("react");
2605
+ var import_react18 = require("react");
2738
2606
  var import_editor_controls6 = require("@elementor/editor-controls");
2739
2607
  var import_editor_current_user3 = require("@elementor/editor-current-user");
2740
2608
  var import_editor_ui7 = require("@elementor/editor-ui");
@@ -2744,7 +2612,7 @@ var import_i18n13 = require("@wordpress/i18n");
2744
2612
 
2745
2613
  // src/components/ui/edit-confirmation-dialog.tsx
2746
2614
  var React18 = __toESM(require("react"));
2747
- var import_react19 = require("react");
2615
+ var import_react17 = require("react");
2748
2616
  var import_icons7 = require("@elementor/icons");
2749
2617
  var import_ui18 = require("@elementor/ui");
2750
2618
  var import_i18n12 = require("@wordpress/i18n");
@@ -2754,7 +2622,7 @@ var EditConfirmationDialog = ({
2754
2622
  onConfirm,
2755
2623
  onSuppressMessage
2756
2624
  }) => {
2757
- const [dontShowAgain, setDontShowAgain] = (0, import_react19.useState)(false);
2625
+ const [dontShowAgain, setDontShowAgain] = (0, import_react17.useState)(false);
2758
2626
  const handleSave = () => {
2759
2627
  if (dontShowAgain) {
2760
2628
  onSuppressMessage?.();
@@ -2788,20 +2656,20 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
2788
2656
  const { setVariableValue: notifyBoundPropChange, variableId } = useVariableBoundProp();
2789
2657
  const { propType } = (0, import_editor_controls6.useBoundProp)();
2790
2658
  const [isMessageSuppressed, suppressMessage] = (0, import_editor_current_user3.useSuppressedMessage)(EDIT_CONFIRMATION_DIALOG_ID);
2791
- const [deleteConfirmation, setDeleteConfirmation] = (0, import_react20.useState)(false);
2792
- const [editConfirmation, setEditConfirmation] = (0, import_react20.useState)(false);
2793
- const [errorMessage, setErrorMessage] = (0, import_react20.useState)("");
2794
- const [valueFieldError, setValueFieldError] = (0, import_react20.useState)("");
2659
+ const [deleteConfirmation, setDeleteConfirmation] = (0, import_react18.useState)(false);
2660
+ const [editConfirmation, setEditConfirmation] = (0, import_react18.useState)(false);
2661
+ const [errorMessage, setErrorMessage] = (0, import_react18.useState)("");
2662
+ const [valueFieldError, setValueFieldError] = (0, import_react18.useState)("");
2795
2663
  const { labelFieldError, setLabelFieldError } = useLabelError();
2796
2664
  const variable = useVariable(editId);
2797
- const [propTypeKey, setPropTypeKey] = (0, import_react20.useState)(variable?.type ?? propTypeUtil.key);
2665
+ const [propTypeKey, setPropTypeKey] = (0, import_react18.useState)(variable?.type ?? propTypeUtil.key);
2798
2666
  if (!variable) {
2799
2667
  throw new Error(`Global ${variableType} variable not found`);
2800
2668
  }
2801
2669
  const userPermissions = usePermissions();
2802
- const [value, setValue] = (0, import_react20.useState)(() => variable.value);
2803
- const [label, setLabel] = (0, import_react20.useState)(() => variable.label);
2804
- (0, import_react20.useEffect)(() => {
2670
+ const [value, setValue] = (0, import_react18.useState)(() => variable.value);
2671
+ const [label, setLabel] = (0, import_react18.useState)(() => variable.label);
2672
+ (0, import_react18.useEffect)(() => {
2805
2673
  styleVariablesRepository.update({
2806
2674
  [editId]: {
2807
2675
  ...variable,
@@ -2966,7 +2834,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
2966
2834
  };
2967
2835
 
2968
2836
  // src/components/variables-selection.tsx
2969
- var import_react21 = require("react");
2837
+ var import_react19 = require("react");
2970
2838
  var React21 = __toESM(require("react"));
2971
2839
  var import_editor_controls7 = require("@elementor/editor-controls");
2972
2840
  var import_editor_ui9 = require("@elementor/editor-ui");
@@ -3074,7 +2942,7 @@ var getProUpgradeUrl = (variableType) => `https://go.elementor.com/renew-license
3074
2942
  var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled = false }) => {
3075
2943
  const { icon: VariableIcon, startIcon, variableType, propTypeUtil, emptyState } = useVariableType();
3076
2944
  const { value: variable, setValue: setVariable, path } = useVariableBoundProp();
3077
- const [searchValue, setSearchValue] = (0, import_react21.useState)("");
2945
+ const [searchValue, setSearchValue] = (0, import_react19.useState)("");
3078
2946
  const {
3079
2947
  list: variables,
3080
2948
  hasMatches: hasSearchResults,
@@ -3151,7 +3019,7 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled =
3151
3019
  const handleClearSearch = () => {
3152
3020
  setSearchValue("");
3153
3021
  };
3154
- (0, import_react21.useEffect)(() => {
3022
+ (0, import_react19.useEffect)(() => {
3155
3023
  if (disabled) {
3156
3024
  (0, import_editor_controls7.trackViewPromotion)({
3157
3025
  target_name: "variables_popover",
@@ -3259,17 +3127,12 @@ var VIEW_LIST = "list";
3259
3127
  var VIEW_ADD = "add";
3260
3128
  var VIEW_EDIT = "edit";
3261
3129
  var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
3262
- const [currentView, setCurrentView] = (0, import_react22.useState)(VIEW_LIST);
3263
- const [editId, setEditId] = (0, import_react22.useState)("");
3264
- const { open: openStandaloneVariablesPanel } = usePanelActions();
3265
- const onSettingsAvailable = (0, import_editor_v1_adapters5.isExperimentActive)("e_variables_manager") ? () => {
3266
- if ((0, import_editor_v1_adapters5.isExperimentActive)("e_editor_design_system_panel")) {
3267
- window.dispatchEvent(
3268
- new CustomEvent("elementor/toggle-design-system", { detail: { tab: "variables" } })
3269
- );
3270
- } else {
3271
- openStandaloneVariablesPanel();
3272
- }
3130
+ const [currentView, setCurrentView] = (0, import_react20.useState)(VIEW_LIST);
3131
+ const [editId, setEditId] = (0, import_react20.useState)("");
3132
+ const onSettingsAvailable = (0, import_editor_v1_adapters2.isExperimentActive)("e_variables_manager") ? () => {
3133
+ window.dispatchEvent(
3134
+ new CustomEvent("elementor/toggle-design-system", { detail: { tab: "variables" } })
3135
+ );
3273
3136
  } : void 0;
3274
3137
  return /* @__PURE__ */ React22.createElement(VariableTypeProvider, { propTypeKey }, /* @__PURE__ */ React22.createElement(PopoverContentRefContextProvider, null, RenderView({
3275
3138
  propTypeKey,
@@ -3377,8 +3240,8 @@ var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
3377
3240
  var AssignedVariable = ({ variable, propTypeKey }) => {
3378
3241
  const { startIcon, propTypeUtil } = getVariableType(propTypeKey);
3379
3242
  const { setValue } = (0, import_editor_controls8.useBoundProp)();
3380
- const anchorRef = (0, import_react23.useRef)(null);
3381
- const popupId = (0, import_react23.useId)();
3243
+ const anchorRef = (0, import_react21.useRef)(null);
3244
+ const popupId = (0, import_react21.useId)();
3382
3245
  const popupState = (0, import_ui24.usePopupState)({
3383
3246
  variant: "popover",
3384
3247
  popupId: `elementor-variables-list-${popupId}`
@@ -3418,14 +3281,14 @@ var AssignedVariable = ({ variable, propTypeKey }) => {
3418
3281
 
3419
3282
  // src/components/ui/variable/deleted-variable.tsx
3420
3283
  var React28 = __toESM(require("react"));
3421
- var import_react25 = require("react");
3284
+ var import_react23 = require("react");
3422
3285
  var import_editor_controls10 = require("@elementor/editor-controls");
3423
3286
  var import_ui28 = require("@elementor/ui");
3424
3287
  var import_i18n19 = require("@wordpress/i18n");
3425
3288
 
3426
3289
  // src/components/variable-restore.tsx
3427
3290
  var React25 = __toESM(require("react"));
3428
- var import_react24 = require("react");
3291
+ var import_react22 = require("react");
3429
3292
  var import_editor_controls9 = require("@elementor/editor-controls");
3430
3293
  var import_editor_ui11 = require("@elementor/editor-ui");
3431
3294
  var import_ui25 = require("@elementor/ui");
@@ -3439,11 +3302,11 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
3439
3302
  if (!variable) {
3440
3303
  throw new Error(`Global ${variableType} variable not found`);
3441
3304
  }
3442
- const [errorMessage, setErrorMessage] = (0, import_react24.useState)("");
3443
- const [valueFieldError, setValueFieldError] = (0, import_react24.useState)("");
3444
- const [label, setLabel] = (0, import_react24.useState)(variable.label);
3445
- const [value, setValue] = (0, import_react24.useState)(variable.value);
3446
- const [propTypeKey, setPropTypeKey] = (0, import_react24.useState)(variable?.type ?? propTypeUtil.key);
3305
+ const [errorMessage, setErrorMessage] = (0, import_react22.useState)("");
3306
+ const [valueFieldError, setValueFieldError] = (0, import_react22.useState)("");
3307
+ const [label, setLabel] = (0, import_react22.useState)(variable.label);
3308
+ const [value, setValue] = (0, import_react22.useState)(variable.value);
3309
+ const [propTypeKey, setPropTypeKey] = (0, import_react22.useState)(variable?.type ?? propTypeUtil.key);
3447
3310
  const { labelFieldError, setLabelFieldError } = useLabelError({
3448
3311
  value: variable.label,
3449
3312
  message: ERROR_MESSAGES.DUPLICATED_LABEL
@@ -3600,11 +3463,11 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
3600
3463
  const { propTypeUtil } = getVariableType(propTypeKey);
3601
3464
  const boundProp = (0, import_editor_controls10.useBoundProp)();
3602
3465
  const userPermissions = usePermissions();
3603
- const [showInfotip, setShowInfotip] = (0, import_react25.useState)(false);
3466
+ const [showInfotip, setShowInfotip] = (0, import_react23.useState)(false);
3604
3467
  const toggleInfotip = () => setShowInfotip((prev) => !prev);
3605
3468
  const closeInfotip = () => setShowInfotip(false);
3606
- const deletedChipAnchorRef = (0, import_react25.useRef)(null);
3607
- const popupId = (0, import_react25.useId)();
3469
+ const deletedChipAnchorRef = (0, import_react23.useRef)(null);
3470
+ const popupId = (0, import_react23.useId)();
3608
3471
  const popupState = (0, import_ui28.usePopupState)({
3609
3472
  variant: "popover",
3610
3473
  popupId: `elementor-variables-restore-${popupId}`
@@ -3618,8 +3481,8 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
3618
3481
  if (!variable.key) {
3619
3482
  return;
3620
3483
  }
3621
- restoreVariable(variable.key).then((id2) => {
3622
- resolveBoundPropAndSetValue(propTypeUtil.create(id2), boundProp);
3484
+ restoreVariable(variable.key).then((id) => {
3485
+ resolveBoundPropAndSetValue(propTypeUtil.create(id), boundProp);
3623
3486
  closeInfotip();
3624
3487
  }).catch(() => {
3625
3488
  closeInfotip();
@@ -3691,7 +3554,7 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
3691
3554
 
3692
3555
  // src/components/ui/variable/mismatch-variable.tsx
3693
3556
  var React30 = __toESM(require("react"));
3694
- var import_react26 = require("react");
3557
+ var import_react24 = require("react");
3695
3558
  var import_editor_controls11 = require("@elementor/editor-controls");
3696
3559
  var import_ui30 = require("@elementor/ui");
3697
3560
  var import_i18n21 = require("@wordpress/i18n");
@@ -3729,13 +3592,13 @@ var MismatchVariableAlert = ({ onClose, onClear, triggerSelect }) => {
3729
3592
  // src/components/ui/variable/mismatch-variable.tsx
3730
3593
  var MismatchVariable = ({ variable }) => {
3731
3594
  const { setValue, value } = (0, import_editor_controls11.useBoundProp)();
3732
- const anchorRef = (0, import_react26.useRef)(null);
3733
- const popupId = (0, import_react26.useId)();
3595
+ const anchorRef = (0, import_react24.useRef)(null);
3596
+ const popupId = (0, import_react24.useId)();
3734
3597
  const popupState = (0, import_ui30.usePopupState)({
3735
3598
  variant: "popover",
3736
3599
  popupId: `elementor-variables-list-${popupId}`
3737
3600
  });
3738
- const [infotipVisible, setInfotipVisible] = (0, import_react26.useState)(false);
3601
+ const [infotipVisible, setInfotipVisible] = (0, import_react24.useState)(false);
3739
3602
  const toggleInfotip = () => setInfotipVisible((prev) => !prev);
3740
3603
  const closeInfotip = () => setInfotipVisible(false);
3741
3604
  const triggerSelect = () => {
@@ -3808,7 +3671,7 @@ var MismatchVariable = ({ variable }) => {
3808
3671
 
3809
3672
  // src/components/ui/variable/missing-variable.tsx
3810
3673
  var React32 = __toESM(require("react"));
3811
- var import_react27 = require("react");
3674
+ var import_react25 = require("react");
3812
3675
  var import_editor_controls12 = require("@elementor/editor-controls");
3813
3676
  var import_ui32 = require("@elementor/ui");
3814
3677
  var import_i18n23 = require("@wordpress/i18n");
@@ -3838,7 +3701,7 @@ var MissingVariableAlert = ({ onClose, onClear }) => {
3838
3701
  // src/components/ui/variable/missing-variable.tsx
3839
3702
  var MissingVariable = () => {
3840
3703
  const { setValue } = (0, import_editor_controls12.useBoundProp)();
3841
- const [infotipVisible, setInfotipVisible] = (0, import_react27.useState)(false);
3704
+ const [infotipVisible, setInfotipVisible] = (0, import_react25.useState)(false);
3842
3705
  const toggleInfotip = () => setInfotipVisible((prev) => !prev);
3843
3706
  const closeInfotip = () => setInfotipVisible(false);
3844
3707
  const clearValue = () => setValue(null);
@@ -4008,13 +3871,13 @@ Delete a variable:
4008
3871
  };
4009
3872
 
4010
3873
  // src/mcp/variables-resource.ts
4011
- var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
3874
+ var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
4012
3875
  var GLOBAL_VARIABLES_URI = "elementor://global-variables";
4013
3876
  var buildGlobalVariablesPayload = async () => {
4014
3877
  const merged = {};
4015
- Object.entries(service.variables()).forEach(([id2, variable]) => {
3878
+ Object.entries(service.variables()).forEach(([id, variable]) => {
4016
3879
  if (!variable.deleted) {
4017
- merged[id2] = { ...variable, version: "v4" };
3880
+ merged[id] = { ...variable, version: "v4" };
4018
3881
  }
4019
3882
  });
4020
3883
  return merged;
@@ -4043,7 +3906,7 @@ var initVariablesResource = (variablesMcpEntry, canvasMcpEntry) => {
4043
3906
  }
4044
3907
  );
4045
3908
  window.addEventListener(STORAGE_UPDATED_EVENT, notifyGlobalVariablesUpdated);
4046
- (0, import_editor_v1_adapters6.__privateListenTo)((0, import_editor_v1_adapters6.commandEndEvent)("document/save/update"), notifyGlobalVariablesUpdated);
3909
+ (0, import_editor_v1_adapters3.__privateListenTo)((0, import_editor_v1_adapters3.commandEndEvent)("document/save/update"), notifyGlobalVariablesUpdated);
4047
3910
  });
4048
3911
  };
4049
3912
 
@@ -4138,28 +4001,28 @@ function getServiceActions(svc) {
4138
4001
  }
4139
4002
  return svc.create({ type, label, value });
4140
4003
  },
4141
- update({ id: id2, label, value }) {
4142
- if (!id2 || !label || !value) {
4004
+ update({ id, label, value }) {
4005
+ if (!id || !label || !value) {
4143
4006
  throw new Error("Update requires id, label, and value");
4144
4007
  }
4145
4008
  const labelError = validateLabel(label);
4146
4009
  if (labelError) {
4147
4010
  throw new Error(labelError);
4148
4011
  }
4149
- const existingVariable = svc.variables()[id2];
4012
+ const existingVariable = svc.variables()[id];
4150
4013
  if (existingVariable) {
4151
4014
  const valueError = validateValueForType(existingVariable.type, value);
4152
4015
  if (valueError) {
4153
4016
  throw new Error(valueError);
4154
4017
  }
4155
4018
  }
4156
- return svc.update(id2, { label, value });
4019
+ return svc.update(id, { label, value });
4157
4020
  },
4158
- delete({ id: id2 }) {
4159
- if (!id2) {
4021
+ delete({ id }) {
4022
+ if (!id) {
4160
4023
  throw new Error("delete requires id");
4161
4024
  }
4162
- return svc.delete(id2);
4025
+ return svc.delete(id);
4163
4026
  }
4164
4027
  };
4165
4028
  }
@@ -4180,12 +4043,12 @@ var import_i18n26 = require("@wordpress/i18n");
4180
4043
 
4181
4044
  // src/components/fields/color-field.tsx
4182
4045
  var React35 = __toESM(require("react"));
4183
- var import_react28 = require("react");
4046
+ var import_react26 = require("react");
4184
4047
  var import_ui33 = require("@elementor/ui");
4185
4048
  var ColorField = ({ value, onChange, onValidationChange }) => {
4186
- const [color, setColor] = (0, import_react28.useState)(value);
4187
- const [errorMessage, setErrorMessage] = (0, import_react28.useState)("");
4188
- const defaultRef = (0, import_react28.useRef)(null);
4049
+ const [color, setColor] = (0, import_react26.useState)(value);
4050
+ const [errorMessage, setErrorMessage] = (0, import_react26.useState)("");
4051
+ const defaultRef = (0, import_react26.useRef)(null);
4189
4052
  const anchorRef = usePopoverContentRef() ?? defaultRef.current;
4190
4053
  const handleChange = (newValue) => {
4191
4054
  setColor(newValue);
@@ -4224,20 +4087,20 @@ var ColorField = ({ value, onChange, onValidationChange }) => {
4224
4087
 
4225
4088
  // src/components/fields/font-field.tsx
4226
4089
  var React36 = __toESM(require("react"));
4227
- var import_react29 = require("react");
4090
+ var import_react27 = require("react");
4228
4091
  var import_editor_controls15 = require("@elementor/editor-controls");
4229
4092
  var import_editor_ui12 = require("@elementor/editor-ui");
4230
4093
  var import_icons15 = require("@elementor/icons");
4231
4094
  var import_ui34 = require("@elementor/ui");
4232
4095
  var import_i18n25 = require("@wordpress/i18n");
4233
4096
  var FontField = ({ value, onChange, onValidationChange }) => {
4234
- const [fontFamily, setFontFamily] = (0, import_react29.useState)(value);
4235
- const defaultRef = (0, import_react29.useRef)(null);
4097
+ const [fontFamily, setFontFamily] = (0, import_react27.useState)(value);
4098
+ const defaultRef = (0, import_react27.useRef)(null);
4236
4099
  const anchorRef = usePopoverContentRef() ?? defaultRef.current;
4237
4100
  const fontPopoverState = (0, import_ui34.usePopupState)({ variant: "popover" });
4238
4101
  const fontFamilies = (0, import_editor_controls15.useFontFamilies)();
4239
4102
  const sectionWidth = (0, import_editor_ui12.useSectionWidth)();
4240
- const mapFontSubs = (0, import_react29.useMemo)(() => {
4103
+ const mapFontSubs = (0, import_react27.useMemo)(() => {
4241
4104
  return fontFamilies.map(({ label, fonts }) => ({
4242
4105
  label,
4243
4106
  items: fonts
@@ -4253,11 +4116,11 @@ var FontField = ({ value, onChange, onValidationChange }) => {
4253
4116
  handleChange(newFontFamily);
4254
4117
  fontPopoverState.close();
4255
4118
  };
4256
- const id2 = (0, import_react29.useId)();
4119
+ const id = (0, import_react27.useId)();
4257
4120
  return /* @__PURE__ */ React36.createElement(React36.Fragment, null, /* @__PURE__ */ React36.createElement(
4258
4121
  import_ui34.UnstableTag,
4259
4122
  {
4260
- id: id2,
4123
+ id,
4261
4124
  variant: "outlined",
4262
4125
  label: fontFamily,
4263
4126
  endIcon: /* @__PURE__ */ React36.createElement(import_icons15.ChevronDownIcon, { fontSize: "tiny" }),
@@ -4373,8 +4236,8 @@ function registerVariableTypes() {
4373
4236
 
4374
4237
  // src/renderers/style-variables-renderer.tsx
4375
4238
  var React38 = __toESM(require("react"));
4376
- var import_react30 = require("react");
4377
- var import_editor_v1_adapters7 = require("@elementor/editor-v1-adapters");
4239
+ var import_react28 = require("react");
4240
+ var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
4378
4241
  var import_ui35 = require("@elementor/ui");
4379
4242
  var VARIABLES_WRAPPER = ":root";
4380
4243
  function StyleVariablesRenderer() {
@@ -4389,11 +4252,11 @@ function StyleVariablesRenderer() {
4389
4252
  return /* @__PURE__ */ React38.createElement(import_ui35.Portal, { container }, /* @__PURE__ */ React38.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
4390
4253
  }
4391
4254
  function usePortalContainer() {
4392
- return (0, import_editor_v1_adapters7.__privateUseListenTo)((0, import_editor_v1_adapters7.commandEndEvent)("editor/documents/attach-preview"), () => (0, import_editor_v1_adapters7.getCanvasIframeDocument)()?.head);
4255
+ return (0, import_editor_v1_adapters4.__privateUseListenTo)((0, import_editor_v1_adapters4.commandEndEvent)("editor/documents/attach-preview"), () => (0, import_editor_v1_adapters4.getCanvasIframeDocument)()?.head);
4393
4256
  }
4394
4257
  function useStyleVariables() {
4395
- const [variables, setVariables] = (0, import_react30.useState)({});
4396
- (0, import_react30.useEffect)(() => {
4258
+ const [variables, setVariables] = (0, import_react28.useState)({});
4259
+ (0, import_react28.useEffect)(() => {
4397
4260
  const unsubscribe = styleVariablesRepository.subscribe(setVariables);
4398
4261
  return () => {
4399
4262
  unsubscribe();
@@ -4694,17 +4557,6 @@ function init() {
4694
4557
  id: "variables-import-listener",
4695
4558
  component: GlobalStylesImportListener
4696
4559
  });
4697
- if (!(0, import_editor_v1_adapters8.isExperimentActive)("e_editor_design_system_panel")) {
4698
- (0, import_editor.injectIntoLogic)({
4699
- id: "variables-open-panel-from-url",
4700
- component: OpenPanelFromUrl
4701
- });
4702
- (0, import_editor.injectIntoLogic)({
4703
- id: "variables-open-panel-from-event",
4704
- component: OpenPanelFromEvent
4705
- });
4706
- (0, import_editor_panels2.__registerPanel)(panel);
4707
- }
4708
4560
  }
4709
4561
  function hasVariableAssigned(value) {
4710
4562
  if ((0, import_editor_props10.isTransformable)(value)) {