@elementor/editor-variables 3.33.0-99 → 3.34.2

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.
Files changed (59) hide show
  1. package/dist/index.d.mts +11 -3
  2. package/dist/index.d.ts +11 -3
  3. package/dist/index.js +1874 -801
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +1819 -737
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +16 -14
  8. package/src/api.ts +24 -0
  9. package/src/batch-operations.ts +86 -0
  10. package/src/components/fields/color-field.tsx +1 -0
  11. package/src/components/fields/font-field.tsx +2 -1
  12. package/src/components/fields/label-field.tsx +42 -6
  13. package/src/components/ui/deleted-variable-alert.tsx +14 -10
  14. package/src/components/ui/{no-variables.tsx → empty-state.tsx} +8 -13
  15. package/src/components/ui/menu-item-content.tsx +14 -11
  16. package/src/components/ui/mismatch-variable-alert.tsx +5 -9
  17. package/src/components/ui/missing-variable-alert.tsx +8 -9
  18. package/src/components/ui/no-search-results.tsx +1 -2
  19. package/src/components/ui/tags/assigned-tag.tsx +6 -3
  20. package/src/components/ui/tags/warning-variable-tag.tsx +44 -0
  21. package/src/components/ui/variable/deleted-variable.tsx +13 -6
  22. package/src/components/ui/variable/mismatch-variable.tsx +11 -4
  23. package/src/components/ui/variable/missing-variable.tsx +2 -2
  24. package/src/components/variable-creation.tsx +10 -3
  25. package/src/components/variable-edit.tsx +11 -12
  26. package/src/components/variable-restore.tsx +3 -2
  27. package/src/components/variables-manager/hooks/use-auto-edit.ts +21 -0
  28. package/src/components/variables-manager/hooks/use-error-navigation.ts +49 -0
  29. package/src/components/variables-manager/hooks/use-variables-manager-state.ts +89 -0
  30. package/src/components/variables-manager/variable-editable-cell.tsx +131 -67
  31. package/src/components/variables-manager/variables-manager-create-menu.tsx +116 -0
  32. package/src/components/variables-manager/variables-manager-panel.tsx +290 -59
  33. package/src/components/variables-manager/variables-manager-table.tsx +111 -14
  34. package/src/components/variables-selection.tsx +61 -15
  35. package/src/controls/variable-control.tsx +1 -1
  36. package/src/hooks/use-prop-variables.ts +11 -8
  37. package/src/hooks/use-variable-bound-prop.ts +42 -0
  38. package/src/index.ts +1 -0
  39. package/src/init.ts +19 -6
  40. package/src/mcp/create-variable-tool.ts +70 -0
  41. package/src/mcp/delete-variable-tool.ts +50 -0
  42. package/src/mcp/index.ts +17 -0
  43. package/src/mcp/list-variables-tool.ts +58 -0
  44. package/src/mcp/update-variable-tool.ts +81 -0
  45. package/src/mcp/variables-resource.ts +28 -0
  46. package/src/register-variable-types.tsx +2 -0
  47. package/src/service.ts +60 -1
  48. package/src/storage.ts +8 -0
  49. package/src/types.ts +1 -0
  50. package/src/utils/filter-by-search.ts +5 -0
  51. package/src/utils/tracking.ts +37 -22
  52. package/src/utils/validations.ts +72 -3
  53. package/src/variables-registry/create-variable-type-registry.ts +10 -1
  54. package/src/variables-registry/variable-type-registry.ts +2 -1
  55. package/src/components/ui/tags/deleted-tag.tsx +0 -37
  56. package/src/components/ui/tags/mismatch-tag.tsx +0 -37
  57. package/src/components/ui/tags/missing-tag.tsx +0 -25
  58. /package/src/components/variables-manager/{variable-edit-menu.tsx → ui/variable-edit-menu.tsx} +0 -0
  59. /package/src/components/variables-manager/{variable-table-cell.tsx → ui/variable-table-cell.tsx} +0 -0
package/dist/index.js CHANGED
@@ -31,32 +31,159 @@ 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
 
38
39
  // src/init.ts
39
40
  var import_editor = require("@elementor/editor");
40
- var import_editor_editing_panel11 = require("@elementor/editor-editing-panel");
41
+ var import_editor_editing_panel8 = require("@elementor/editor-editing-panel");
41
42
  var import_editor_panels2 = require("@elementor/editor-panels");
43
+ var import_editor_props6 = require("@elementor/editor-props");
42
44
 
43
45
  // src/components/variables-manager/variables-manager-panel.tsx
44
- var React8 = __toESM(require("react"));
45
- var import_react7 = require("react");
46
+ var React12 = __toESM(require("react"));
47
+ var import_react11 = require("react");
46
48
  var import_editor_panels = require("@elementor/editor-panels");
47
- var import_editor_ui2 = require("@elementor/editor-ui");
49
+ var import_editor_ui3 = require("@elementor/editor-ui");
48
50
  var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
49
- var import_icons3 = require("@elementor/icons");
50
- var import_ui8 = require("@elementor/ui");
51
- var import_i18n5 = require("@wordpress/i18n");
51
+ var import_icons6 = require("@elementor/icons");
52
+ var import_ui12 = require("@elementor/ui");
53
+ var import_i18n9 = require("@wordpress/i18n");
52
54
 
53
- // src/hooks/use-prop-variables.ts
54
- var import_react2 = require("react");
55
- var import_editor_controls = require("@elementor/editor-controls");
55
+ // src/utils/tracking.ts
56
+ var import_mixpanel = require("@elementor/mixpanel");
57
+ var trackVariableEvent = ({ varType, controlPath, action }) => {
58
+ const { dispatchEvent, config } = (0, import_mixpanel.getMixpanel)();
59
+ if (!config?.names?.variables?.[action]) {
60
+ return;
61
+ }
62
+ const name = config.names.variables[action];
63
+ dispatchEvent?.(name, {
64
+ location: config?.locations?.variables || "",
65
+ secondaryLocation: config?.secondaryLocations?.variablesPopover || "",
66
+ trigger: config?.triggers?.click || "",
67
+ var_type: varType,
68
+ control_path: controlPath,
69
+ action_type: name
70
+ });
71
+ };
72
+ var trackVariablesManagerEvent = ({ action, varType, controlPath }) => {
73
+ const { dispatchEvent, config } = (0, import_mixpanel.getMixpanel)();
74
+ if (!config?.names?.variables?.[action]) {
75
+ return;
76
+ }
77
+ const name = config.names.variables[action];
78
+ const eventData = {
79
+ location: config?.locations?.variablesManager || "",
80
+ trigger: config?.triggers?.click || "",
81
+ action_type: name
82
+ };
83
+ if (varType) {
84
+ eventData.var_type = varType;
85
+ }
86
+ if (controlPath) {
87
+ eventData.style_control_path = controlPath;
88
+ }
89
+ dispatchEvent?.(name, eventData);
90
+ };
56
91
 
57
- // src/context/variable-type-context.tsx
58
- var React2 = __toESM(require("react"));
59
- var import_react = require("react");
92
+ // src/utils/validations.ts
93
+ var import_icons = require("@elementor/icons");
94
+ var import_i18n = require("@wordpress/i18n");
95
+ var ERROR_MESSAGES = {
96
+ MISSING_VARIABLE_NAME: (0, import_i18n.__)("Give your variable a name.", "elementor"),
97
+ MISSING_VARIABLE_VALUE: (0, import_i18n.__)("Add a value to complete your variable.", "elementor"),
98
+ INVALID_CHARACTERS: (0, import_i18n.__)("Use letters, numbers, dashes (-), or underscores (_) for the name.", "elementor"),
99
+ NO_NON_SPECIAL_CHARACTER: (0, import_i18n.__)("Names have to include at least one non-special character.", "elementor"),
100
+ VARIABLE_LABEL_MAX_LENGTH: (0, import_i18n.__)("Keep names up to 50 characters.", "elementor"),
101
+ DUPLICATED_LABEL: (0, import_i18n.__)("This variable name already exists. Please choose a unique name.", "elementor"),
102
+ UNEXPECTED_ERROR: (0, import_i18n.__)("There was a glitch. Try saving your variable again.", "elementor"),
103
+ BATCH: {
104
+ DUPLICATED_LABELS: (count, name) => (
105
+ // eslint-disable-next-line @wordpress/i18n-translator-comments
106
+ (0, import_i18n.sprintf)((0, import_i18n.__)("We found %1$d duplicated %2$s.", "elementor"), count, name)
107
+ ),
108
+ UNEXPECTED_ERROR: (0, import_i18n.__)("There was a glitch.", "elementor"),
109
+ DUPLICATED_LABEL_ACTION: (0, import_i18n.__)("Take me there", "elementor"),
110
+ DUPLICATED_LABEL_ACTION_MESSAGE: (0, import_i18n.__)("Please rename the variables.", "elementor"),
111
+ UNEXPECTED_ERROR_ACTION_MESSAGE: (0, import_i18n.__)("Try saving your variables again.", "elementor")
112
+ }
113
+ };
114
+ var VARIABLE_LABEL_MAX_LENGTH = 50;
115
+ var mapServerError = (error) => {
116
+ if (error?.response?.data?.code === "duplicated_label") {
117
+ return {
118
+ field: "label",
119
+ message: ERROR_MESSAGES.DUPLICATED_LABEL
120
+ };
121
+ }
122
+ if (error?.response?.data?.code === "batch_duplicated_label") {
123
+ const errorData = error?.response?.data?.data ?? {};
124
+ const count = Object.keys(errorData).length;
125
+ const name = count === 1 ? "name" : "names";
126
+ const duplicatedIds = Object.keys(errorData);
127
+ return {
128
+ field: "label",
129
+ message: ERROR_MESSAGES.BATCH.DUPLICATED_LABELS(count, name),
130
+ severity: "error",
131
+ IconComponent: import_icons.AlertTriangleFilledIcon,
132
+ action: {
133
+ label: ERROR_MESSAGES.BATCH.DUPLICATED_LABEL_ACTION,
134
+ message: ERROR_MESSAGES.BATCH.DUPLICATED_LABEL_ACTION_MESSAGE,
135
+ data: {
136
+ duplicatedIds
137
+ }
138
+ }
139
+ };
140
+ }
141
+ if (error?.response?.data?.code === "batch_operation_failed") {
142
+ return {
143
+ field: "label",
144
+ message: ERROR_MESSAGES.BATCH.UNEXPECTED_ERROR,
145
+ severity: "secondary",
146
+ IconComponent: import_icons.InfoCircleFilledIcon,
147
+ action: {
148
+ message: ERROR_MESSAGES.BATCH.UNEXPECTED_ERROR_ACTION_MESSAGE
149
+ }
150
+ };
151
+ }
152
+ return void 0;
153
+ };
154
+ var validateLabel = (name, variables) => {
155
+ if (!name.trim()) {
156
+ return ERROR_MESSAGES.MISSING_VARIABLE_NAME;
157
+ }
158
+ const allowedChars = /^[a-zA-Z0-9_-]+$/;
159
+ if (!allowedChars.test(name)) {
160
+ return ERROR_MESSAGES.INVALID_CHARACTERS;
161
+ }
162
+ const hasAlphanumeric = /[a-zA-Z0-9]/;
163
+ if (!hasAlphanumeric.test(name)) {
164
+ return ERROR_MESSAGES.NO_NON_SPECIAL_CHARACTER;
165
+ }
166
+ if (VARIABLE_LABEL_MAX_LENGTH < name.length) {
167
+ return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
168
+ }
169
+ if (Object.values(variables ?? {}).some((variable) => variable.label === name)) {
170
+ return ERROR_MESSAGES.DUPLICATED_LABEL;
171
+ }
172
+ return "";
173
+ };
174
+ var labelHint = (name) => {
175
+ const hintThreshold = VARIABLE_LABEL_MAX_LENGTH * 0.8 - 1;
176
+ if (hintThreshold < name.length) {
177
+ return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
178
+ }
179
+ return "";
180
+ };
181
+ var validateValue = (value) => {
182
+ if (!value.trim()) {
183
+ return ERROR_MESSAGES.MISSING_VARIABLE_VALUE;
184
+ }
185
+ return "";
186
+ };
60
187
 
61
188
  // src/variables-registry/create-variable-type-registry.ts
62
189
  var import_editor_canvas3 = require("@elementor/editor-canvas");
@@ -66,7 +193,7 @@ var import_editor_editing_panel = require("@elementor/editor-editing-panel");
66
193
  var React = __toESM(require("react"));
67
194
  var import_editor_canvas = require("@elementor/editor-canvas");
68
195
  var import_ui2 = require("@elementor/ui");
69
- var import_i18n2 = require("@wordpress/i18n");
196
+ var import_i18n3 = require("@wordpress/i18n");
70
197
 
71
198
  // src/components/ui/color-indicator.tsx
72
199
  var import_ui = require("@elementor/ui");
@@ -81,7 +208,7 @@ var import_schema = require("@elementor/schema");
81
208
  var colorVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-color-variable", import_schema.z.string());
82
209
 
83
210
  // src/service.ts
84
- var import_i18n = require("@wordpress/i18n");
211
+ var import_i18n2 = require("@wordpress/i18n");
85
212
 
86
213
  // src/api.ts
87
214
  var import_http_client = require("@elementor/http-client");
@@ -116,9 +243,72 @@ var apiClient = {
116
243
  payload.value = value;
117
244
  }
118
245
  return (0, import_http_client.httpService)().post(BASE_PATH + "/restore", payload);
246
+ },
247
+ batch: (payload) => {
248
+ return (0, import_http_client.httpService)().post(BASE_PATH + "/batch", payload);
119
249
  }
120
250
  };
121
251
 
252
+ // src/batch-operations.ts
253
+ var generateTempId = () => {
254
+ const timestamp = Date.now().toString(36);
255
+ const random = Math.random().toString(36).substring(2, 8);
256
+ return `tmp-${timestamp}-${random}`;
257
+ };
258
+ var isTempId = (id2) => {
259
+ return id2.startsWith("tmp-");
260
+ };
261
+ var buildOperationsArray = (originalVariables, currentVariables) => {
262
+ const operations = [];
263
+ Object.entries(currentVariables).forEach(([id2, variable]) => {
264
+ if (isTempId(id2)) {
265
+ operations.push({
266
+ type: "create",
267
+ variable: {
268
+ ...variable,
269
+ id: id2
270
+ }
271
+ });
272
+ } else if (originalVariables[id2]) {
273
+ const original = originalVariables[id2];
274
+ if (original.deleted && !variable.deleted) {
275
+ operations.push({
276
+ type: "restore",
277
+ id: id2,
278
+ ...original.label !== variable.label && { label: variable.label },
279
+ ...original.value !== variable.value && { value: variable.value }
280
+ });
281
+ } else if (!variable.deleted && (original.label !== variable.label || original.value !== variable.value || original.order !== variable.order)) {
282
+ operations.push({
283
+ type: "update",
284
+ id: id2,
285
+ variable: {
286
+ ...original.label !== variable.label && { label: variable.label },
287
+ ...original.value !== variable.value && { value: variable.value },
288
+ ...original.order !== variable.order && { order: variable.order }
289
+ }
290
+ });
291
+ }
292
+ }
293
+ });
294
+ Object.entries(originalVariables).forEach(([id2, variable]) => {
295
+ if (isTempId(id2) || variable.deleted) {
296
+ return;
297
+ }
298
+ const currentVariable = currentVariables[id2];
299
+ if (!currentVariable || currentVariable.deleted) {
300
+ operations.push({
301
+ type: "delete",
302
+ id: id2
303
+ });
304
+ }
305
+ });
306
+ return operations.filter((op) => {
307
+ const id2 = op.id || op.variable?.id;
308
+ return id2 && !(isTempId(id2) && currentVariables[id2]?.deleted);
309
+ });
310
+ };
311
+
122
312
  // src/storage.ts
123
313
  var STORAGE_KEY = "elementor-global-variables";
124
314
  var STORAGE_WATERMARK_KEY = "elementor-global-variables-watermark";
@@ -126,6 +316,9 @@ var OP_RW = "RW";
126
316
  var OP_RO = "RO";
127
317
  var Storage = class {
128
318
  state;
319
+ notifyChange() {
320
+ window.dispatchEvent(new Event("variables:updated"));
321
+ }
129
322
  constructor() {
130
323
  this.state = {
131
324
  watermark: -1,
@@ -145,16 +338,19 @@ var Storage = class {
145
338
  this.state.watermark = watermark;
146
339
  localStorage.setItem(STORAGE_WATERMARK_KEY, this.state.watermark.toString());
147
340
  localStorage.setItem(STORAGE_KEY, JSON.stringify(this.state.variables));
341
+ this.notifyChange();
148
342
  }
149
343
  add(id2, variable) {
150
344
  this.load();
151
345
  this.state.variables[id2] = variable;
152
346
  localStorage.setItem(STORAGE_KEY, JSON.stringify(this.state.variables));
347
+ this.notifyChange();
153
348
  }
154
349
  update(id2, variable) {
155
350
  this.load();
156
351
  this.state.variables[id2] = variable;
157
352
  localStorage.setItem(STORAGE_KEY, JSON.stringify(this.state.variables));
353
+ this.notifyChange();
158
354
  }
159
355
  watermark(watermark) {
160
356
  this.state.watermark = watermark;
@@ -259,8 +455,11 @@ var service = {
259
455
  variables: () => {
260
456
  return storage.load();
261
457
  },
458
+ getWatermark: () => {
459
+ return storage.state.watermark;
460
+ },
262
461
  init: () => {
263
- service.load();
462
+ return service.load();
264
463
  },
265
464
  load: () => {
266
465
  return apiClient.list().then((response) => {
@@ -280,7 +479,7 @@ var service = {
280
479
  return apiClient.create(type, label, value).then((response) => {
281
480
  const { success, data: payload } = response.data;
282
481
  if (!success) {
283
- const errorMessage = payload?.message || (0, import_i18n.__)("Unexpected response from server", "elementor");
482
+ const errorMessage = payload?.message || (0, import_i18n2.__)("Unexpected response from server", "elementor");
284
483
  throw new Error(errorMessage);
285
484
  }
286
485
  return payload;
@@ -302,7 +501,7 @@ var service = {
302
501
  return apiClient.update(id2, label, value).then((response) => {
303
502
  const { success, data: payload } = response.data;
304
503
  if (!success) {
305
- const errorMessage = payload?.message || (0, import_i18n.__)("Unexpected response from server", "elementor");
504
+ const errorMessage = payload?.message || (0, import_i18n2.__)("Unexpected response from server", "elementor");
306
505
  throw new Error(errorMessage);
307
506
  }
308
507
  return payload;
@@ -361,6 +560,47 @@ var service = {
361
560
  variable: restoredVariable
362
561
  };
363
562
  });
563
+ },
564
+ batchSave: (originalVariables, currentVariables) => {
565
+ const operations = buildOperationsArray(originalVariables, currentVariables);
566
+ const batchPayload = { operations, watermark: storage.state.watermark };
567
+ if (operations.length === 0) {
568
+ return Promise.resolve({
569
+ success: true,
570
+ watermark: storage.state.watermark,
571
+ operations: 0
572
+ });
573
+ }
574
+ return apiClient.batch(batchPayload).then((response) => {
575
+ const { success, data: payload } = response.data;
576
+ if (!success) {
577
+ throw new Error("Unexpected response from server");
578
+ }
579
+ return payload;
580
+ }).then((data) => {
581
+ const { results, watermark } = data;
582
+ handleWatermark(OP_RW, watermark);
583
+ if (results) {
584
+ results.forEach((result) => {
585
+ if (result.variable) {
586
+ const { id: variableId, ...variableData } = result.variable;
587
+ if (result.type === "create") {
588
+ storage.add(variableId, variableData);
589
+ } else {
590
+ storage.update(variableId, variableData);
591
+ }
592
+ styleVariablesRepository.update({
593
+ [variableId]: variableData
594
+ });
595
+ }
596
+ });
597
+ }
598
+ return {
599
+ success: true,
600
+ watermark,
601
+ operations: operations.length
602
+ };
603
+ });
364
604
  }
365
605
  };
366
606
  var handleWatermark = (operation, newWatermark) => {
@@ -394,7 +634,7 @@ var inheritanceTransformer = (0, import_editor_canvas.createTransformer)((id2) =
394
634
  const variables = service.variables();
395
635
  const variable = variables[id2];
396
636
  if (!variable) {
397
- return /* @__PURE__ */ React.createElement("span", null, (0, import_i18n2.__)("Missing variable", "elementor"));
637
+ return /* @__PURE__ */ React.createElement("span", null, (0, import_i18n3.__)("Missing variable", "elementor"));
398
638
  }
399
639
  const showColorIndicator = variable.type === colorVariablePropTypeUtil.key;
400
640
  const css = resolveCssVariable(id2, variable);
@@ -420,6 +660,7 @@ function createVariableTypeRegistry() {
420
660
  valueField,
421
661
  propTypeUtil,
422
662
  variableType,
663
+ defaultValue,
423
664
  selectionFilter,
424
665
  valueTransformer,
425
666
  fallbackPropTypeUtil,
@@ -444,6 +685,7 @@ function createVariableTypeRegistry() {
444
685
  valueField,
445
686
  propTypeUtil,
446
687
  variableType,
688
+ defaultValue,
447
689
  selectionFilter,
448
690
  valueTransformer,
449
691
  fallbackPropTypeUtil,
@@ -461,32 +703,188 @@ function createVariableTypeRegistry() {
461
703
  const getVariableType2 = (key) => {
462
704
  return variableTypes[key];
463
705
  };
706
+ const getVariableTypes2 = () => {
707
+ return variableTypes;
708
+ };
464
709
  const hasVariableType2 = (key) => {
465
710
  return key in variableTypes;
466
711
  };
467
712
  return {
468
713
  registerVariableType: registerVariableType2,
469
714
  getVariableType: getVariableType2,
715
+ getVariableTypes: getVariableTypes2,
470
716
  hasVariableType: hasVariableType2
471
717
  };
472
718
  }
473
719
 
474
720
  // src/variables-registry/variable-type-registry.ts
475
- var { registerVariableType, getVariableType, hasVariableType } = createVariableTypeRegistry();
721
+ var { registerVariableType, getVariableType, getVariableTypes, hasVariableType } = createVariableTypeRegistry();
722
+
723
+ // src/components/ui/delete-confirmation-dialog.tsx
724
+ var React2 = __toESM(require("react"));
725
+ var import_icons2 = require("@elementor/icons");
726
+ var import_ui3 = require("@elementor/ui");
727
+ var import_i18n4 = require("@wordpress/i18n");
728
+ var TITLE_ID = "delete-variable-dialog";
729
+ var DeleteConfirmationDialog = ({
730
+ open,
731
+ label,
732
+ closeDialog,
733
+ onConfirm
734
+ }) => {
735
+ return /* @__PURE__ */ React2.createElement(import_ui3.Dialog, { open, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React2.createElement(import_ui3.DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React2.createElement(import_icons2.AlertOctagonFilledIcon, { color: "error" }), (0, import_i18n4.__)("Delete this variable?", "elementor")), /* @__PURE__ */ React2.createElement(import_ui3.DialogContent, null, /* @__PURE__ */ React2.createElement(import_ui3.DialogContentText, { variant: "body2", color: "textPrimary" }, (0, import_i18n4.__)("All elements using", "elementor"), "\xA0", /* @__PURE__ */ React2.createElement(import_ui3.Typography, { variant: "subtitle2", component: "span", sx: { lineBreak: "anywhere" } }, label), "\xA0", (0, import_i18n4.__)("will keep their current values, but the variable itself will be removed.", "elementor"))), /* @__PURE__ */ React2.createElement(import_ui3.DialogActions, null, /* @__PURE__ */ React2.createElement(import_ui3.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n4.__)("Not now", "elementor")), /* @__PURE__ */ React2.createElement(import_ui3.Button, { variant: "contained", color: "error", onClick: onConfirm }, (0, import_i18n4.__)("Delete", "elementor"))));
736
+ };
737
+
738
+ // src/components/ui/empty-state.tsx
739
+ var React3 = __toESM(require("react"));
740
+ var import_ui4 = require("@elementor/ui");
741
+ var import_i18n5 = require("@wordpress/i18n");
742
+
743
+ // src/hooks/use-permissions.ts
744
+ var import_editor_current_user = require("@elementor/editor-current-user");
745
+ var usePermissions = () => {
746
+ const { canUser } = (0, import_editor_current_user.useCurrentUserCapabilities)();
747
+ return {
748
+ canAssign: () => canUser("edit_posts"),
749
+ canUnlink: () => canUser("edit_posts"),
750
+ canAdd: () => canUser("manage_options"),
751
+ canDelete: () => canUser("manage_options"),
752
+ canEdit: () => canUser("manage_options"),
753
+ canRestore: () => canUser("manage_options"),
754
+ canManageSettings: () => canUser("manage_options")
755
+ };
756
+ };
757
+
758
+ // src/components/ui/empty-state.tsx
759
+ var EmptyState = ({ icon, title, message, onAdd }) => {
760
+ const canAdd = usePermissions().canAdd();
761
+ return /* @__PURE__ */ React3.createElement(
762
+ import_ui4.Stack,
763
+ {
764
+ gap: 1,
765
+ alignItems: "center",
766
+ justifyContent: "flex-start",
767
+ height: "100%",
768
+ color: "text.secondary",
769
+ sx: { p: 2.5, pt: 8, pb: 5.5 }
770
+ },
771
+ icon,
772
+ canAdd ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(Content, { title, message }), onAdd && /* @__PURE__ */ React3.createElement(import_ui4.Button, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, (0, import_i18n5.__)("Create a variable", "elementor"))) : /* @__PURE__ */ React3.createElement(
773
+ Content,
774
+ {
775
+ title: (0, import_i18n5.__)("There are no variables", "elementor"),
776
+ message: (0, import_i18n5.__)("With your current role, you can only connect and detach variables.", "elementor")
777
+ }
778
+ )
779
+ );
780
+ };
781
+ function Content({ title, message }) {
782
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(import_ui4.Typography, { align: "center", variant: "subtitle2" }, title), /* @__PURE__ */ React3.createElement(import_ui4.Typography, { align: "center", variant: "caption", maxWidth: "180px" }, message));
783
+ }
784
+
785
+ // src/components/ui/no-search-results.tsx
786
+ var React4 = __toESM(require("react"));
787
+ var import_ui5 = require("@elementor/ui");
788
+ var import_i18n6 = require("@wordpress/i18n");
789
+ var NoSearchResults = ({ searchValue, onClear, icon }) => {
790
+ return /* @__PURE__ */ React4.createElement(
791
+ import_ui5.Stack,
792
+ {
793
+ gap: 1,
794
+ alignItems: "center",
795
+ justifyContent: "center",
796
+ p: 2.5,
797
+ color: "text.secondary",
798
+ sx: { pb: 3.5, pt: 8 }
799
+ },
800
+ icon,
801
+ /* @__PURE__ */ React4.createElement(import_ui5.Typography, { align: "center", variant: "subtitle2" }, (0, import_i18n6.__)("Sorry, nothing matched", "elementor"), /* @__PURE__ */ React4.createElement("br", null), "\u201C", searchValue, "\u201D."),
802
+ /* @__PURE__ */ React4.createElement(import_ui5.Typography, { align: "center", variant: "caption", sx: { display: "flex", flexDirection: "column" } }, (0, import_i18n6.__)("Try something else.", "elementor"), /* @__PURE__ */ React4.createElement(import_ui5.Link, { color: "text.secondary", variant: "caption", component: "button", onClick: onClear }, (0, import_i18n6.__)("Clear & try again", "elementor")))
803
+ );
804
+ };
805
+
806
+ // src/components/variables-manager/hooks/use-auto-edit.ts
807
+ var import_react = require("react");
808
+ var useAutoEdit = () => {
809
+ const [autoEditVariableId, setAutoEditVariableId] = (0, import_react.useState)(void 0);
810
+ const startAutoEdit = (0, import_react.useCallback)((variableId) => {
811
+ setAutoEditVariableId(variableId);
812
+ }, []);
813
+ const handleAutoEditComplete = (0, import_react.useCallback)(() => {
814
+ setTimeout(() => {
815
+ setAutoEditVariableId(void 0);
816
+ }, 100);
817
+ }, []);
818
+ return {
819
+ autoEditVariableId,
820
+ startAutoEdit,
821
+ handleAutoEditComplete
822
+ };
823
+ };
824
+
825
+ // src/components/variables-manager/hooks/use-error-navigation.ts
826
+ var import_react2 = require("react");
827
+ var useErrorNavigation = () => {
828
+ const currentIndexRef = (0, import_react2.useRef)(0);
829
+ const createNavigationCallback = (0, import_react2.useCallback)(
830
+ (ids, onNavigate, onComplete) => {
831
+ return () => {
832
+ if (!ids?.length) {
833
+ return;
834
+ }
835
+ const currentIndex = currentIndexRef.current;
836
+ const currentId = ids[currentIndex];
837
+ if (currentId) {
838
+ onNavigate(currentId);
839
+ const nextIndex = currentIndex + 1;
840
+ if (nextIndex >= ids.length) {
841
+ onComplete();
842
+ currentIndexRef.current = 0;
843
+ } else {
844
+ currentIndexRef.current = nextIndex;
845
+ }
846
+ }
847
+ };
848
+ },
849
+ []
850
+ );
851
+ const resetNavigation = (0, import_react2.useCallback)(() => {
852
+ currentIndexRef.current = 0;
853
+ }, []);
854
+ return {
855
+ createNavigationCallback,
856
+ resetNavigation
857
+ };
858
+ };
859
+
860
+ // src/components/variables-manager/hooks/use-variables-manager-state.ts
861
+ var import_react5 = require("react");
862
+
863
+ // src/hooks/use-prop-variables.ts
864
+ var import_react4 = require("react");
865
+ var import_editor_controls = require("@elementor/editor-controls");
476
866
 
477
867
  // src/context/variable-type-context.tsx
478
- var VariableTypeContext = (0, import_react.createContext)(null);
868
+ var React5 = __toESM(require("react"));
869
+ var import_react3 = require("react");
870
+ var VariableTypeContext = (0, import_react3.createContext)(null);
479
871
  function VariableTypeProvider({ children, propTypeKey }) {
480
- return /* @__PURE__ */ React2.createElement(VariableTypeContext.Provider, { value: propTypeKey }, children);
872
+ return /* @__PURE__ */ React5.createElement(VariableTypeContext.Provider, { value: propTypeKey }, children);
481
873
  }
482
874
  function useVariableType() {
483
- const context = (0, import_react.useContext)(VariableTypeContext);
875
+ const context = (0, import_react3.useContext)(VariableTypeContext);
484
876
  if (context === null) {
485
877
  throw new Error("useVariableType must be used within a VariableTypeProvider");
486
878
  }
487
879
  return getVariableType(context);
488
880
  }
489
881
 
882
+ // src/utils/filter-by-search.ts
883
+ function filterBySearch(variables, searchValue) {
884
+ const lowerSearchValue = searchValue.toLowerCase();
885
+ return variables.filter((variable) => variable.label.toLowerCase().includes(lowerSearchValue));
886
+ }
887
+
490
888
  // src/hooks/use-prop-variables.ts
491
889
  var getVariables = (includeDeleted = true) => {
492
890
  const variables = service.variables();
@@ -508,11 +906,17 @@ var useVariable = (key) => {
508
906
  var useFilteredVariables = (searchValue, propTypeKey) => {
509
907
  const baseVariables = usePropVariables(propTypeKey);
510
908
  const typeFilteredVariables = useVariableSelectionFilter(baseVariables);
511
- const searchFilteredVariables = filterVariablesBySearchValue(typeFilteredVariables, searchValue);
909
+ const searchFilteredVariables = filterBySearch(typeFilteredVariables, searchValue);
910
+ const sortedVariables = searchFilteredVariables.sort((a, b) => {
911
+ const orderA = a.order ?? Number.MAX_SAFE_INTEGER;
912
+ const orderB = b.order ?? Number.MAX_SAFE_INTEGER;
913
+ return orderA - orderB;
914
+ });
512
915
  return {
513
- list: searchFilteredVariables,
916
+ list: sortedVariables,
514
917
  hasMatches: searchFilteredVariables.length > 0,
515
- isSourceNotEmpty: typeFilteredVariables.length > 0
918
+ isSourceNotEmpty: typeFilteredVariables.length > 0,
919
+ hasNoCompatibleVariables: baseVariables.length > 0 && typeFilteredVariables.length === 0
516
920
  };
517
921
  };
518
922
  var useVariableSelectionFilter = (variables) => {
@@ -520,19 +924,16 @@ var useVariableSelectionFilter = (variables) => {
520
924
  const { propType } = (0, import_editor_controls.useBoundProp)();
521
925
  return selectionFilter ? selectionFilter(variables, propType) : variables;
522
926
  };
523
- var filterVariablesBySearchValue = (variables, searchValue) => {
524
- const lowerSearchValue = searchValue.toLowerCase();
525
- return variables.filter(({ label }) => label.toLowerCase().includes(lowerSearchValue));
526
- };
527
927
  var usePropVariables = (propKey) => {
528
- return (0, import_react2.useMemo)(() => normalizeVariables(propKey), [propKey]);
928
+ return (0, import_react4.useMemo)(() => normalizeVariables(propKey), [propKey]);
529
929
  };
530
930
  var normalizeVariables = (propKey) => {
531
931
  const variables = getVariables(false);
532
- return Object.entries(variables).filter(([, variable]) => variable.type === propKey).map(([key, { label, value }]) => ({
932
+ return Object.entries(variables).filter(([, variable]) => variable.type === propKey).map(([key, { label, value, order }]) => ({
533
933
  key,
534
934
  label,
535
- value
935
+ value,
936
+ order
536
937
  }));
537
938
  };
538
939
  var extractId = ({ id: id2 }) => id2;
@@ -549,77 +950,185 @@ var restoreVariable = (restoreId, label, value) => {
549
950
  return service.restore(restoreId, label, value).then(extractId);
550
951
  };
551
952
 
552
- // src/components/variables-manager/variables-manager-table.tsx
553
- var React7 = __toESM(require("react"));
953
+ // src/components/variables-manager/hooks/use-variables-manager-state.ts
954
+ var useVariablesManagerState = () => {
955
+ const [variables, setVariables] = (0, import_react5.useState)(() => getVariables(false));
956
+ const [deletedVariables, setDeletedVariables] = (0, import_react5.useState)([]);
957
+ const [isSaveDisabled, setIsSaveDisabled] = (0, import_react5.useState)(false);
958
+ const [isDirty, setIsDirty] = (0, import_react5.useState)(false);
959
+ const [isSaving, setIsSaving] = (0, import_react5.useState)(false);
960
+ const [searchValue, setSearchValue] = (0, import_react5.useState)("");
961
+ const handleOnChange = (0, import_react5.useCallback)(
962
+ (newVariables) => {
963
+ setVariables({ ...variables, ...newVariables });
964
+ setIsDirty(true);
965
+ },
966
+ [variables]
967
+ );
968
+ const createVariable2 = (0, import_react5.useCallback)((type, defaultName, defaultValue) => {
969
+ const newId = generateTempId();
970
+ const newVariable = {
971
+ id: newId,
972
+ label: defaultName.trim(),
973
+ value: defaultValue.trim(),
974
+ type
975
+ };
976
+ setVariables((prev) => ({ ...prev, [newId]: newVariable }));
977
+ setIsDirty(true);
978
+ return newId;
979
+ }, []);
980
+ const handleDeleteVariable = (0, import_react5.useCallback)((itemId) => {
981
+ setDeletedVariables((prev) => [...prev, itemId]);
982
+ setVariables((prev) => ({ ...prev, [itemId]: { ...prev[itemId], deleted: true } }));
983
+ setIsDirty(true);
984
+ }, []);
985
+ const handleSearch = (searchTerm) => {
986
+ setSearchValue(searchTerm);
987
+ };
988
+ const handleSave = (0, import_react5.useCallback)(async () => {
989
+ const originalVariables = getVariables(false);
990
+ setIsSaving(true);
991
+ const result = await service.batchSave(originalVariables, variables);
992
+ if (result.success) {
993
+ await service.load();
994
+ const updatedVariables = service.variables();
995
+ setVariables(updatedVariables);
996
+ setDeletedVariables([]);
997
+ setIsDirty(false);
998
+ }
999
+ return { success: result.success };
1000
+ }, [variables]);
1001
+ const filteredVariables = () => {
1002
+ const list = Object.entries(variables).map(([id2, value]) => ({ ...value, id: id2 }));
1003
+ const filtered = filterBySearch(list, searchValue);
1004
+ return Object.fromEntries(filtered.map(({ id: id2, ...rest }) => [id2, rest]));
1005
+ };
1006
+ return {
1007
+ variables: filteredVariables(),
1008
+ deletedVariables,
1009
+ isDirty,
1010
+ isSaveDisabled,
1011
+ handleOnChange,
1012
+ createVariable: createVariable2,
1013
+ handleDeleteVariable,
1014
+ handleSave,
1015
+ isSaving,
1016
+ handleSearch,
1017
+ searchValue,
1018
+ setIsSaving,
1019
+ setIsSaveDisabled
1020
+ };
1021
+ };
1022
+
1023
+ // src/components/variables-manager/variables-manager-create-menu.tsx
1024
+ var React6 = __toESM(require("react"));
554
1025
  var import_react6 = require("react");
555
- var import_editor_ui = require("@elementor/editor-ui");
556
- var import_icons2 = require("@elementor/icons");
557
- var import_ui7 = require("@elementor/ui");
558
- var import_i18n4 = require("@wordpress/i18n");
559
-
560
- // src/components/fields/label-field.tsx
561
- var React3 = __toESM(require("react"));
562
- var import_react3 = require("react");
563
- var import_ui3 = require("@elementor/ui");
564
-
565
- // src/utils/validations.ts
566
- var import_i18n3 = require("@wordpress/i18n");
567
- var ERROR_MESSAGES = {
568
- MISSING_VARIABLE_NAME: (0, import_i18n3.__)("Give your variable a name.", "elementor"),
569
- MISSING_VARIABLE_VALUE: (0, import_i18n3.__)("Add a value to complete your variable.", "elementor"),
570
- INVALID_CHARACTERS: (0, import_i18n3.__)("Use letters, numbers, dashes (-), or underscores (_) for the name.", "elementor"),
571
- NO_NON_SPECIAL_CHARACTER: (0, import_i18n3.__)("Names have to include at least one non-special character.", "elementor"),
572
- VARIABLE_LABEL_MAX_LENGTH: (0, import_i18n3.__)("Keep names up to 50 characters.", "elementor"),
573
- DUPLICATED_LABEL: (0, import_i18n3.__)("This variable name already exists. Please choose a unique name.", "elementor"),
574
- UNEXPECTED_ERROR: (0, import_i18n3.__)("There was a glitch. Try saving your variable again.", "elementor")
575
- };
576
- var VARIABLE_LABEL_MAX_LENGTH = 50;
577
- var mapServerError = (error) => {
578
- if (error?.response?.data?.code === "duplicated_label") {
1026
+ var import_icons3 = require("@elementor/icons");
1027
+ var import_ui6 = require("@elementor/ui");
1028
+ var import_i18n7 = require("@wordpress/i18n");
1029
+ var SIZE = "tiny";
1030
+ var VariableManagerCreateMenu = ({
1031
+ variables,
1032
+ onCreate,
1033
+ disabled,
1034
+ menuState
1035
+ }) => {
1036
+ const buttonRef = (0, import_react6.useRef)(null);
1037
+ const variableTypes = getVariableTypes();
1038
+ const menuOptions = Object.entries(variableTypes).map(([key, variable]) => {
1039
+ const displayName = variable.variableType.charAt(0).toUpperCase() + variable.variableType.slice(1);
579
1040
  return {
580
- field: "label",
581
- message: ERROR_MESSAGES.DUPLICATED_LABEL
1041
+ key,
1042
+ name: displayName,
1043
+ icon: variable.icon,
1044
+ onClick: () => {
1045
+ const defaultName = getDefaultName(variables, key, variable.variableType);
1046
+ onCreate(key, defaultName, variable.defaultValue || "");
1047
+ trackVariablesManagerEvent({ action: "add", varType: variable.variableType });
1048
+ }
582
1049
  };
583
- }
584
- return void 0;
585
- };
586
- var validateLabel = (name) => {
587
- if (!name.trim()) {
588
- return ERROR_MESSAGES.MISSING_VARIABLE_NAME;
589
- }
590
- const allowedChars = /^[a-zA-Z0-9_-]+$/;
591
- if (!allowedChars.test(name)) {
592
- return ERROR_MESSAGES.INVALID_CHARACTERS;
593
- }
594
- const hasAlphanumeric = /[a-zA-Z0-9]/;
595
- if (!hasAlphanumeric.test(name)) {
596
- return ERROR_MESSAGES.NO_NON_SPECIAL_CHARACTER;
597
- }
598
- if (VARIABLE_LABEL_MAX_LENGTH < name.length) {
599
- return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
600
- }
601
- return "";
602
- };
603
- var labelHint = (name) => {
604
- const hintThreshold = VARIABLE_LABEL_MAX_LENGTH * 0.8 - 1;
605
- if (hintThreshold < name.length) {
606
- return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
607
- }
608
- return "";
1050
+ });
1051
+ return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(
1052
+ import_ui6.IconButton,
1053
+ {
1054
+ ...(0, import_ui6.bindTrigger)(menuState),
1055
+ ref: buttonRef,
1056
+ disabled,
1057
+ size: SIZE,
1058
+ "aria-label": (0, import_i18n7.__)("Add variable", "elementor")
1059
+ },
1060
+ /* @__PURE__ */ React6.createElement(import_icons3.PlusIcon, { fontSize: SIZE })
1061
+ ), /* @__PURE__ */ React6.createElement(
1062
+ import_ui6.Menu,
1063
+ {
1064
+ disablePortal: true,
1065
+ MenuListProps: {
1066
+ dense: true
1067
+ },
1068
+ PaperProps: {
1069
+ elevation: 6
1070
+ },
1071
+ ...(0, import_ui6.bindMenu)(menuState),
1072
+ anchorEl: buttonRef.current,
1073
+ anchorOrigin: {
1074
+ vertical: "bottom",
1075
+ horizontal: "right"
1076
+ },
1077
+ transformOrigin: {
1078
+ vertical: "top",
1079
+ horizontal: "right"
1080
+ },
1081
+ "data-testid": "variable-manager-create-menu"
1082
+ },
1083
+ menuOptions.map((option) => /* @__PURE__ */ React6.createElement(
1084
+ import_ui6.MenuItem,
1085
+ {
1086
+ key: option.key,
1087
+ onClick: () => {
1088
+ option.onClick?.();
1089
+ menuState.close();
1090
+ },
1091
+ sx: {
1092
+ gap: 1.5
1093
+ }
1094
+ },
1095
+ (0, import_react6.createElement)(option.icon, {
1096
+ fontSize: SIZE,
1097
+ color: "action"
1098
+ }),
1099
+ /* @__PURE__ */ React6.createElement(import_ui6.Typography, { variant: "caption", color: "text.primary" }, option.name)
1100
+ ))
1101
+ ));
609
1102
  };
610
- var validateValue = (value) => {
611
- if (!value.trim()) {
612
- return ERROR_MESSAGES.MISSING_VARIABLE_VALUE;
1103
+ var getDefaultName = (variables, type, baseName) => {
1104
+ const existingNames = Object.values(variables).filter((variable) => variable.type === type).map((variable) => variable.label);
1105
+ let counter = 1;
1106
+ let name = `${baseName}-${counter}`;
1107
+ while (existingNames.includes(name)) {
1108
+ counter++;
1109
+ name = `${baseName}-${counter}`;
613
1110
  }
614
- return "";
1111
+ return name;
615
1112
  };
616
1113
 
1114
+ // src/components/variables-manager/variables-manager-table.tsx
1115
+ var React11 = __toESM(require("react"));
1116
+ var import_react10 = require("react");
1117
+ var import_editor_ui2 = require("@elementor/editor-ui");
1118
+ var import_icons5 = require("@elementor/icons");
1119
+ var import_ui11 = require("@elementor/ui");
1120
+ var import_i18n8 = require("@wordpress/i18n");
1121
+
617
1122
  // src/components/fields/label-field.tsx
1123
+ var React7 = __toESM(require("react"));
1124
+ var import_react7 = require("react");
1125
+ var import_editor_ui = require("@elementor/editor-ui");
1126
+ var import_ui7 = require("@elementor/ui");
618
1127
  function isLabelEqual(a, b) {
619
1128
  return a.trim().toLowerCase() === b.trim().toLowerCase();
620
1129
  }
621
1130
  var useLabelError = (initialError) => {
622
- const [error, setError] = (0, import_react3.useState)(initialError ?? { value: "", message: "" });
1131
+ const [error, setError] = (0, import_react7.useState)(initialError ?? { value: "", message: "" });
623
1132
  return {
624
1133
  labelFieldError: error,
625
1134
  setLabelFieldError: setError
@@ -632,13 +1141,17 @@ var LabelField = ({
632
1141
  id: id2,
633
1142
  onErrorChange,
634
1143
  size = "tiny",
635
- focusOnShow = false
1144
+ focusOnShow = false,
1145
+ selectOnShow = false,
1146
+ showWarningInfotip = false,
1147
+ variables
636
1148
  }) => {
637
- const [label, setLabel] = (0, import_react3.useState)(value);
638
- const [errorMessage, setErrorMessage] = (0, import_react3.useState)("");
1149
+ const [label, setLabel] = (0, import_react7.useState)(value);
1150
+ const [errorMessage, setErrorMessage] = (0, import_react7.useState)("");
1151
+ const fieldRef = (0, import_react7.useRef)(null);
639
1152
  const handleChange = (newValue) => {
640
1153
  setLabel(newValue);
641
- const errorMsg2 = validateLabel(newValue);
1154
+ const errorMsg2 = validateLabel(newValue, variables);
642
1155
  setErrorMessage(errorMsg2);
643
1156
  onErrorChange?.(errorMsg2);
644
1157
  onChange(isLabelEqual(newValue, error?.value ?? "") || errorMsg2 ? "" : newValue);
@@ -647,32 +1160,54 @@ var LabelField = ({
647
1160
  if (isLabelEqual(label, error?.value ?? "") && error?.message) {
648
1161
  errorMsg = error.message;
649
1162
  }
650
- return /* @__PURE__ */ React3.createElement(
651
- import_ui3.TextField,
1163
+ const hintMsg = !errorMsg ? labelHint(label) : "";
1164
+ const textField = /* @__PURE__ */ React7.createElement(
1165
+ import_ui7.TextField,
652
1166
  {
1167
+ ref: fieldRef,
653
1168
  id: id2,
654
1169
  size,
655
1170
  fullWidth: true,
656
1171
  value: label,
657
1172
  error: !!errorMsg,
658
1173
  onChange: (e) => handleChange(e.target.value),
659
- inputProps: { maxLength: VARIABLE_LABEL_MAX_LENGTH },
1174
+ inputProps: {
1175
+ maxLength: VARIABLE_LABEL_MAX_LENGTH,
1176
+ ...selectOnShow && { onFocus: (e) => e.target.select() },
1177
+ "aria-label": "Name"
1178
+ },
660
1179
  autoFocus: focusOnShow
661
1180
  }
662
1181
  );
1182
+ if (showWarningInfotip) {
1183
+ const tooltipWidth = Math.max(240, fieldRef.current?.getBoundingClientRect().width ?? 240);
1184
+ return /* @__PURE__ */ React7.createElement(
1185
+ import_editor_ui.WarningInfotip,
1186
+ {
1187
+ open: Boolean(errorMsg || hintMsg),
1188
+ text: errorMsg || hintMsg,
1189
+ placement: "bottom-start",
1190
+ width: tooltipWidth,
1191
+ offset: [0, -15],
1192
+ ...hintMsg && { hasError: false }
1193
+ },
1194
+ textField
1195
+ );
1196
+ }
1197
+ return textField;
663
1198
  };
664
1199
 
665
- // src/components/variables-manager/variable-edit-menu.tsx
666
- var React4 = __toESM(require("react"));
667
- var import_react4 = require("react");
668
- var import_icons = require("@elementor/icons");
669
- var import_ui4 = require("@elementor/ui");
1200
+ // src/components/variables-manager/ui/variable-edit-menu.tsx
1201
+ var React8 = __toESM(require("react"));
1202
+ var import_react8 = require("react");
1203
+ var import_icons4 = require("@elementor/icons");
1204
+ var import_ui8 = require("@elementor/ui");
670
1205
  var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
671
- const menuState = (0, import_ui4.usePopupState)({
1206
+ const menuState = (0, import_ui8.usePopupState)({
672
1207
  variant: "popover"
673
1208
  });
674
- return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(import_ui4.IconButton, { ...(0, import_ui4.bindTrigger)(menuState), disabled, size: "tiny" }, /* @__PURE__ */ React4.createElement(import_icons.DotsVerticalIcon, { fontSize: "tiny" })), /* @__PURE__ */ React4.createElement(
675
- import_ui4.Menu,
1209
+ return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(import_ui8.IconButton, { ...(0, import_ui8.bindTrigger)(menuState), disabled, size: "tiny" }, /* @__PURE__ */ React8.createElement(import_icons4.DotsVerticalIcon, { fontSize: "tiny" })), /* @__PURE__ */ React8.createElement(
1210
+ import_ui8.Menu,
676
1211
  {
677
1212
  disablePortal: true,
678
1213
  MenuListProps: {
@@ -681,7 +1216,7 @@ var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
681
1216
  PaperProps: {
682
1217
  elevation: 6
683
1218
  },
684
- ...(0, import_ui4.bindMenu)(menuState),
1219
+ ...(0, import_ui8.bindMenu)(menuState),
685
1220
  anchorEl: menuState.anchorEl,
686
1221
  anchorOrigin: {
687
1222
  vertical: "bottom",
@@ -694,8 +1229,8 @@ var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
694
1229
  open: menuState.isOpen,
695
1230
  onClose: menuState.close
696
1231
  },
697
- menuActions.map((action) => /* @__PURE__ */ React4.createElement(
698
- import_ui4.MenuItem,
1232
+ menuActions.map((action) => /* @__PURE__ */ React8.createElement(
1233
+ import_ui8.MenuItem,
699
1234
  {
700
1235
  key: action.name,
701
1236
  onClick: () => {
@@ -707,7 +1242,7 @@ var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
707
1242
  gap: 1
708
1243
  }
709
1244
  },
710
- action.icon && (0, import_react4.createElement)(action.icon, {
1245
+ action.icon && (0, import_react8.createElement)(action.icon, {
711
1246
  fontSize: "inherit"
712
1247
  }),
713
1248
  " ",
@@ -716,78 +1251,9 @@ var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
716
1251
  ));
717
1252
  };
718
1253
 
719
- // src/components/variables-manager/variable-editable-cell.tsx
720
- var React5 = __toESM(require("react"));
721
- var import_react5 = require("react");
722
- var import_ui5 = require("@elementor/ui");
723
- var VariableEditableCell = ({
724
- initialValue,
725
- children,
726
- editableElement,
727
- onChange,
728
- prefixElement
729
- }) => {
730
- const [value, setValue] = (0, import_react5.useState)(initialValue);
731
- const [isEditing, setIsEditing] = (0, import_react5.useState)(false);
732
- const handleDoubleClick = () => {
733
- setIsEditing(true);
734
- };
735
- const handleSave = () => {
736
- onChange(value);
737
- setIsEditing(false);
738
- };
739
- const handleKeyDown = (event) => {
740
- if (event.key === "Enter") {
741
- handleSave();
742
- } else if (event.key === "Escape") {
743
- setIsEditing(false);
744
- }
745
- if (event.key === " " && !isEditing) {
746
- event.preventDefault();
747
- setIsEditing(true);
748
- }
749
- };
750
- const handleChange = (newValue) => {
751
- setValue(newValue);
752
- };
753
- const editableContent = editableElement({ value, onChange: handleChange });
754
- if (isEditing) {
755
- return /* @__PURE__ */ React5.createElement(import_ui5.ClickAwayListener, { onClickAway: handleSave }, /* @__PURE__ */ React5.createElement(
756
- import_ui5.Stack,
757
- {
758
- direction: "row",
759
- alignItems: "center",
760
- gap: 1,
761
- onDoubleClick: handleDoubleClick,
762
- onKeyDown: handleKeyDown,
763
- tabIndex: 0,
764
- role: "button",
765
- "aria-label": "Double click or press Space to edit"
766
- },
767
- prefixElement,
768
- editableContent
769
- ));
770
- }
771
- return /* @__PURE__ */ React5.createElement(
772
- import_ui5.Stack,
773
- {
774
- direction: "row",
775
- alignItems: "center",
776
- gap: 1,
777
- onDoubleClick: handleDoubleClick,
778
- onKeyDown: handleKeyDown,
779
- tabIndex: 0,
780
- role: "button",
781
- "aria-label": "Double click or press Space to edit"
782
- },
783
- prefixElement,
784
- children
785
- );
786
- };
787
-
788
- // src/components/variables-manager/variable-table-cell.tsx
789
- var React6 = __toESM(require("react"));
790
- var import_ui6 = require("@elementor/ui");
1254
+ // src/components/variables-manager/ui/variable-table-cell.tsx
1255
+ var React9 = __toESM(require("react"));
1256
+ var import_ui9 = require("@elementor/ui");
791
1257
  var VariableTableCell = ({
792
1258
  children,
793
1259
  isHeader,
@@ -806,20 +1272,167 @@ var VariableTableCell = ({
806
1272
  ...width && { width },
807
1273
  ...sx
808
1274
  };
809
- return /* @__PURE__ */ React6.createElement(import_ui6.TableCell, { size: "small", padding: noPadding ? "none" : void 0, align, sx: baseSx }, children);
1275
+ return /* @__PURE__ */ React9.createElement(import_ui9.TableCell, { size: "small", padding: noPadding ? "none" : void 0, align, sx: baseSx }, children);
810
1276
  };
811
1277
 
1278
+ // src/components/variables-manager/variable-editable-cell.tsx
1279
+ var React10 = __toESM(require("react"));
1280
+ var import_react9 = require("react");
1281
+ var import_ui10 = require("@elementor/ui");
1282
+ var VariableEditableCell = React10.memo(
1283
+ ({
1284
+ initialValue,
1285
+ children,
1286
+ editableElement,
1287
+ onChange,
1288
+ prefixElement,
1289
+ autoEdit = false,
1290
+ onRowRef,
1291
+ onAutoEditComplete,
1292
+ gap = 1,
1293
+ fieldType
1294
+ }) => {
1295
+ const [value, setValue] = (0, import_react9.useState)(initialValue);
1296
+ const [isEditing, setIsEditing] = (0, import_react9.useState)(false);
1297
+ const { labelFieldError, setLabelFieldError } = useLabelError();
1298
+ const [valueFieldError, setValueFieldError] = (0, import_react9.useState)("");
1299
+ const rowRef = (0, import_react9.useRef)(null);
1300
+ const handleSave = (0, import_react9.useCallback)(() => {
1301
+ const hasError = fieldType === "label" && labelFieldError?.message || fieldType === "value" && valueFieldError;
1302
+ if (!hasError) {
1303
+ onChange(value);
1304
+ }
1305
+ setIsEditing(false);
1306
+ }, [value, onChange, fieldType, labelFieldError, valueFieldError]);
1307
+ (0, import_react9.useEffect)(() => {
1308
+ onRowRef?.(rowRef?.current);
1309
+ }, [onRowRef]);
1310
+ (0, import_react9.useEffect)(() => {
1311
+ if (autoEdit && !isEditing) {
1312
+ setIsEditing(true);
1313
+ onAutoEditComplete?.();
1314
+ }
1315
+ }, [autoEdit, isEditing, onAutoEditComplete]);
1316
+ const handleDoubleClick = () => {
1317
+ setIsEditing(true);
1318
+ };
1319
+ const handleKeyDown = (event) => {
1320
+ if (event.key === "Enter") {
1321
+ handleSave();
1322
+ } else if (event.key === "Escape") {
1323
+ setIsEditing(false);
1324
+ }
1325
+ if (event.key === " " && !isEditing) {
1326
+ event.preventDefault();
1327
+ setIsEditing(true);
1328
+ }
1329
+ };
1330
+ const handleChange = (0, import_react9.useCallback)((newValue) => {
1331
+ setValue(newValue);
1332
+ }, []);
1333
+ const handleValidationChange = (0, import_react9.useCallback)(
1334
+ (errorMsg) => {
1335
+ if (fieldType === "label") {
1336
+ setLabelFieldError({
1337
+ value,
1338
+ message: errorMsg
1339
+ });
1340
+ } else {
1341
+ setValueFieldError(errorMsg);
1342
+ }
1343
+ },
1344
+ [fieldType, value, setLabelFieldError, setValueFieldError]
1345
+ );
1346
+ let currentError;
1347
+ if (fieldType === "label") {
1348
+ currentError = labelFieldError;
1349
+ } else if (fieldType === "value") {
1350
+ currentError = { value, message: valueFieldError };
1351
+ }
1352
+ const editableContent = editableElement({
1353
+ value,
1354
+ onChange: handleChange,
1355
+ onValidationChange: handleValidationChange,
1356
+ error: currentError
1357
+ });
1358
+ if (isEditing) {
1359
+ return /* @__PURE__ */ React10.createElement(import_ui10.ClickAwayListener, { onClickAway: handleSave }, /* @__PURE__ */ React10.createElement(
1360
+ import_ui10.Stack,
1361
+ {
1362
+ ref: rowRef,
1363
+ direction: "row",
1364
+ alignItems: "center",
1365
+ gap,
1366
+ onDoubleClick: handleDoubleClick,
1367
+ onKeyDown: handleKeyDown,
1368
+ tabIndex: 0,
1369
+ role: "button",
1370
+ "aria-label": "Double click or press Space to edit"
1371
+ },
1372
+ prefixElement,
1373
+ editableContent
1374
+ ));
1375
+ }
1376
+ return /* @__PURE__ */ React10.createElement(
1377
+ import_ui10.Stack,
1378
+ {
1379
+ ref: rowRef,
1380
+ direction: "row",
1381
+ alignItems: "center",
1382
+ gap,
1383
+ onDoubleClick: handleDoubleClick,
1384
+ onKeyDown: handleKeyDown,
1385
+ tabIndex: 0,
1386
+ role: "button",
1387
+ "aria-label": "Double click or press Space to edit"
1388
+ },
1389
+ prefixElement,
1390
+ children
1391
+ );
1392
+ }
1393
+ );
1394
+
812
1395
  // src/components/variables-manager/variables-manager-table.tsx
813
- var VariablesManagerTable = ({ menuActions, variables, onChange: handleOnChange }) => {
814
- const [ids, setIds] = (0, import_react6.useState)(Object.keys(variables));
1396
+ var VariablesManagerTable = ({
1397
+ menuActions,
1398
+ variables,
1399
+ onChange: handleOnChange,
1400
+ autoEditVariableId,
1401
+ onAutoEditComplete,
1402
+ onFieldError
1403
+ }) => {
1404
+ const tableContainerRef = (0, import_react10.useRef)(null);
1405
+ const variableRowRefs = (0, import_react10.useRef)(/* @__PURE__ */ new Map());
1406
+ (0, import_react10.useEffect)(() => {
1407
+ if (autoEditVariableId && tableContainerRef.current) {
1408
+ const rowElement = variableRowRefs.current.get(autoEditVariableId);
1409
+ if (rowElement) {
1410
+ setTimeout(() => {
1411
+ rowElement.scrollIntoView({
1412
+ behavior: "smooth",
1413
+ block: "center",
1414
+ inline: "nearest"
1415
+ });
1416
+ }, 100);
1417
+ }
1418
+ }
1419
+ }, [autoEditVariableId]);
1420
+ const handleRowRef = (id2) => (ref) => {
1421
+ if (ref) {
1422
+ variableRowRefs.current.set(id2, ref);
1423
+ } else {
1424
+ variableRowRefs.current.delete(id2);
1425
+ }
1426
+ };
1427
+ const ids = Object.keys(variables).sort(sortVariablesOrder(variables));
815
1428
  const rows = ids.filter((id2) => !variables[id2].deleted).map((id2) => {
816
1429
  const variable = variables[id2];
817
1430
  const variableType = getVariableType(variable.type);
818
1431
  return {
819
1432
  id: id2,
1433
+ type: variable.type,
820
1434
  name: variable.label,
821
1435
  value: variable.value,
822
- type: variable.type,
823
1436
  ...variableType
824
1437
  };
825
1438
  });
@@ -827,17 +1440,28 @@ var VariablesManagerTable = ({ menuActions, variables, onChange: handleOnChange
827
1440
  minWidth: 250,
828
1441
  tableLayout: "fixed"
829
1442
  };
830
- return /* @__PURE__ */ React7.createElement(import_ui7.TableContainer, { sx: { overflow: "initial" } }, /* @__PURE__ */ React7.createElement(import_ui7.Table, { sx: tableSX, "aria-label": "Variables manager list with drag and drop reordering", stickyHeader: true }, /* @__PURE__ */ React7.createElement(import_ui7.TableHead, null, /* @__PURE__ */ React7.createElement(import_ui7.TableRow, null, /* @__PURE__ */ React7.createElement(VariableTableCell, { isHeader: true, noPadding: true, width: 10, maxWidth: 10 }), /* @__PURE__ */ React7.createElement(VariableTableCell, { isHeader: true }, (0, import_i18n4.__)("Name", "elementor")), /* @__PURE__ */ React7.createElement(VariableTableCell, { isHeader: true }, (0, import_i18n4.__)("Value", "elementor")), /* @__PURE__ */ React7.createElement(VariableTableCell, { isHeader: true, noPadding: true, width: 16, maxWidth: 16 }))), /* @__PURE__ */ React7.createElement(import_ui7.TableBody, null, /* @__PURE__ */ React7.createElement(
831
- import_ui7.UnstableSortableProvider,
1443
+ const handleReorder = (newIds) => {
1444
+ const updatedVariables = { ...variables };
1445
+ newIds.forEach((id2, index) => {
1446
+ const current = updatedVariables[id2];
1447
+ if (!current) {
1448
+ return;
1449
+ }
1450
+ updatedVariables[id2] = Object.assign({}, current, { order: index + 1 });
1451
+ });
1452
+ handleOnChange(updatedVariables);
1453
+ };
1454
+ return /* @__PURE__ */ React11.createElement(import_ui11.TableContainer, { ref: tableContainerRef, sx: { overflow: "initial" } }, /* @__PURE__ */ React11.createElement(import_ui11.Table, { sx: tableSX, "aria-label": "Variables manager list with drag and drop reordering", stickyHeader: true }, /* @__PURE__ */ React11.createElement(import_ui11.TableHead, null, /* @__PURE__ */ React11.createElement(import_ui11.TableRow, null, /* @__PURE__ */ React11.createElement(VariableTableCell, { isHeader: true, noPadding: true, width: 10, maxWidth: 10 }), /* @__PURE__ */ React11.createElement(VariableTableCell, { isHeader: true }, (0, import_i18n8.__)("Name", "elementor")), /* @__PURE__ */ React11.createElement(VariableTableCell, { isHeader: true }, (0, import_i18n8.__)("Value", "elementor")), /* @__PURE__ */ React11.createElement(VariableTableCell, { isHeader: true, noPadding: true, width: 16, maxWidth: 16 }))), /* @__PURE__ */ React11.createElement(import_ui11.TableBody, null, /* @__PURE__ */ React11.createElement(
1455
+ import_ui11.UnstableSortableProvider,
832
1456
  {
833
1457
  value: ids,
834
- onChange: setIds,
1458
+ onChange: handleReorder,
835
1459
  variant: "static",
836
1460
  restrictAxis: true,
837
- dragOverlay: ({ children: dragOverlayChildren, ...dragOverlayProps }) => /* @__PURE__ */ React7.createElement(import_ui7.Table, { sx: tableSX, ...dragOverlayProps }, /* @__PURE__ */ React7.createElement(import_ui7.TableBody, null, dragOverlayChildren))
1461
+ dragOverlay: ({ children: dragOverlayChildren, ...dragOverlayProps }) => /* @__PURE__ */ React11.createElement(import_ui11.Table, { sx: tableSX, ...dragOverlayProps }, /* @__PURE__ */ React11.createElement(import_ui11.TableBody, null, dragOverlayChildren))
838
1462
  },
839
- rows.map((row) => /* @__PURE__ */ React7.createElement(
840
- import_ui7.UnstableSortableItem,
1463
+ rows.map((row) => /* @__PURE__ */ React11.createElement(
1464
+ import_ui11.UnstableSortableItem,
841
1465
  {
842
1466
  key: row.id,
843
1467
  id: row.id,
@@ -850,14 +1474,12 @@ var VariablesManagerTable = ({ menuActions, variables, onChange: handleOnChange
850
1474
  isDragged,
851
1475
  dropPosition,
852
1476
  setTriggerRef,
853
- isDragOverlay,
854
- isSorting,
855
- index
1477
+ isSorting
856
1478
  }) => {
857
1479
  const showIndicationBefore = showDropIndication && dropPosition === "before";
858
1480
  const showIndicationAfter = showDropIndication && dropPosition === "after";
859
- return /* @__PURE__ */ React7.createElement(
860
- import_ui7.TableRow,
1481
+ return /* @__PURE__ */ React11.createElement(
1482
+ import_ui11.TableRow,
861
1483
  {
862
1484
  ...itemProps,
863
1485
  selected: isDragged,
@@ -884,11 +1506,10 @@ var VariablesManagerTable = ({ menuActions, variables, onChange: handleOnChange
884
1506
  }
885
1507
  }
886
1508
  },
887
- style: { ...itemStyle, ...triggerStyle },
888
- disableDivider: isDragOverlay || index === rows.length - 1
1509
+ style: { ...itemStyle, ...triggerStyle }
889
1510
  },
890
- /* @__PURE__ */ React7.createElement(VariableTableCell, { noPadding: true, width: 10, maxWidth: 10 }, /* @__PURE__ */ React7.createElement(
891
- import_ui7.IconButton,
1511
+ /* @__PURE__ */ React11.createElement(VariableTableCell, { noPadding: true, width: 10, maxWidth: 10 }, /* @__PURE__ */ React11.createElement(
1512
+ import_ui11.IconButton,
892
1513
  {
893
1514
  size: "small",
894
1515
  ref: setTriggerRef,
@@ -896,9 +1517,9 @@ var VariablesManagerTable = ({ menuActions, variables, onChange: handleOnChange
896
1517
  disabled: isSorting,
897
1518
  draggable: true
898
1519
  },
899
- /* @__PURE__ */ React7.createElement(import_icons2.GripVerticalIcon, { fontSize: "inherit" })
1520
+ /* @__PURE__ */ React11.createElement(import_icons5.GripVerticalIcon, { fontSize: "inherit" })
900
1521
  )),
901
- /* @__PURE__ */ React7.createElement(VariableTableCell, null, /* @__PURE__ */ React7.createElement(
1522
+ /* @__PURE__ */ React11.createElement(VariableTableCell, null, /* @__PURE__ */ React11.createElement(
902
1523
  VariableEditableCell,
903
1524
  {
904
1525
  initialValue: row.name,
@@ -910,20 +1531,37 @@ var VariablesManagerTable = ({ menuActions, variables, onChange: handleOnChange
910
1531
  });
911
1532
  }
912
1533
  },
913
- prefixElement: (0, import_react6.createElement)(row.icon, { fontSize: "inherit" }),
914
- editableElement: ({ value, onChange }) => /* @__PURE__ */ React7.createElement(
1534
+ prefixElement: (0, import_react10.createElement)(row.icon, { fontSize: "inherit" }),
1535
+ editableElement: ({
1536
+ value,
1537
+ onChange,
1538
+ onValidationChange,
1539
+ error
1540
+ }) => /* @__PURE__ */ React11.createElement(
915
1541
  LabelField,
916
1542
  {
917
1543
  id: "variable-label-" + row.id,
918
1544
  size: "tiny",
919
1545
  value,
920
1546
  onChange,
921
- focusOnShow: true
1547
+ onErrorChange: (errorMsg) => {
1548
+ onValidationChange?.(errorMsg);
1549
+ onFieldError?.(!!errorMsg);
1550
+ },
1551
+ error,
1552
+ focusOnShow: true,
1553
+ selectOnShow: autoEditVariableId === row.id,
1554
+ showWarningInfotip: true,
1555
+ variables
922
1556
  }
923
- )
1557
+ ),
1558
+ autoEdit: autoEditVariableId === row.id,
1559
+ onRowRef: handleRowRef(row.id),
1560
+ onAutoEditComplete: autoEditVariableId === row.id ? onAutoEditComplete : void 0,
1561
+ fieldType: "label"
924
1562
  },
925
- /* @__PURE__ */ React7.createElement(
926
- import_editor_ui.EllipsisWithTooltip,
1563
+ /* @__PURE__ */ React11.createElement(
1564
+ import_editor_ui2.EllipsisWithTooltip,
927
1565
  {
928
1566
  title: row.name,
929
1567
  sx: { border: "4px solid transparent" }
@@ -931,7 +1569,7 @@ var VariablesManagerTable = ({ menuActions, variables, onChange: handleOnChange
931
1569
  row.name
932
1570
  )
933
1571
  )),
934
- /* @__PURE__ */ React7.createElement(VariableTableCell, null, /* @__PURE__ */ React7.createElement(
1572
+ /* @__PURE__ */ React11.createElement(VariableTableCell, null, /* @__PURE__ */ React11.createElement(
935
1573
  VariableEditableCell,
936
1574
  {
937
1575
  initialValue: row.value,
@@ -943,19 +1581,39 @@ var VariablesManagerTable = ({ menuActions, variables, onChange: handleOnChange
943
1581
  });
944
1582
  }
945
1583
  },
946
- editableElement: row.valueField
1584
+ editableElement: ({
1585
+ value,
1586
+ onChange,
1587
+ onValidationChange,
1588
+ error
1589
+ }) => row.valueField({
1590
+ value,
1591
+ onChange,
1592
+ onValidationChange: (errorMsg) => {
1593
+ onValidationChange?.(errorMsg);
1594
+ onFieldError?.(!!errorMsg);
1595
+ },
1596
+ error
1597
+ }),
1598
+ onRowRef: handleRowRef(row.id),
1599
+ gap: 0.25,
1600
+ fieldType: "value"
947
1601
  },
948
1602
  row.startIcon && row.startIcon({ value: row.value }),
949
- /* @__PURE__ */ React7.createElement(
950
- import_editor_ui.EllipsisWithTooltip,
1603
+ /* @__PURE__ */ React11.createElement(
1604
+ import_editor_ui2.EllipsisWithTooltip,
951
1605
  {
952
1606
  title: row.value,
953
- sx: { border: "4px solid transparent" }
1607
+ sx: {
1608
+ border: "4px solid transparent",
1609
+ lineHeight: "1",
1610
+ pt: 0.25
1611
+ }
954
1612
  },
955
1613
  row.value
956
1614
  )
957
1615
  )),
958
- /* @__PURE__ */ React7.createElement(
1616
+ /* @__PURE__ */ React11.createElement(
959
1617
  VariableTableCell,
960
1618
  {
961
1619
  align: "right",
@@ -964,7 +1622,7 @@ var VariablesManagerTable = ({ menuActions, variables, onChange: handleOnChange
964
1622
  maxWidth: 16,
965
1623
  sx: { paddingInlineEnd: 1 }
966
1624
  },
967
- /* @__PURE__ */ React7.createElement(import_ui7.Stack, { role: "toolbar", direction: "row", justifyContent: "flex-end" }, /* @__PURE__ */ React7.createElement(
1625
+ /* @__PURE__ */ React11.createElement(import_ui11.Stack, { role: "toolbar", direction: "row", justifyContent: "flex-end" }, /* @__PURE__ */ React11.createElement(
968
1626
  VariableEditMenu,
969
1627
  {
970
1628
  menuActions,
@@ -979,6 +1637,13 @@ var VariablesManagerTable = ({ menuActions, variables, onChange: handleOnChange
979
1637
  ))
980
1638
  ))));
981
1639
  };
1640
+ function sortVariablesOrder(variables) {
1641
+ return (a, b) => {
1642
+ const orderA = variables[a]?.order ?? Number.MAX_SAFE_INTEGER;
1643
+ const orderB = variables[b]?.order ?? Number.MAX_SAFE_INTEGER;
1644
+ return orderA - orderB;
1645
+ };
1646
+ }
982
1647
 
983
1648
  // src/components/variables-manager/variables-manager-panel.tsx
984
1649
  var id = "variables-manager";
@@ -991,39 +1656,134 @@ var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
991
1656
  },
992
1657
  onClose: () => {
993
1658
  (0, import_editor_v1_adapters.changeEditMode)("edit");
994
- }
1659
+ },
1660
+ isOpenPreviousElement: true
995
1661
  });
996
1662
  function VariablesManagerPanel() {
997
1663
  const { close: closePanel } = usePanelActions();
998
- const [isDirty, setIsDirty] = (0, import_react7.useState)(false);
999
- const [variables, setVariables] = (0, import_react7.useState)(getVariables(false));
1000
- const [deletedVariables, setDeletedVariables] = (0, import_react7.useState)([]);
1664
+ const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = (0, import_editor_ui3.useDialog)();
1665
+ const createMenuState = (0, import_ui12.usePopupState)({
1666
+ variant: "popover"
1667
+ });
1668
+ const {
1669
+ variables,
1670
+ isDirty,
1671
+ searchValue,
1672
+ isSaveDisabled,
1673
+ handleOnChange,
1674
+ createVariable: createVariable2,
1675
+ handleDeleteVariable,
1676
+ handleSave,
1677
+ isSaving,
1678
+ handleSearch,
1679
+ setIsSaving,
1680
+ setIsSaveDisabled
1681
+ } = useVariablesManagerState();
1682
+ const { autoEditVariableId, startAutoEdit, handleAutoEditComplete } = useAutoEdit();
1683
+ const { createNavigationCallback, resetNavigation } = useErrorNavigation();
1684
+ const [deleteConfirmation, setDeleteConfirmation] = (0, import_react11.useState)(null);
1685
+ const [serverError, setServerError] = (0, import_react11.useState)(null);
1001
1686
  usePreventUnload(isDirty);
1687
+ const handleClosePanel = () => {
1688
+ if (isDirty) {
1689
+ openSaveChangesDialog();
1690
+ return;
1691
+ }
1692
+ closePanel();
1693
+ };
1694
+ const handleCreateVariable = (0, import_react11.useCallback)(
1695
+ (type, defaultName, defaultValue) => {
1696
+ const newId = createVariable2(type, defaultName, defaultValue);
1697
+ if (newId) {
1698
+ startAutoEdit(newId);
1699
+ }
1700
+ },
1701
+ [createVariable2, startAutoEdit]
1702
+ );
1703
+ const handleSaveClick = async () => {
1704
+ try {
1705
+ setServerError(null);
1706
+ resetNavigation();
1707
+ const result = await handleSave();
1708
+ trackVariablesManagerEvent({ action: "saveChanges" });
1709
+ return result;
1710
+ } catch (error) {
1711
+ const mappedError = mapServerError(error);
1712
+ const duplicatedIds = mappedError?.action?.data?.duplicatedIds;
1713
+ if (mappedError && "label" === mappedError.field) {
1714
+ if (duplicatedIds && mappedError.action) {
1715
+ mappedError.action.callback = createNavigationCallback(duplicatedIds, startAutoEdit, () => {
1716
+ setIsSaveDisabled(false);
1717
+ });
1718
+ }
1719
+ setServerError(mappedError);
1720
+ setIsSaveDisabled(true);
1721
+ resetNavigation();
1722
+ }
1723
+ return { success: false, error: mappedError };
1724
+ } finally {
1725
+ setIsSaving(false);
1726
+ }
1727
+ };
1728
+ const handleDeleteVariableWithConfirmation = (0, import_react11.useCallback)(
1729
+ (itemId) => {
1730
+ handleDeleteVariable(itemId);
1731
+ setDeleteConfirmation(null);
1732
+ },
1733
+ [handleDeleteVariable]
1734
+ );
1002
1735
  const menuActions = [
1003
1736
  {
1004
- name: (0, import_i18n5.__)("Delete", "elementor"),
1005
- icon: import_icons3.TrashIcon,
1737
+ name: (0, import_i18n9.__)("Delete", "elementor"),
1738
+ icon: import_icons6.TrashIcon,
1006
1739
  color: "error.main",
1007
1740
  onClick: (itemId) => {
1008
- setDeletedVariables([...deletedVariables, itemId]);
1009
- setVariables({ ...variables, [itemId]: { ...variables[itemId], deleted: true } });
1010
- setIsDirty(true);
1741
+ const variable = variables[itemId];
1742
+ if (variable) {
1743
+ setDeleteConfirmation({ id: itemId, label: variable.label });
1744
+ const variableTypeOptions = getVariableType(variable.type);
1745
+ trackVariablesManagerEvent({ action: "delete", varType: variableTypeOptions?.variableType });
1746
+ }
1011
1747
  }
1012
1748
  }
1013
1749
  ];
1014
- const handleOnChange = (newVariables) => {
1015
- setVariables(newVariables);
1016
- setIsDirty(true);
1017
- };
1018
- return /* @__PURE__ */ React8.createElement(import_editor_ui2.ThemeProvider, null, /* @__PURE__ */ React8.createElement(import_ui8.ErrorBoundary, { fallback: /* @__PURE__ */ React8.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React8.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React8.createElement(import_editor_panels.PanelHeader, null, /* @__PURE__ */ React8.createElement(import_ui8.Stack, { width: "100%", direction: "column", alignItems: "center" }, /* @__PURE__ */ React8.createElement(import_ui8.Stack, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React8.createElement(import_ui8.Stack, { width: "100%", direction: "row", gap: 1 }, /* @__PURE__ */ React8.createElement(import_editor_panels.PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React8.createElement(import_icons3.ColorFilterIcon, { fontSize: "inherit" }), (0, import_i18n5.__)("Variable Manager", "elementor"))), /* @__PURE__ */ React8.createElement(
1019
- CloseButton,
1750
+ const hasVariables = Object.values(variables).some((variable) => !variable.deleted);
1751
+ return /* @__PURE__ */ React12.createElement(import_editor_ui3.ThemeProvider, null, /* @__PURE__ */ React12.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React12.createElement(
1752
+ import_editor_panels.PanelHeader,
1020
1753
  {
1021
- sx: { marginLeft: "auto" },
1022
- onClose: () => {
1023
- closePanel();
1754
+ sx: {
1755
+ height: "unset"
1024
1756
  }
1025
- }
1026
- )), /* @__PURE__ */ React8.createElement(import_ui8.Divider, { sx: { width: "100%" } }))), /* @__PURE__ */ React8.createElement(
1757
+ },
1758
+ /* @__PURE__ */ React12.createElement(import_ui12.Stack, { width: "100%", direction: "column", alignItems: "center" }, /* @__PURE__ */ React12.createElement(import_ui12.Stack, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React12.createElement(import_ui12.Stack, { width: "100%", direction: "row", gap: 1 }, /* @__PURE__ */ React12.createElement(import_editor_panels.PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React12.createElement(import_icons6.ColorFilterIcon, { fontSize: "inherit" }), (0, import_i18n9.__)("Variables Manager", "elementor"))), /* @__PURE__ */ React12.createElement(import_ui12.Stack, { direction: "row", gap: 0.5, alignItems: "center" }, /* @__PURE__ */ React12.createElement(
1759
+ VariableManagerCreateMenu,
1760
+ {
1761
+ onCreate: handleCreateVariable,
1762
+ variables,
1763
+ menuState: createMenuState
1764
+ }
1765
+ ), /* @__PURE__ */ React12.createElement(
1766
+ import_ui12.CloseButton,
1767
+ {
1768
+ "aria-label": "Close",
1769
+ slotProps: { icon: { fontSize: SIZE } },
1770
+ onClick: () => {
1771
+ handleClosePanel();
1772
+ }
1773
+ }
1774
+ ))), /* @__PURE__ */ React12.createElement(import_ui12.Stack, { width: "100%", direction: "row", gap: 1 }, /* @__PURE__ */ React12.createElement(
1775
+ import_editor_ui3.SearchField,
1776
+ {
1777
+ sx: {
1778
+ display: "flex",
1779
+ flex: 1
1780
+ },
1781
+ placeholder: (0, import_i18n9.__)("Search", "elementor"),
1782
+ value: searchValue,
1783
+ onSearch: handleSearch
1784
+ }
1785
+ )), /* @__PURE__ */ React12.createElement(import_ui12.Divider, { sx: { width: "100%" } }))
1786
+ ), /* @__PURE__ */ React12.createElement(
1027
1787
  import_editor_panels.PanelBody,
1028
1788
  {
1029
1789
  sx: {
@@ -1032,20 +1792,116 @@ function VariablesManagerPanel() {
1032
1792
  height: "100%"
1033
1793
  }
1034
1794
  },
1035
- /* @__PURE__ */ React8.createElement(
1795
+ hasVariables && /* @__PURE__ */ React12.createElement(
1036
1796
  VariablesManagerTable,
1037
1797
  {
1038
1798
  menuActions,
1039
1799
  variables,
1040
- onChange: handleOnChange
1800
+ onChange: handleOnChange,
1801
+ autoEditVariableId,
1802
+ onAutoEditComplete: handleAutoEditComplete,
1803
+ onFieldError: setIsSaveDisabled
1804
+ }
1805
+ ),
1806
+ !hasVariables && searchValue && /* @__PURE__ */ React12.createElement(
1807
+ NoSearchResults,
1808
+ {
1809
+ searchValue,
1810
+ onClear: () => handleSearch(""),
1811
+ icon: /* @__PURE__ */ React12.createElement(import_icons6.ColorFilterIcon, { fontSize: "large" })
1812
+ }
1813
+ ),
1814
+ !hasVariables && !searchValue && /* @__PURE__ */ React12.createElement(
1815
+ EmptyState,
1816
+ {
1817
+ title: (0, import_i18n9.__)("Create your first variable", "elementor"),
1818
+ message: (0, import_i18n9.__)(
1819
+ "Variables are saved attributes that you can apply anywhere on your site.",
1820
+ "elementor"
1821
+ ),
1822
+ icon: /* @__PURE__ */ React12.createElement(import_icons6.ColorFilterIcon, { fontSize: "large" }),
1823
+ onAdd: createMenuState.open
1041
1824
  }
1042
1825
  )
1043
- ), /* @__PURE__ */ React8.createElement(import_editor_panels.PanelFooter, null, /* @__PURE__ */ React8.createElement(import_ui8.Button, { fullWidth: true, size: "small", color: "global", variant: "contained", disabled: !isDirty }, (0, import_i18n5.__)("Save changes", "elementor"))))));
1826
+ ), /* @__PURE__ */ React12.createElement(import_editor_panels.PanelFooter, null, /* @__PURE__ */ React12.createElement(
1827
+ import_ui12.Infotip,
1828
+ {
1829
+ placement: "right",
1830
+ open: !!serverError,
1831
+ content: serverError ? /* @__PURE__ */ React12.createElement(
1832
+ import_ui12.Alert,
1833
+ {
1834
+ severity: serverError.severity ?? "error",
1835
+ action: serverError.action?.label ? /* @__PURE__ */ React12.createElement(import_ui12.AlertAction, { onClick: serverError.action.callback }, serverError.action.label) : void 0,
1836
+ onClose: !serverError.action?.label ? () => {
1837
+ setServerError(null);
1838
+ setIsSaveDisabled(false);
1839
+ } : void 0,
1840
+ icon: serverError.IconComponent ? /* @__PURE__ */ React12.createElement(serverError.IconComponent, null) : /* @__PURE__ */ React12.createElement(import_icons6.AlertTriangleFilledIcon, null)
1841
+ },
1842
+ /* @__PURE__ */ React12.createElement(import_ui12.AlertTitle, null, serverError.message),
1843
+ serverError.action?.message
1844
+ ) : null,
1845
+ arrow: false,
1846
+ slotProps: {
1847
+ popper: {
1848
+ modifiers: [
1849
+ {
1850
+ name: "offset",
1851
+ options: { offset: [-10, 10] }
1852
+ }
1853
+ ]
1854
+ }
1855
+ }
1856
+ },
1857
+ /* @__PURE__ */ React12.createElement(
1858
+ import_ui12.Button,
1859
+ {
1860
+ fullWidth: true,
1861
+ size: "small",
1862
+ color: "global",
1863
+ variant: "contained",
1864
+ disabled: isSaveDisabled || !isDirty || isSaving,
1865
+ onClick: handleSaveClick,
1866
+ loading: isSaving
1867
+ },
1868
+ (0, import_i18n9.__)("Save changes", "elementor")
1869
+ )
1870
+ ))), deleteConfirmation && /* @__PURE__ */ React12.createElement(
1871
+ DeleteConfirmationDialog,
1872
+ {
1873
+ open: true,
1874
+ label: deleteConfirmation.label,
1875
+ onConfirm: () => handleDeleteVariableWithConfirmation(deleteConfirmation.id),
1876
+ closeDialog: () => setDeleteConfirmation(null)
1877
+ }
1878
+ ), isSaveChangesDialogOpen && /* @__PURE__ */ React12.createElement(import_editor_ui3.SaveChangesDialog, null, /* @__PURE__ */ React12.createElement(import_editor_ui3.SaveChangesDialog.Title, { onClose: closeSaveChangesDialog }, (0, import_i18n9.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React12.createElement(import_editor_ui3.SaveChangesDialog.Content, null, /* @__PURE__ */ React12.createElement(import_editor_ui3.SaveChangesDialog.ContentText, null, (0, import_i18n9.__)("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React12.createElement(
1879
+ import_editor_ui3.SaveChangesDialog.Actions,
1880
+ {
1881
+ actions: {
1882
+ discard: {
1883
+ label: (0, import_i18n9.__)("Discard", "elementor"),
1884
+ action: () => {
1885
+ closeSaveChangesDialog();
1886
+ closePanel();
1887
+ }
1888
+ },
1889
+ confirm: {
1890
+ label: (0, import_i18n9.__)("Save", "elementor"),
1891
+ action: async () => {
1892
+ const result = await handleSaveClick();
1893
+ closeSaveChangesDialog();
1894
+ if (result?.success) {
1895
+ closePanel();
1896
+ }
1897
+ }
1898
+ }
1899
+ }
1900
+ }
1901
+ )));
1044
1902
  }
1045
- var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React8.createElement(import_ui8.IconButton, { size: "small", color: "secondary", onClick: onClose, "aria-label": "Close", ...props }, /* @__PURE__ */ React8.createElement(import_icons3.XIcon, { fontSize: "small" }));
1046
- var ErrorBoundaryFallback = () => /* @__PURE__ */ React8.createElement(import_ui8.Box, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React8.createElement(import_ui8.Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React8.createElement("strong", null, (0, import_i18n5.__)("Something went wrong", "elementor"))));
1047
1903
  var usePreventUnload = (isDirty) => {
1048
- (0, import_react7.useEffect)(() => {
1904
+ (0, import_react11.useEffect)(() => {
1049
1905
  const handleBeforeUnload = (event) => {
1050
1906
  if (isDirty) {
1051
1907
  event.preventDefault();
@@ -1059,15 +1915,15 @@ var usePreventUnload = (isDirty) => {
1059
1915
  };
1060
1916
 
1061
1917
  // src/controls/variable-control.tsx
1062
- var React32 = __toESM(require("react"));
1918
+ var React31 = __toESM(require("react"));
1063
1919
  var import_editor_controls11 = require("@elementor/editor-controls");
1064
1920
 
1065
1921
  // src/components/ui/variable/assigned-variable.tsx
1066
- var import_react14 = require("react");
1067
- var React21 = __toESM(require("react"));
1922
+ var import_react18 = require("react");
1923
+ var React22 = __toESM(require("react"));
1068
1924
  var import_editor_controls6 = require("@elementor/editor-controls");
1069
- var import_icons11 = require("@elementor/icons");
1070
- var import_ui21 = require("@elementor/ui");
1925
+ var import_icons13 = require("@elementor/icons");
1926
+ var import_ui22 = require("@elementor/ui");
1071
1927
 
1072
1928
  // src/utils/unlink-variable.ts
1073
1929
  function transformValueBeforeUnlink(variable, propTypeKey) {
@@ -1086,96 +1942,91 @@ function createUnlinkHandler(variable, propTypeKey, setValue) {
1086
1942
  }
1087
1943
 
1088
1944
  // src/components/variable-selection-popover.tsx
1089
- var React19 = __toESM(require("react"));
1090
- var import_react13 = require("react");
1945
+ var React20 = __toESM(require("react"));
1946
+ var import_react17 = require("react");
1091
1947
  var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
1092
1948
 
1093
1949
  // src/context/variable-selection-popover.context.tsx
1094
- var React9 = __toESM(require("react"));
1095
- var import_react8 = require("react");
1096
- var import_ui9 = require("@elementor/ui");
1097
- var PopoverContentRefContext = (0, import_react8.createContext)(null);
1950
+ var React13 = __toESM(require("react"));
1951
+ var import_react12 = require("react");
1952
+ var import_ui13 = require("@elementor/ui");
1953
+ var PopoverContentRefContext = (0, import_react12.createContext)(null);
1098
1954
  var PopoverContentRefContextProvider = ({ children }) => {
1099
- const [anchorRef, setAnchorRef] = (0, import_react8.useState)(null);
1100
- return /* @__PURE__ */ React9.createElement(PopoverContentRefContext.Provider, { value: anchorRef }, /* @__PURE__ */ React9.createElement(import_ui9.Box, { ref: setAnchorRef }, children));
1955
+ const [anchorRef, setAnchorRef] = (0, import_react12.useState)(null);
1956
+ return /* @__PURE__ */ React13.createElement(PopoverContentRefContext.Provider, { value: anchorRef }, /* @__PURE__ */ React13.createElement(import_ui13.Box, { ref: setAnchorRef }, children));
1101
1957
  };
1102
1958
  var usePopoverContentRef = () => {
1103
- return (0, import_react8.useContext)(PopoverContentRefContext);
1104
- };
1105
-
1106
- // src/hooks/use-permissions.ts
1107
- var import_editor_current_user = require("@elementor/editor-current-user");
1108
- var usePermissions = () => {
1109
- const { canUser } = (0, import_editor_current_user.useCurrentUserCapabilities)();
1110
- return {
1111
- canAssign: () => canUser("edit_posts"),
1112
- canUnlink: () => canUser("edit_posts"),
1113
- canAdd: () => canUser("manage_options"),
1114
- canDelete: () => canUser("manage_options"),
1115
- canEdit: () => canUser("manage_options"),
1116
- canRestore: () => canUser("manage_options"),
1117
- canManageSettings: () => canUser("manage_options")
1118
- };
1959
+ return (0, import_react12.useContext)(PopoverContentRefContext);
1119
1960
  };
1120
1961
 
1121
1962
  // src/components/variable-creation.tsx
1122
- var React11 = __toESM(require("react"));
1123
- var import_react9 = require("react");
1124
- var import_editor_controls3 = require("@elementor/editor-controls");
1963
+ var React15 = __toESM(require("react"));
1964
+ var import_react13 = require("react");
1965
+ var import_editor_controls4 = require("@elementor/editor-controls");
1125
1966
  var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
1126
- var import_editor_ui3 = require("@elementor/editor-ui");
1127
- var import_icons4 = require("@elementor/icons");
1128
- var import_ui11 = require("@elementor/ui");
1129
- var import_i18n6 = require("@wordpress/i18n");
1967
+ var import_editor_ui4 = require("@elementor/editor-ui");
1968
+ var import_icons7 = require("@elementor/icons");
1969
+ var import_ui15 = require("@elementor/ui");
1970
+ var import_i18n10 = require("@wordpress/i18n");
1130
1971
 
1131
1972
  // src/hooks/use-initial-value.ts
1132
1973
  var import_editor_controls2 = require("@elementor/editor-controls");
1133
1974
  var useInitialValue = () => {
1134
1975
  const { value: initial } = (0, import_editor_controls2.useBoundProp)();
1135
- const hasAssignedVariable2 = hasVariableType(initial?.$$type) && Boolean(initial?.value);
1136
- const variable = useVariable(hasAssignedVariable2 ? initial.value : "");
1137
- if (hasAssignedVariable2) {
1976
+ const hasAssignedVariable = hasVariableType(initial?.$$type) && Boolean(initial?.value);
1977
+ const variable = useVariable(hasAssignedVariable ? initial.value : "");
1978
+ if (hasAssignedVariable) {
1138
1979
  return variable ? variable.value : "";
1139
1980
  }
1140
1981
  return initial?.value ?? "";
1141
1982
  };
1142
1983
 
1143
- // src/utils/tracking.ts
1144
- var trackVariableEvent = ({ varType, controlPath, action }) => {
1145
- const extendedWindow = window;
1146
- const config = extendedWindow?.elementorCommon?.eventsManager?.config;
1147
- if (!config?.names?.variables?.[action]) {
1148
- return;
1984
+ // src/hooks/use-variable-bound-prop.ts
1985
+ var import_editor_controls3 = require("@elementor/editor-controls");
1986
+ var import_editor_props3 = require("@elementor/editor-props");
1987
+ var useVariableBoundProp = () => {
1988
+ const { propTypeUtil } = useVariableType();
1989
+ const boundProp = (0, import_editor_controls3.useBoundProp)(propTypeUtil);
1990
+ return {
1991
+ ...boundProp,
1992
+ setVariableValue: (value) => resolveBoundPropAndSetValue(value, boundProp),
1993
+ variableId: boundProp.value ?? boundProp.placeholder
1994
+ };
1995
+ };
1996
+ var resolveBoundPropAndSetValue = (value, boundProp) => {
1997
+ const propValue = unwrapValue(boundProp.value);
1998
+ const placeholder = unwrapValue(boundProp.placeholder);
1999
+ const newValue = unwrapValue(value);
2000
+ if (!propValue && placeholder === newValue) {
2001
+ return boundProp.setValue(null);
1149
2002
  }
1150
- const name = config.names.variables[action];
1151
- extendedWindow.elementorCommon?.eventsManager?.dispatchEvent(name, {
1152
- location: config.locations.variables,
1153
- secondaryLocation: config.secondaryLocations.variablesPopover,
1154
- trigger: config.triggers.click,
1155
- var_type: varType,
1156
- control_path: controlPath,
1157
- action_type: name
1158
- });
2003
+ return boundProp.setValue(value);
2004
+ };
2005
+ var unwrapValue = (input) => {
2006
+ if ((0, import_editor_props3.isTransformable)(input)) {
2007
+ return input.value;
2008
+ }
2009
+ return input;
1159
2010
  };
1160
2011
 
1161
2012
  // src/components/ui/form-field.tsx
1162
- var React10 = __toESM(require("react"));
1163
- var import_ui10 = require("@elementor/ui");
2013
+ var React14 = __toESM(require("react"));
2014
+ var import_ui14 = require("@elementor/ui");
1164
2015
  var FormField = ({ id: id2, label, errorMsg, noticeMsg, children }) => {
1165
- return /* @__PURE__ */ React10.createElement(import_ui10.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React10.createElement(import_ui10.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React10.createElement(import_ui10.FormLabel, { htmlFor: id2, size: "tiny" }, label)), /* @__PURE__ */ React10.createElement(import_ui10.Grid, { item: true, xs: 12 }, children, errorMsg && /* @__PURE__ */ React10.createElement(import_ui10.FormHelperText, { error: true }, errorMsg), noticeMsg && /* @__PURE__ */ React10.createElement(import_ui10.FormHelperText, null, noticeMsg)));
2016
+ return /* @__PURE__ */ React14.createElement(import_ui14.Grid, { container: true, gap: 0.75, alignItems: "center" }, /* @__PURE__ */ React14.createElement(import_ui14.Grid, { item: true, xs: 12 }, /* @__PURE__ */ React14.createElement(import_ui14.FormLabel, { htmlFor: id2, size: "tiny" }, label)), /* @__PURE__ */ React14.createElement(import_ui14.Grid, { item: true, xs: 12 }, children, errorMsg && /* @__PURE__ */ React14.createElement(import_ui14.FormHelperText, { error: true }, errorMsg), noticeMsg && /* @__PURE__ */ React14.createElement(import_ui14.FormHelperText, null, noticeMsg)));
1166
2017
  };
1167
2018
 
1168
2019
  // src/components/variable-creation.tsx
1169
- var SIZE = "tiny";
2020
+ var SIZE2 = "tiny";
1170
2021
  var VariableCreation = ({ onGoBack, onClose }) => {
1171
2022
  const { icon: VariableIcon, valueField: ValueField, variableType, propTypeUtil } = useVariableType();
1172
- const { setValue: setVariable, path } = (0, import_editor_controls3.useBoundProp)(propTypeUtil);
1173
- const { propType } = (0, import_editor_controls3.useBoundProp)();
2023
+ const { setVariableValue: setVariable, path } = useVariableBoundProp();
2024
+ const { propType } = (0, import_editor_controls4.useBoundProp)();
1174
2025
  const initialValue = useInitialValue();
1175
- const [value, setValue] = (0, import_react9.useState)(initialValue);
1176
- const [label, setLabel] = (0, import_react9.useState)("");
1177
- const [errorMessage, setErrorMessage] = (0, import_react9.useState)("");
1178
- const [valueFieldError, setValueFieldError] = (0, import_react9.useState)("");
2026
+ const [value, setValue] = (0, import_react13.useState)(initialValue);
2027
+ const [label, setLabel] = (0, import_react13.useState)("");
2028
+ const [errorMessage, setErrorMessage] = (0, import_react13.useState)("");
2029
+ const [valueFieldError, setValueFieldError] = (0, import_react13.useState)("");
1179
2030
  const { labelFieldError, setLabelFieldError } = useLabelError();
1180
2031
  const resetFields = () => {
1181
2032
  setValue("");
@@ -1226,22 +2077,22 @@ var VariableCreation = ({ onGoBack, onClose }) => {
1226
2077
  return !!errorMessage;
1227
2078
  };
1228
2079
  const isSubmitDisabled = hasEmptyFields() || hasErrors();
1229
- return /* @__PURE__ */ React11.createElement(import_editor_editing_panel2.PopoverBody, { height: "auto" }, /* @__PURE__ */ React11.createElement(
1230
- import_editor_ui3.PopoverHeader,
2080
+ return /* @__PURE__ */ React15.createElement(import_editor_editing_panel2.PopoverBody, { height: "auto" }, /* @__PURE__ */ React15.createElement(
2081
+ import_editor_ui4.PopoverHeader,
1231
2082
  {
1232
- icon: /* @__PURE__ */ React11.createElement(React11.Fragment, null, onGoBack && /* @__PURE__ */ React11.createElement(import_ui11.IconButton, { size: SIZE, "aria-label": (0, import_i18n6.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React11.createElement(import_icons4.ArrowLeftIcon, { fontSize: SIZE })), /* @__PURE__ */ React11.createElement(VariableIcon, { fontSize: SIZE })),
1233
- title: (0, import_i18n6.__)("Create variable", "elementor"),
2083
+ icon: /* @__PURE__ */ React15.createElement(React15.Fragment, null, onGoBack && /* @__PURE__ */ React15.createElement(import_ui15.IconButton, { size: SIZE2, "aria-label": (0, import_i18n10.__)("Go Back", "elementor"), onClick: onGoBack }, /* @__PURE__ */ React15.createElement(import_icons7.ArrowLeftIcon, { fontSize: SIZE2 })), /* @__PURE__ */ React15.createElement(VariableIcon, { fontSize: SIZE2 })),
2084
+ title: (0, import_i18n10.__)("Create variable", "elementor"),
1234
2085
  onClose: closePopover
1235
2086
  }
1236
- ), /* @__PURE__ */ React11.createElement(import_ui11.Divider, null), /* @__PURE__ */ React11.createElement(import_editor_controls3.PopoverContent, { p: 2 }, /* @__PURE__ */ React11.createElement(
2087
+ ), /* @__PURE__ */ React15.createElement(import_ui15.Divider, null), /* @__PURE__ */ React15.createElement(import_editor_controls4.PopoverContent, { p: 2 }, /* @__PURE__ */ React15.createElement(
1237
2088
  FormField,
1238
2089
  {
1239
2090
  id: "variable-label",
1240
- label: (0, import_i18n6.__)("Name", "elementor"),
2091
+ label: (0, import_i18n10.__)("Name", "elementor"),
1241
2092
  errorMsg: labelFieldError?.message,
1242
2093
  noticeMsg: labelHint(label)
1243
2094
  },
1244
- /* @__PURE__ */ React11.createElement(
2095
+ /* @__PURE__ */ React15.createElement(
1245
2096
  LabelField,
1246
2097
  {
1247
2098
  id: "variable-label",
@@ -1259,7 +2110,7 @@ var VariableCreation = ({ onGoBack, onClose }) => {
1259
2110
  }
1260
2111
  }
1261
2112
  )
1262
- ), /* @__PURE__ */ React11.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n6.__)("Value", "elementor") }, /* @__PURE__ */ React11.createElement(import_ui11.Typography, { variant: "h5" }, /* @__PURE__ */ React11.createElement(
2113
+ ), /* @__PURE__ */ React15.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n10.__)("Value", "elementor") }, /* @__PURE__ */ React15.createElement(import_ui15.Typography, { variant: "h5", id: "variable-value-wrapper" }, /* @__PURE__ */ React15.createElement(
1263
2114
  ValueField,
1264
2115
  {
1265
2116
  value,
@@ -1271,93 +2122,89 @@ var VariableCreation = ({ onGoBack, onClose }) => {
1271
2122
  onValidationChange: setValueFieldError,
1272
2123
  propType
1273
2124
  }
1274
- ))), errorMessage && /* @__PURE__ */ React11.createElement(import_ui11.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React11.createElement(import_ui11.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React11.createElement(import_ui11.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleCreateAndTrack }, (0, import_i18n6.__)("Create", "elementor"))));
2125
+ ))), errorMessage && /* @__PURE__ */ React15.createElement(import_ui15.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React15.createElement(import_ui15.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React15.createElement(
2126
+ import_ui15.Button,
2127
+ {
2128
+ id: "create-variable-button",
2129
+ size: "small",
2130
+ variant: "contained",
2131
+ disabled: isSubmitDisabled,
2132
+ onClick: handleCreateAndTrack
2133
+ },
2134
+ (0, import_i18n10.__)("Create", "elementor")
2135
+ )));
1275
2136
  };
1276
2137
 
1277
2138
  // src/components/variable-edit.tsx
1278
- var React14 = __toESM(require("react"));
1279
- var import_react11 = require("react");
1280
- var import_editor_controls4 = require("@elementor/editor-controls");
2139
+ var React17 = __toESM(require("react"));
2140
+ var import_react15 = require("react");
2141
+ var import_editor_controls5 = require("@elementor/editor-controls");
1281
2142
  var import_editor_current_user2 = require("@elementor/editor-current-user");
1282
2143
  var import_editor_editing_panel3 = require("@elementor/editor-editing-panel");
1283
- var import_editor_ui4 = require("@elementor/editor-ui");
1284
- var import_icons7 = require("@elementor/icons");
1285
- var import_ui14 = require("@elementor/ui");
1286
- var import_i18n9 = require("@wordpress/i18n");
1287
-
1288
- // src/components/ui/delete-confirmation-dialog.tsx
1289
- var React12 = __toESM(require("react"));
1290
- var import_icons5 = require("@elementor/icons");
1291
- var import_ui12 = require("@elementor/ui");
1292
- var import_i18n7 = require("@wordpress/i18n");
1293
- var TITLE_ID = "delete-variable-dialog";
1294
- var DeleteConfirmationDialog = ({
1295
- open,
1296
- label,
1297
- closeDialog,
1298
- onConfirm
1299
- }) => {
1300
- return /* @__PURE__ */ React12.createElement(import_ui12.Dialog, { open, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React12.createElement(import_ui12.DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React12.createElement(import_icons5.AlertOctagonFilledIcon, { color: "error" }), (0, import_i18n7.__)("Delete this variable?", "elementor")), /* @__PURE__ */ React12.createElement(import_ui12.DialogContent, null, /* @__PURE__ */ React12.createElement(import_ui12.DialogContentText, { variant: "body2", color: "textPrimary" }, (0, import_i18n7.__)("All elements using", "elementor"), "\xA0", /* @__PURE__ */ React12.createElement(import_ui12.Typography, { variant: "subtitle2", component: "span", sx: { lineBreak: "anywhere" } }, label), "\xA0", (0, import_i18n7.__)("will keep their current values, but the variable itself will be removed.", "elementor"))), /* @__PURE__ */ React12.createElement(import_ui12.DialogActions, null, /* @__PURE__ */ React12.createElement(import_ui12.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n7.__)("Not now", "elementor")), /* @__PURE__ */ React12.createElement(import_ui12.Button, { variant: "contained", color: "error", onClick: onConfirm }, (0, import_i18n7.__)("Delete", "elementor"))));
1301
- };
2144
+ var import_editor_ui5 = require("@elementor/editor-ui");
2145
+ var import_icons9 = require("@elementor/icons");
2146
+ var import_ui17 = require("@elementor/ui");
2147
+ var import_i18n12 = require("@wordpress/i18n");
1302
2148
 
1303
2149
  // src/components/ui/edit-confirmation-dialog.tsx
1304
- var React13 = __toESM(require("react"));
1305
- var import_react10 = require("react");
1306
- var import_icons6 = require("@elementor/icons");
1307
- var import_ui13 = require("@elementor/ui");
1308
- var import_i18n8 = require("@wordpress/i18n");
2150
+ var React16 = __toESM(require("react"));
2151
+ var import_react14 = require("react");
2152
+ var import_icons8 = require("@elementor/icons");
2153
+ var import_ui16 = require("@elementor/ui");
2154
+ var import_i18n11 = require("@wordpress/i18n");
1309
2155
  var EDIT_CONFIRMATION_DIALOG_ID = "edit-confirmation-dialog";
1310
2156
  var EditConfirmationDialog = ({
1311
2157
  closeDialog,
1312
2158
  onConfirm,
1313
2159
  onSuppressMessage
1314
2160
  }) => {
1315
- const [dontShowAgain, setDontShowAgain] = (0, import_react10.useState)(false);
2161
+ const [dontShowAgain, setDontShowAgain] = (0, import_react14.useState)(false);
1316
2162
  const handleSave = () => {
1317
2163
  if (dontShowAgain) {
1318
2164
  onSuppressMessage?.();
1319
2165
  }
1320
2166
  onConfirm?.();
1321
2167
  };
1322
- return /* @__PURE__ */ React13.createElement(import_ui13.Dialog, { open: true, onClose: closeDialog, maxWidth: "xs" }, /* @__PURE__ */ React13.createElement(import_ui13.DialogTitle, { display: "flex", alignItems: "center", gap: 1 }, /* @__PURE__ */ React13.createElement(import_icons6.AlertTriangleFilledIcon, { color: "secondary" }), (0, import_i18n8.__)("Changes to variables go live right away.", "elementor")), /* @__PURE__ */ React13.createElement(import_ui13.DialogContent, null, /* @__PURE__ */ React13.createElement(import_ui13.DialogContentText, { variant: "body2", color: "textPrimary" }, (0, import_i18n8.__)(
2168
+ return /* @__PURE__ */ React16.createElement(import_ui16.Dialog, { open: true, onClose: closeDialog, maxWidth: "xs" }, /* @__PURE__ */ React16.createElement(import_ui16.DialogTitle, { display: "flex", alignItems: "center", gap: 1 }, /* @__PURE__ */ React16.createElement(import_icons8.AlertTriangleFilledIcon, { color: "secondary" }), (0, import_i18n11.__)("Changes to variables go live right away.", "elementor")), /* @__PURE__ */ React16.createElement(import_ui16.DialogContent, null, /* @__PURE__ */ React16.createElement(import_ui16.DialogContentText, { variant: "body2", color: "textPrimary" }, (0, import_i18n11.__)(
1323
2169
  "Don't worry - all other changes you make will wait until you publish your site.",
1324
2170
  "elementor"
1325
- ))), /* @__PURE__ */ React13.createElement(import_ui13.DialogActions, { sx: { justifyContent: "space-between", alignItems: "center" } }, /* @__PURE__ */ React13.createElement(
1326
- import_ui13.FormControlLabel,
2171
+ ))), /* @__PURE__ */ React16.createElement(import_ui16.DialogActions, { sx: { justifyContent: "space-between", alignItems: "center" } }, /* @__PURE__ */ React16.createElement(
2172
+ import_ui16.FormControlLabel,
1327
2173
  {
1328
- control: /* @__PURE__ */ React13.createElement(
1329
- import_ui13.Checkbox,
2174
+ control: /* @__PURE__ */ React16.createElement(
2175
+ import_ui16.Checkbox,
1330
2176
  {
1331
2177
  checked: dontShowAgain,
1332
2178
  onChange: (event) => setDontShowAgain(event.target.checked),
1333
2179
  size: "small"
1334
2180
  }
1335
2181
  ),
1336
- label: /* @__PURE__ */ React13.createElement(import_ui13.Typography, { variant: "body2" }, (0, import_i18n8.__)("Don't show me again", "elementor"))
2182
+ label: /* @__PURE__ */ React16.createElement(import_ui16.Typography, { variant: "body2" }, (0, import_i18n11.__)("Don't show me again", "elementor"))
1337
2183
  }
1338
- ), /* @__PURE__ */ React13.createElement("div", null, /* @__PURE__ */ React13.createElement(import_ui13.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n8.__)("Keep editing", "elementor")), /* @__PURE__ */ React13.createElement(import_ui13.Button, { variant: "contained", color: "secondary", onClick: handleSave, sx: { ml: 1 } }, (0, import_i18n8.__)("Save", "elementor")))));
2184
+ ), /* @__PURE__ */ React16.createElement("div", null, /* @__PURE__ */ React16.createElement(import_ui16.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n11.__)("Keep editing", "elementor")), /* @__PURE__ */ React16.createElement(import_ui16.Button, { variant: "contained", color: "secondary", onClick: handleSave, sx: { ml: 1 } }, (0, import_i18n11.__)("Save", "elementor")))));
1339
2185
  };
1340
2186
 
1341
2187
  // src/components/variable-edit.tsx
1342
- var SIZE2 = "tiny";
2188
+ var SIZE3 = "tiny";
2189
+ var DELETE_LABEL = (0, import_i18n12.__)("Delete variable", "elementor");
1343
2190
  var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
1344
- const { icon: VariableIcon, valueField: ValueField, variableType, propTypeUtil } = useVariableType();
1345
- const { setValue: notifyBoundPropChange, value: assignedValue } = (0, import_editor_controls4.useBoundProp)(propTypeUtil);
1346
- const { propType } = (0, import_editor_controls4.useBoundProp)();
2191
+ const { icon: VariableIcon, valueField: ValueField, variableType } = useVariableType();
2192
+ const { setVariableValue: notifyBoundPropChange, variableId } = useVariableBoundProp();
2193
+ const { propType } = (0, import_editor_controls5.useBoundProp)();
1347
2194
  const [isMessageSuppressed, suppressMessage] = (0, import_editor_current_user2.useSuppressedMessage)(EDIT_CONFIRMATION_DIALOG_ID);
1348
- const [deleteConfirmation, setDeleteConfirmation] = (0, import_react11.useState)(false);
1349
- const [editConfirmation, setEditConfirmation] = (0, import_react11.useState)(false);
1350
- const [errorMessage, setErrorMessage] = (0, import_react11.useState)("");
1351
- const [valueFieldError, setValueFieldError] = (0, import_react11.useState)("");
2195
+ const [deleteConfirmation, setDeleteConfirmation] = (0, import_react15.useState)(false);
2196
+ const [editConfirmation, setEditConfirmation] = (0, import_react15.useState)(false);
2197
+ const [errorMessage, setErrorMessage] = (0, import_react15.useState)("");
2198
+ const [valueFieldError, setValueFieldError] = (0, import_react15.useState)("");
1352
2199
  const { labelFieldError, setLabelFieldError } = useLabelError();
1353
2200
  const variable = useVariable(editId);
1354
2201
  if (!variable) {
1355
2202
  throw new Error(`Global ${variableType} variable not found`);
1356
2203
  }
1357
2204
  const userPermissions = usePermissions();
1358
- const [value, setValue] = (0, import_react11.useState)(() => variable.value);
1359
- const [label, setLabel] = (0, import_react11.useState)(() => variable.label);
1360
- (0, import_react11.useEffect)(() => {
2205
+ const [value, setValue] = (0, import_react15.useState)(() => variable.value);
2206
+ const [label, setLabel] = (0, import_react15.useState)(() => variable.label);
2207
+ (0, import_react15.useEffect)(() => {
1361
2208
  styleVariablesRepository.update({
1362
2209
  [editId]: {
1363
2210
  ...variable,
@@ -1404,7 +2251,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
1404
2251
  });
1405
2252
  };
1406
2253
  const maybeTriggerBoundPropChange = () => {
1407
- if (editId === assignedValue) {
2254
+ if (editId === variableId) {
1408
2255
  notifyBoundPropChange(editId);
1409
2256
  }
1410
2257
  };
@@ -1420,16 +2267,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
1420
2267
  const actions = [];
1421
2268
  if (userPermissions.canDelete()) {
1422
2269
  actions.push(
1423
- /* @__PURE__ */ React14.createElement(
1424
- import_ui14.IconButton,
1425
- {
1426
- key: "delete",
1427
- size: SIZE2,
1428
- "aria-label": (0, import_i18n9.__)("Delete", "elementor"),
1429
- onClick: handleDeleteConfirmation
1430
- },
1431
- /* @__PURE__ */ React14.createElement(import_icons7.TrashIcon, { fontSize: SIZE2 })
1432
- )
2270
+ /* @__PURE__ */ React17.createElement(import_ui17.Tooltip, { key: "delete", placement: "top", title: DELETE_LABEL }, /* @__PURE__ */ React17.createElement(import_ui17.IconButton, { size: SIZE3, onClick: handleDeleteConfirmation, "aria-label": DELETE_LABEL }, /* @__PURE__ */ React17.createElement(import_icons9.TrashIcon, { fontSize: SIZE3 })))
1433
2271
  );
1434
2272
  }
1435
2273
  const hasEmptyFields = () => {
@@ -1448,31 +2286,31 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
1448
2286
  return !!errorMessage;
1449
2287
  };
1450
2288
  const isSubmitDisabled = noValueChanged() || hasEmptyFields() || hasErrors();
1451
- return /* @__PURE__ */ React14.createElement(React14.Fragment, null, /* @__PURE__ */ React14.createElement(import_editor_editing_panel3.PopoverBody, { height: "auto" }, /* @__PURE__ */ React14.createElement(
1452
- import_editor_ui4.PopoverHeader,
2289
+ return /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(import_editor_editing_panel3.PopoverBody, { height: "auto" }, /* @__PURE__ */ React17.createElement(
2290
+ import_editor_ui5.PopoverHeader,
1453
2291
  {
1454
- title: (0, import_i18n9.__)("Edit variable", "elementor"),
2292
+ title: (0, import_i18n12.__)("Edit variable", "elementor"),
1455
2293
  onClose,
1456
- icon: /* @__PURE__ */ React14.createElement(React14.Fragment, null, onGoBack && /* @__PURE__ */ React14.createElement(
1457
- import_ui14.IconButton,
2294
+ icon: /* @__PURE__ */ React17.createElement(React17.Fragment, null, onGoBack && /* @__PURE__ */ React17.createElement(
2295
+ import_ui17.IconButton,
1458
2296
  {
1459
- size: SIZE2,
1460
- "aria-label": (0, import_i18n9.__)("Go Back", "elementor"),
2297
+ size: SIZE3,
2298
+ "aria-label": (0, import_i18n12.__)("Go Back", "elementor"),
1461
2299
  onClick: onGoBack
1462
2300
  },
1463
- /* @__PURE__ */ React14.createElement(import_icons7.ArrowLeftIcon, { fontSize: SIZE2 })
1464
- ), /* @__PURE__ */ React14.createElement(VariableIcon, { fontSize: SIZE2 })),
2301
+ /* @__PURE__ */ React17.createElement(import_icons9.ArrowLeftIcon, { fontSize: SIZE3 })
2302
+ ), /* @__PURE__ */ React17.createElement(VariableIcon, { fontSize: SIZE3 })),
1465
2303
  actions
1466
2304
  }
1467
- ), /* @__PURE__ */ React14.createElement(import_ui14.Divider, null), /* @__PURE__ */ React14.createElement(import_editor_controls4.PopoverContent, { p: 2 }, /* @__PURE__ */ React14.createElement(
2305
+ ), /* @__PURE__ */ React17.createElement(import_ui17.Divider, null), /* @__PURE__ */ React17.createElement(import_editor_controls5.PopoverContent, { p: 2 }, /* @__PURE__ */ React17.createElement(
1468
2306
  FormField,
1469
2307
  {
1470
2308
  id: "variable-label",
1471
- label: (0, import_i18n9.__)("Name", "elementor"),
2309
+ label: (0, import_i18n12.__)("Name", "elementor"),
1472
2310
  errorMsg: labelFieldError?.message,
1473
2311
  noticeMsg: labelHint(label)
1474
2312
  },
1475
- /* @__PURE__ */ React14.createElement(
2313
+ /* @__PURE__ */ React17.createElement(
1476
2314
  LabelField,
1477
2315
  {
1478
2316
  id: "variable-label",
@@ -1490,7 +2328,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
1490
2328
  }
1491
2329
  }
1492
2330
  )
1493
- ), /* @__PURE__ */ React14.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n9.__)("Value", "elementor") }, /* @__PURE__ */ React14.createElement(import_ui14.Typography, { variant: "h5" }, /* @__PURE__ */ React14.createElement(
2331
+ ), /* @__PURE__ */ React17.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n12.__)("Value", "elementor") }, /* @__PURE__ */ React17.createElement(import_ui17.Typography, { variant: "h5" }, /* @__PURE__ */ React17.createElement(
1494
2332
  ValueField,
1495
2333
  {
1496
2334
  value,
@@ -1502,7 +2340,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
1502
2340
  onValidationChange: setValueFieldError,
1503
2341
  propType
1504
2342
  }
1505
- ))), errorMessage && /* @__PURE__ */ React14.createElement(import_ui14.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React14.createElement(import_ui14.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React14.createElement(import_ui14.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleUpdate }, (0, import_i18n9.__)("Save", "elementor")))), deleteConfirmation && /* @__PURE__ */ React14.createElement(
2343
+ ))), errorMessage && /* @__PURE__ */ React17.createElement(import_ui17.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React17.createElement(import_ui17.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React17.createElement(import_ui17.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleUpdate }, (0, import_i18n12.__)("Save", "elementor")))), deleteConfirmation && /* @__PURE__ */ React17.createElement(
1506
2344
  DeleteConfirmationDialog,
1507
2345
  {
1508
2346
  open: true,
@@ -1510,7 +2348,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
1510
2348
  onConfirm: handleDelete,
1511
2349
  closeDialog: closeDeleteDialog()
1512
2350
  }
1513
- ), editConfirmation && !isMessageSuppressed && /* @__PURE__ */ React14.createElement(
2351
+ ), editConfirmation && !isMessageSuppressed && /* @__PURE__ */ React17.createElement(
1514
2352
  EditConfirmationDialog,
1515
2353
  {
1516
2354
  closeDialog: closeEditDialog(),
@@ -1521,135 +2359,74 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
1521
2359
  };
1522
2360
 
1523
2361
  // src/components/variables-selection.tsx
1524
- var React18 = __toESM(require("react"));
1525
- var import_react12 = require("react");
1526
- var import_editor_controls5 = require("@elementor/editor-controls");
2362
+ var React19 = __toESM(require("react"));
2363
+ var import_react16 = require("react");
1527
2364
  var import_editor_editing_panel4 = require("@elementor/editor-editing-panel");
1528
- var import_editor_ui6 = require("@elementor/editor-ui");
1529
- var import_icons9 = require("@elementor/icons");
1530
- var import_ui19 = require("@elementor/ui");
1531
- var import_i18n13 = require("@wordpress/i18n");
2365
+ var import_editor_ui7 = require("@elementor/editor-ui");
2366
+ var import_icons11 = require("@elementor/icons");
2367
+ var import_ui20 = require("@elementor/ui");
2368
+ var import_i18n14 = require("@wordpress/i18n");
1532
2369
 
1533
2370
  // src/components/ui/menu-item-content.tsx
1534
- var React15 = __toESM(require("react"));
1535
- var import_editor_ui5 = require("@elementor/editor-ui");
1536
- var import_icons8 = require("@elementor/icons");
1537
- var import_ui15 = require("@elementor/ui");
1538
- var import_i18n10 = require("@wordpress/i18n");
1539
- var SIZE3 = "tiny";
2371
+ var React18 = __toESM(require("react"));
2372
+ var import_editor_ui6 = require("@elementor/editor-ui");
2373
+ var import_icons10 = require("@elementor/icons");
2374
+ var import_ui18 = require("@elementor/ui");
2375
+ var import_i18n13 = require("@wordpress/i18n");
2376
+ var SIZE4 = "tiny";
2377
+ var EDIT_LABEL = (0, import_i18n13.__)("Edit variable", "elementor");
1540
2378
  var MenuItemContent = ({ item }) => {
1541
2379
  const onEdit = item.onEdit;
1542
- return /* @__PURE__ */ React15.createElement(React15.Fragment, null, /* @__PURE__ */ React15.createElement(import_ui15.ListItemIcon, null, item.icon), /* @__PURE__ */ React15.createElement(
1543
- import_ui15.Box,
1544
- {
1545
- sx: {
1546
- flex: 1,
1547
- minWidth: 0,
1548
- display: "flex",
1549
- alignItems: "center",
1550
- gap: 1
1551
- }
1552
- },
1553
- /* @__PURE__ */ React15.createElement(
1554
- import_editor_ui5.EllipsisWithTooltip,
1555
- {
1556
- title: item.label || item.value,
1557
- as: import_ui15.Typography,
1558
- variant: "caption",
1559
- color: "text.primary",
1560
- sx: { marginTop: "1px", lineHeight: "2" },
1561
- maxWidth: "50%"
1562
- }
1563
- ),
1564
- item.secondaryText && /* @__PURE__ */ React15.createElement(
1565
- import_editor_ui5.EllipsisWithTooltip,
1566
- {
1567
- title: item.secondaryText,
1568
- as: import_ui15.Typography,
1569
- variant: "caption",
1570
- color: "text.tertiary",
1571
- sx: { marginTop: "1px", lineHeight: "1" },
1572
- maxWidth: "50%"
1573
- }
1574
- )
1575
- ), !!onEdit && /* @__PURE__ */ React15.createElement(
1576
- import_ui15.IconButton,
1577
- {
1578
- sx: { mx: 1, opacity: "0" },
1579
- onClick: (e) => {
1580
- e.stopPropagation();
1581
- onEdit(item.value);
1582
- },
1583
- "aria-label": (0, import_i18n10.__)("Edit", "elementor")
1584
- },
1585
- /* @__PURE__ */ React15.createElement(import_icons8.EditIcon, { color: "action", fontSize: SIZE3 })
1586
- ));
1587
- };
1588
-
1589
- // src/components/ui/no-search-results.tsx
1590
- var React16 = __toESM(require("react"));
1591
- var import_ui16 = require("@elementor/ui");
1592
- var import_i18n11 = require("@wordpress/i18n");
1593
- var NoSearchResults = ({ searchValue, onClear, icon }) => {
1594
- return /* @__PURE__ */ React16.createElement(
1595
- import_ui16.Stack,
1596
- {
1597
- gap: 1,
1598
- alignItems: "center",
1599
- justifyContent: "center",
1600
- height: "100%",
1601
- p: 2.5,
1602
- color: "text.secondary",
1603
- sx: { pb: 3.5 }
1604
- },
1605
- icon,
1606
- /* @__PURE__ */ React16.createElement(import_ui16.Typography, { align: "center", variant: "subtitle2" }, (0, import_i18n11.__)("Sorry, nothing matched", "elementor"), /* @__PURE__ */ React16.createElement("br", null), "\u201C", searchValue, "\u201D."),
1607
- /* @__PURE__ */ React16.createElement(import_ui16.Typography, { align: "center", variant: "caption", sx: { display: "flex", flexDirection: "column" } }, (0, import_i18n11.__)("Try something else.", "elementor"), /* @__PURE__ */ React16.createElement(import_ui16.Link, { color: "text.secondary", variant: "caption", component: "button", onClick: onClear }, (0, import_i18n11.__)("Clear & try again", "elementor")))
1608
- );
1609
- };
1610
-
1611
- // src/components/ui/no-variables.tsx
1612
- var React17 = __toESM(require("react"));
1613
- var import_ui17 = require("@elementor/ui");
1614
- var import_i18n12 = require("@wordpress/i18n");
1615
- var NoVariables = ({ icon, title, onAdd }) => {
1616
- const canAdd = usePermissions().canAdd();
1617
- return /* @__PURE__ */ React17.createElement(
1618
- import_ui17.Stack,
2380
+ return /* @__PURE__ */ React18.createElement(React18.Fragment, null, /* @__PURE__ */ React18.createElement(import_ui18.ListItemIcon, null, item.icon), /* @__PURE__ */ React18.createElement(
2381
+ import_ui18.Box,
1619
2382
  {
1620
- gap: 1,
1621
- alignItems: "center",
1622
- justifyContent: "center",
1623
- height: "100%",
1624
- color: "text.secondary",
1625
- sx: { p: 2.5, pb: 5.5 }
2383
+ sx: {
2384
+ flex: 1,
2385
+ minWidth: 0,
2386
+ display: "flex",
2387
+ alignItems: "center",
2388
+ gap: 1
2389
+ }
1626
2390
  },
1627
- icon,
1628
- canAdd ? /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(
1629
- NoVariablesContent,
2391
+ /* @__PURE__ */ React18.createElement(
2392
+ import_editor_ui6.EllipsisWithTooltip,
1630
2393
  {
1631
- title: title || (0, import_i18n12.__)("Create your first variable", "elementor"),
1632
- message: (0, import_i18n12.__)(
1633
- "Variables are saved attributes that you can apply anywhere on your site.",
1634
- "elementor"
1635
- )
2394
+ title: item.label || item.value,
2395
+ as: import_ui18.Typography,
2396
+ variant: "caption",
2397
+ color: "text.primary",
2398
+ sx: { marginTop: "1px", lineHeight: "2" },
2399
+ maxWidth: "50%"
1636
2400
  }
1637
- ), onAdd && /* @__PURE__ */ React17.createElement(import_ui17.Button, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, (0, import_i18n12.__)("Create a variable", "elementor"))) : /* @__PURE__ */ React17.createElement(
1638
- NoVariablesContent,
2401
+ ),
2402
+ item.secondaryText && /* @__PURE__ */ React18.createElement(
2403
+ import_editor_ui6.EllipsisWithTooltip,
1639
2404
  {
1640
- title: (0, import_i18n12.__)("There are no variables", "elementor"),
1641
- message: (0, import_i18n12.__)("With your current role, you can only connect and detach variables.", "elementor")
2405
+ title: item.secondaryText,
2406
+ as: import_ui18.Typography,
2407
+ variant: "caption",
2408
+ color: "text.tertiary",
2409
+ sx: { marginTop: "1px", lineHeight: "1" },
2410
+ maxWidth: "50%"
1642
2411
  }
1643
2412
  )
1644
- );
2413
+ ), !!onEdit && /* @__PURE__ */ React18.createElement(import_ui18.Tooltip, { placement: "top", title: EDIT_LABEL }, /* @__PURE__ */ React18.createElement(
2414
+ import_ui18.IconButton,
2415
+ {
2416
+ sx: { mx: 1, opacity: "0" },
2417
+ onClick: (e) => {
2418
+ e.stopPropagation();
2419
+ onEdit(item.value);
2420
+ },
2421
+ "aria-label": EDIT_LABEL
2422
+ },
2423
+ /* @__PURE__ */ React18.createElement(import_icons10.EditIcon, { color: "action", fontSize: SIZE4 })
2424
+ )));
1645
2425
  };
1646
- function NoVariablesContent({ title, message }) {
1647
- return /* @__PURE__ */ React17.createElement(React17.Fragment, null, /* @__PURE__ */ React17.createElement(import_ui17.Typography, { align: "center", variant: "subtitle2" }, title), /* @__PURE__ */ React17.createElement(import_ui17.Typography, { align: "center", variant: "caption", maxWidth: "180px" }, message));
1648
- }
1649
2426
 
1650
2427
  // src/components/ui/styled-menu-list.tsx
1651
- var import_ui18 = require("@elementor/ui");
1652
- var VariablesStyledMenuList = (0, import_ui18.styled)(import_ui18.MenuList)(({ theme }) => ({
2428
+ var import_ui19 = require("@elementor/ui");
2429
+ var VariablesStyledMenuList = (0, import_ui19.styled)(import_ui19.MenuList)(({ theme }) => ({
1653
2430
  "& > li": {
1654
2431
  height: 32,
1655
2432
  width: "100%",
@@ -1680,15 +2457,18 @@ var VariablesStyledMenuList = (0, import_ui18.styled)(import_ui18.MenuList)(({ t
1680
2457
  }));
1681
2458
 
1682
2459
  // src/components/variables-selection.tsx
1683
- var SIZE4 = "tiny";
2460
+ var SIZE5 = "tiny";
2461
+ var CREATE_LABEL = (0, import_i18n14.__)("Create variable", "elementor");
2462
+ var MANAGER_LABEL = (0, import_i18n14.__)("Variables Manager", "elementor");
1684
2463
  var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
1685
2464
  const { icon: VariableIcon, startIcon, variableType, propTypeUtil } = useVariableType();
1686
- const { value: variable, setValue: setVariable, path } = (0, import_editor_controls5.useBoundProp)(propTypeUtil);
1687
- const [searchValue, setSearchValue] = (0, import_react12.useState)("");
2465
+ const { value: variable, setValue: setVariable, path } = useVariableBoundProp();
2466
+ const [searchValue, setSearchValue] = (0, import_react16.useState)("");
1688
2467
  const {
1689
2468
  list: variables,
1690
2469
  hasMatches: hasSearchResults,
1691
- isSourceNotEmpty: hasVariables
2470
+ isSourceNotEmpty: hasVariables,
2471
+ hasNoCompatibleVariables
1692
2472
  } = useFilteredVariables(searchValue, propTypeUtil.key);
1693
2473
  const handleSetVariable = (key) => {
1694
2474
  setVariable(key);
@@ -1710,20 +2490,46 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
1710
2490
  const actions = [];
1711
2491
  if (onAdd) {
1712
2492
  actions.push(
1713
- /* @__PURE__ */ React18.createElement(import_ui19.IconButton, { key: "add", size: SIZE4, onClick: onAddAndTrack }, /* @__PURE__ */ React18.createElement(import_icons9.PlusIcon, { fontSize: SIZE4 }))
2493
+ /* @__PURE__ */ React19.createElement(import_ui20.Tooltip, { key: "add", placement: "top", title: CREATE_LABEL }, /* @__PURE__ */ React19.createElement(
2494
+ import_ui20.IconButton,
2495
+ {
2496
+ id: "add-variable-button",
2497
+ size: SIZE5,
2498
+ onClick: onAddAndTrack,
2499
+ "aria-label": CREATE_LABEL
2500
+ },
2501
+ /* @__PURE__ */ React19.createElement(import_icons11.PlusIcon, { fontSize: SIZE5 })
2502
+ ))
1714
2503
  );
1715
2504
  }
1716
2505
  if (onSettings) {
2506
+ const handleOpenManager = () => {
2507
+ onSettings();
2508
+ trackVariablesManagerEvent({
2509
+ action: "openManager",
2510
+ varType: variableType,
2511
+ controlPath: path.join(".")
2512
+ });
2513
+ };
1717
2514
  actions.push(
1718
- /* @__PURE__ */ React18.createElement(import_ui19.IconButton, { key: "settings", size: SIZE4, onClick: onSettings }, /* @__PURE__ */ React18.createElement(import_icons9.SettingsIcon, { fontSize: SIZE4 }))
2515
+ /* @__PURE__ */ React19.createElement(import_ui20.Tooltip, { key: "settings", placement: "top", title: MANAGER_LABEL }, /* @__PURE__ */ React19.createElement(
2516
+ import_ui20.IconButton,
2517
+ {
2518
+ id: "variables-manager-button",
2519
+ size: SIZE5,
2520
+ onClick: handleOpenManager,
2521
+ "aria-label": MANAGER_LABEL
2522
+ },
2523
+ /* @__PURE__ */ React19.createElement(import_icons11.SettingsIcon, { fontSize: SIZE5 })
2524
+ ))
1719
2525
  );
1720
2526
  }
1721
- const StartIcon = startIcon || (() => /* @__PURE__ */ React18.createElement(VariableIcon, { fontSize: SIZE4 }));
2527
+ const StartIcon = startIcon || (() => /* @__PURE__ */ React19.createElement(VariableIcon, { fontSize: SIZE5 }));
1722
2528
  const items = variables.map(({ value, label, key }) => ({
1723
2529
  type: "item",
1724
2530
  value: key,
1725
2531
  label,
1726
- icon: /* @__PURE__ */ React18.createElement(StartIcon, { value }),
2532
+ icon: /* @__PURE__ */ React19.createElement(StartIcon, { value }),
1727
2533
  secondaryText: value,
1728
2534
  onEdit: onEdit ? () => onEdit?.(key) : void 0
1729
2535
  }));
@@ -1733,28 +2539,28 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
1733
2539
  const handleClearSearch = () => {
1734
2540
  setSearchValue("");
1735
2541
  };
1736
- const noVariableTitle = (0, import_i18n13.sprintf)(
2542
+ const noVariableTitle = (0, import_i18n14.sprintf)(
1737
2543
  /* translators: %s: Variable Type. */
1738
- (0, import_i18n13.__)("Create your first %s variable", "elementor"),
2544
+ (0, import_i18n14.__)("Create your first %s variable", "elementor"),
1739
2545
  variableType
1740
2546
  );
1741
- return /* @__PURE__ */ React18.createElement(import_editor_editing_panel4.PopoverBody, null, /* @__PURE__ */ React18.createElement(
1742
- import_editor_ui6.PopoverHeader,
2547
+ return /* @__PURE__ */ React19.createElement(import_editor_editing_panel4.PopoverBody, null, /* @__PURE__ */ React19.createElement(
2548
+ import_editor_ui7.PopoverHeader,
1743
2549
  {
1744
- title: (0, import_i18n13.__)("Variables", "elementor"),
1745
- icon: /* @__PURE__ */ React18.createElement(import_icons9.ColorFilterIcon, { fontSize: SIZE4 }),
2550
+ title: (0, import_i18n14.__)("Variables", "elementor"),
2551
+ icon: /* @__PURE__ */ React19.createElement(import_icons11.ColorFilterIcon, { fontSize: SIZE5 }),
1746
2552
  onClose: closePopover,
1747
2553
  actions
1748
2554
  }
1749
- ), hasVariables && /* @__PURE__ */ React18.createElement(
1750
- import_editor_ui6.PopoverSearch,
2555
+ ), hasVariables && /* @__PURE__ */ React19.createElement(
2556
+ import_editor_ui7.SearchField,
1751
2557
  {
1752
2558
  value: searchValue,
1753
2559
  onSearch: handleSearch,
1754
- placeholder: (0, import_i18n13.__)("Search", "elementor")
2560
+ placeholder: (0, import_i18n14.__)("Search", "elementor")
1755
2561
  }
1756
- ), /* @__PURE__ */ React18.createElement(import_ui19.Divider, null), hasVariables && hasSearchResults && /* @__PURE__ */ React18.createElement(
1757
- import_editor_ui6.PopoverMenuList,
2562
+ ), /* @__PURE__ */ React19.createElement(import_ui20.Divider, null), hasVariables && hasSearchResults && /* @__PURE__ */ React19.createElement(
2563
+ import_editor_ui7.PopoverMenuList,
1758
2564
  {
1759
2565
  items,
1760
2566
  onSelect: handleSetVariable,
@@ -1763,16 +2569,38 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
1763
2569
  selectedValue: variable,
1764
2570
  "data-testid": `${variableType}-variables-list`,
1765
2571
  menuListTemplate: VariablesStyledMenuList,
1766
- menuItemContentTemplate: (item) => /* @__PURE__ */ React18.createElement(MenuItemContent, { item })
2572
+ menuItemContentTemplate: (item) => /* @__PURE__ */ React19.createElement(MenuItemContent, { item })
1767
2573
  }
1768
- ), !hasSearchResults && hasVariables && /* @__PURE__ */ React18.createElement(
2574
+ ), !hasSearchResults && hasVariables && /* @__PURE__ */ React19.createElement(
1769
2575
  NoSearchResults,
1770
2576
  {
1771
2577
  searchValue,
1772
2578
  onClear: handleClearSearch,
1773
- icon: /* @__PURE__ */ React18.createElement(VariableIcon, { fontSize: "large" })
2579
+ icon: /* @__PURE__ */ React19.createElement(VariableIcon, { fontSize: "large" })
2580
+ }
2581
+ ), !hasVariables && !hasNoCompatibleVariables && /* @__PURE__ */ React19.createElement(
2582
+ EmptyState,
2583
+ {
2584
+ title: noVariableTitle,
2585
+ message: (0, import_i18n14.__)(
2586
+ "Variables are saved attributes that you can apply anywhere on your site.",
2587
+ "elementor"
2588
+ ),
2589
+ icon: /* @__PURE__ */ React19.createElement(VariableIcon, { fontSize: "large" }),
2590
+ onAdd
2591
+ }
2592
+ ), hasNoCompatibleVariables && /* @__PURE__ */ React19.createElement(
2593
+ EmptyState,
2594
+ {
2595
+ title: (0, import_i18n14.__)("No compatible variables", "elementor"),
2596
+ message: (0, import_i18n14.__)(
2597
+ "Looks like none of your variables work with this control. Create a new variable to use it here.",
2598
+ "elementor"
2599
+ ),
2600
+ icon: /* @__PURE__ */ React19.createElement(VariableIcon, { fontSize: "large" }),
2601
+ onAdd
1774
2602
  }
1775
- ), !hasVariables && /* @__PURE__ */ React18.createElement(NoVariables, { title: noVariableTitle, icon: /* @__PURE__ */ React18.createElement(VariableIcon, { fontSize: "large" }), onAdd }));
2603
+ ));
1776
2604
  };
1777
2605
 
1778
2606
  // src/components/variable-selection-popover.tsx
@@ -1780,13 +2608,13 @@ var VIEW_LIST = "list";
1780
2608
  var VIEW_ADD = "add";
1781
2609
  var VIEW_EDIT = "edit";
1782
2610
  var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
1783
- const [currentView, setCurrentView] = (0, import_react13.useState)(VIEW_LIST);
1784
- const [editId, setEditId] = (0, import_react13.useState)("");
2611
+ const [currentView, setCurrentView] = (0, import_react17.useState)(VIEW_LIST);
2612
+ const [editId, setEditId] = (0, import_react17.useState)("");
1785
2613
  const { open } = usePanelActions();
1786
2614
  const onSettingsAvailable = (0, import_editor_v1_adapters2.isExperimentActive)("e_variables_manager") ? () => {
1787
2615
  open();
1788
2616
  } : void 0;
1789
- return /* @__PURE__ */ React19.createElement(VariableTypeProvider, { propTypeKey }, /* @__PURE__ */ React19.createElement(PopoverContentRefContextProvider, null, RenderView({
2617
+ return /* @__PURE__ */ React20.createElement(VariableTypeProvider, { propTypeKey }, /* @__PURE__ */ React20.createElement(PopoverContentRefContextProvider, null, RenderView({
1790
2618
  propTypeKey,
1791
2619
  currentView,
1792
2620
  selectedVariable,
@@ -1832,7 +2660,7 @@ function RenderView(props) {
1832
2660
  }
1833
2661
  };
1834
2662
  if (VIEW_LIST === props.currentView) {
1835
- return /* @__PURE__ */ React19.createElement(
2663
+ return /* @__PURE__ */ React20.createElement(
1836
2664
  VariablesSelection,
1837
2665
  {
1838
2666
  closePopover: handlers.onClose,
@@ -1843,10 +2671,10 @@ function RenderView(props) {
1843
2671
  );
1844
2672
  }
1845
2673
  if (VIEW_ADD === props.currentView) {
1846
- return /* @__PURE__ */ React19.createElement(VariableCreation, { onGoBack: handlers.onGoBack, onClose: handlers.onClose });
2674
+ return /* @__PURE__ */ React20.createElement(VariableCreation, { onGoBack: handlers.onGoBack, onClose: handlers.onClose });
1847
2675
  }
1848
2676
  if (VIEW_EDIT === props.currentView) {
1849
- return /* @__PURE__ */ React19.createElement(
2677
+ return /* @__PURE__ */ React20.createElement(
1850
2678
  VariableEdit,
1851
2679
  {
1852
2680
  editId: props.editId,
@@ -1860,25 +2688,26 @@ function RenderView(props) {
1860
2688
  }
1861
2689
 
1862
2690
  // src/components/ui/tags/assigned-tag.tsx
1863
- var React20 = __toESM(require("react"));
1864
- var import_icons10 = require("@elementor/icons");
1865
- var import_ui20 = require("@elementor/ui");
1866
- var import_i18n14 = require("@wordpress/i18n");
1867
- var SIZE5 = "tiny";
2691
+ var React21 = __toESM(require("react"));
2692
+ var import_icons12 = require("@elementor/icons");
2693
+ var import_ui21 = require("@elementor/ui");
2694
+ var import_i18n15 = require("@wordpress/i18n");
2695
+ var SIZE6 = "tiny";
2696
+ var UNLINK_LABEL = (0, import_i18n15.__)("Unlink variable", "elementor");
1868
2697
  var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
1869
2698
  const actions = [];
1870
2699
  if (onUnlink) {
1871
2700
  actions.push(
1872
- /* @__PURE__ */ React20.createElement(import_ui20.IconButton, { key: "unlink", size: SIZE5, onClick: onUnlink, "aria-label": (0, import_i18n14.__)("Unlink", "elementor") }, /* @__PURE__ */ React20.createElement(import_icons10.DetachIcon, { fontSize: SIZE5 }))
2701
+ /* @__PURE__ */ React21.createElement(import_ui21.Tooltip, { key: "unlink", title: UNLINK_LABEL, placement: "bottom" }, /* @__PURE__ */ React21.createElement(import_ui21.IconButton, { size: SIZE6, onClick: onUnlink, "aria-label": UNLINK_LABEL }, /* @__PURE__ */ React21.createElement(import_icons12.DetachIcon, { fontSize: SIZE6 })))
1873
2702
  );
1874
2703
  }
1875
- return /* @__PURE__ */ React20.createElement(import_ui20.Tooltip, { title: label, placement: "top" }, /* @__PURE__ */ React20.createElement(
1876
- import_ui20.UnstableTag,
2704
+ return /* @__PURE__ */ React21.createElement(import_ui21.Tooltip, { title: label, placement: "top" }, /* @__PURE__ */ React21.createElement(
2705
+ import_ui21.UnstableTag,
1877
2706
  {
1878
2707
  fullWidth: true,
1879
2708
  showActionsOnHover: true,
1880
- startIcon: /* @__PURE__ */ React20.createElement(import_ui20.Stack, { gap: 0.5, direction: "row", alignItems: "center" }, startIcon),
1881
- label: /* @__PURE__ */ React20.createElement(import_ui20.Box, { sx: { display: "inline-grid", minWidth: 0 } }, /* @__PURE__ */ React20.createElement(import_ui20.Typography, { sx: { lineHeight: 1.34 }, variant: "caption", noWrap: true }, label)),
2709
+ startIcon: /* @__PURE__ */ React21.createElement(import_ui21.Stack, { gap: 0.5, direction: "row", alignItems: "center" }, startIcon),
2710
+ label: /* @__PURE__ */ React21.createElement(import_ui21.Box, { sx: { display: "inline-grid", minWidth: 0 } }, /* @__PURE__ */ React21.createElement(import_ui21.Typography, { sx: { lineHeight: 1.34 }, variant: "caption", noWrap: true }, label)),
1882
2711
  actions,
1883
2712
  ...props
1884
2713
  }
@@ -1889,24 +2718,24 @@ var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
1889
2718
  var AssignedVariable = ({ variable, propTypeKey }) => {
1890
2719
  const { startIcon, propTypeUtil } = getVariableType(propTypeKey);
1891
2720
  const { setValue } = (0, import_editor_controls6.useBoundProp)();
1892
- const anchorRef = (0, import_react14.useRef)(null);
1893
- const popupId = (0, import_react14.useId)();
1894
- const popupState = (0, import_ui21.usePopupState)({
2721
+ const anchorRef = (0, import_react18.useRef)(null);
2722
+ const popupId = (0, import_react18.useId)();
2723
+ const popupState = (0, import_ui22.usePopupState)({
1895
2724
  variant: "popover",
1896
2725
  popupId: `elementor-variables-list-${popupId}`
1897
2726
  });
1898
2727
  const unlinkVariable = createUnlinkHandler(variable, propTypeKey, setValue);
1899
2728
  const StartIcon = startIcon || (() => null);
1900
- return /* @__PURE__ */ React21.createElement(import_ui21.Box, { ref: anchorRef }, /* @__PURE__ */ React21.createElement(
2729
+ return /* @__PURE__ */ React22.createElement(import_ui22.Box, { ref: anchorRef }, /* @__PURE__ */ React22.createElement(
1901
2730
  AssignedTag,
1902
2731
  {
1903
2732
  label: variable.label,
1904
- startIcon: /* @__PURE__ */ React21.createElement(React21.Fragment, null, /* @__PURE__ */ React21.createElement(import_icons11.ColorFilterIcon, { fontSize: SIZE5 }), /* @__PURE__ */ React21.createElement(StartIcon, { value: variable.value })),
2733
+ startIcon: /* @__PURE__ */ React22.createElement(React22.Fragment, null, /* @__PURE__ */ React22.createElement(import_icons13.ColorFilterIcon, { fontSize: SIZE6 }), /* @__PURE__ */ React22.createElement(StartIcon, { value: variable.value })),
1905
2734
  onUnlink: unlinkVariable,
1906
- ...(0, import_ui21.bindTrigger)(popupState)
2735
+ ...(0, import_ui22.bindTrigger)(popupState)
1907
2736
  }
1908
- ), /* @__PURE__ */ React21.createElement(
1909
- import_ui21.Popover,
2737
+ ), /* @__PURE__ */ React22.createElement(
2738
+ import_ui22.Popover,
1910
2739
  {
1911
2740
  disableScrollLock: true,
1912
2741
  anchorEl: anchorRef.current,
@@ -1915,9 +2744,9 @@ var AssignedVariable = ({ variable, propTypeKey }) => {
1915
2744
  PaperProps: {
1916
2745
  sx: { my: 1 }
1917
2746
  },
1918
- ...(0, import_ui21.bindPopover)(popupState)
2747
+ ...(0, import_ui22.bindPopover)(popupState)
1919
2748
  },
1920
- /* @__PURE__ */ React21.createElement(
2749
+ /* @__PURE__ */ React22.createElement(
1921
2750
  VariableSelectionPopover,
1922
2751
  {
1923
2752
  selectedVariable: variable,
@@ -1929,32 +2758,33 @@ var AssignedVariable = ({ variable, propTypeKey }) => {
1929
2758
  };
1930
2759
 
1931
2760
  // src/components/ui/variable/deleted-variable.tsx
1932
- var React25 = __toESM(require("react"));
1933
- var import_react16 = require("react");
2761
+ var React26 = __toESM(require("react"));
2762
+ var import_react20 = require("react");
1934
2763
  var import_editor_controls8 = require("@elementor/editor-controls");
1935
- var import_ui25 = require("@elementor/ui");
2764
+ var import_ui26 = require("@elementor/ui");
2765
+ var import_i18n18 = require("@wordpress/i18n");
1936
2766
 
1937
2767
  // src/components/variable-restore.tsx
1938
- var React22 = __toESM(require("react"));
1939
- var import_react15 = require("react");
2768
+ var React23 = __toESM(require("react"));
2769
+ var import_react19 = require("react");
1940
2770
  var import_editor_controls7 = require("@elementor/editor-controls");
1941
2771
  var import_editor_editing_panel5 = require("@elementor/editor-editing-panel");
1942
- var import_editor_ui7 = require("@elementor/editor-ui");
1943
- var import_ui22 = require("@elementor/ui");
1944
- var import_i18n15 = require("@wordpress/i18n");
1945
- var SIZE6 = "tiny";
2772
+ var import_editor_ui8 = require("@elementor/editor-ui");
2773
+ var import_ui23 = require("@elementor/ui");
2774
+ var import_i18n16 = require("@wordpress/i18n");
2775
+ var SIZE7 = "tiny";
1946
2776
  var VariableRestore = ({ variableId, onClose, onSubmit }) => {
1947
- const { icon: VariableIcon, valueField: ValueField, variableType, propTypeUtil } = useVariableType();
1948
- const { setValue: notifyBoundPropChange } = (0, import_editor_controls7.useBoundProp)(propTypeUtil);
2777
+ const { icon: VariableIcon, valueField: ValueField, variableType } = useVariableType();
2778
+ const { setVariableValue: notifyBoundPropChange } = useVariableBoundProp();
1949
2779
  const { propType } = (0, import_editor_controls7.useBoundProp)();
1950
2780
  const variable = useVariable(variableId);
1951
2781
  if (!variable) {
1952
2782
  throw new Error(`Global ${variableType} variable not found`);
1953
2783
  }
1954
- const [errorMessage, setErrorMessage] = (0, import_react15.useState)("");
1955
- const [valueFieldError, setValueFieldError] = (0, import_react15.useState)("");
1956
- const [label, setLabel] = (0, import_react15.useState)(variable.label);
1957
- const [value, setValue] = (0, import_react15.useState)(variable.value);
2784
+ const [errorMessage, setErrorMessage] = (0, import_react19.useState)("");
2785
+ const [valueFieldError, setValueFieldError] = (0, import_react19.useState)("");
2786
+ const [label, setLabel] = (0, import_react19.useState)(variable.label);
2787
+ const [value, setValue] = (0, import_react19.useState)(variable.value);
1958
2788
  const { labelFieldError, setLabelFieldError } = useLabelError({
1959
2789
  value: variable.label,
1960
2790
  message: ERROR_MESSAGES.DUPLICATED_LABEL
@@ -1992,22 +2822,22 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
1992
2822
  return !!errorMessage;
1993
2823
  };
1994
2824
  const isSubmitDisabled = noValueChanged() || hasEmptyFields() || hasErrors();
1995
- return /* @__PURE__ */ React22.createElement(PopoverContentRefContextProvider, null, /* @__PURE__ */ React22.createElement(import_editor_editing_panel5.PopoverBody, { height: "auto" }, /* @__PURE__ */ React22.createElement(
1996
- import_editor_ui7.PopoverHeader,
2825
+ return /* @__PURE__ */ React23.createElement(PopoverContentRefContextProvider, null, /* @__PURE__ */ React23.createElement(import_editor_editing_panel5.PopoverBody, { height: "auto" }, /* @__PURE__ */ React23.createElement(
2826
+ import_editor_ui8.PopoverHeader,
1997
2827
  {
1998
- icon: /* @__PURE__ */ React22.createElement(VariableIcon, { fontSize: SIZE6 }),
1999
- title: (0, import_i18n15.__)("Restore variable", "elementor"),
2828
+ icon: /* @__PURE__ */ React23.createElement(VariableIcon, { fontSize: SIZE7 }),
2829
+ title: (0, import_i18n16.__)("Restore variable", "elementor"),
2000
2830
  onClose
2001
2831
  }
2002
- ), /* @__PURE__ */ React22.createElement(import_ui22.Divider, null), /* @__PURE__ */ React22.createElement(import_editor_controls7.PopoverContent, { p: 2 }, /* @__PURE__ */ React22.createElement(
2832
+ ), /* @__PURE__ */ React23.createElement(import_ui23.Divider, null), /* @__PURE__ */ React23.createElement(import_editor_controls7.PopoverContent, { p: 2 }, /* @__PURE__ */ React23.createElement(
2003
2833
  FormField,
2004
2834
  {
2005
2835
  id: "variable-label",
2006
- label: (0, import_i18n15.__)("Name", "elementor"),
2836
+ label: (0, import_i18n16.__)("Name", "elementor"),
2007
2837
  errorMsg: labelFieldError?.message,
2008
2838
  noticeMsg: labelHint(label)
2009
2839
  },
2010
- /* @__PURE__ */ React22.createElement(
2840
+ /* @__PURE__ */ React23.createElement(
2011
2841
  LabelField,
2012
2842
  {
2013
2843
  id: "variable-label",
@@ -2025,7 +2855,7 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
2025
2855
  }
2026
2856
  }
2027
2857
  )
2028
- ), /* @__PURE__ */ React22.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n15.__)("Value", "elementor") }, /* @__PURE__ */ React22.createElement(import_ui22.Typography, { variant: "h5" }, /* @__PURE__ */ React22.createElement(
2858
+ ), /* @__PURE__ */ React23.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n16.__)("Value", "elementor") }, /* @__PURE__ */ React23.createElement(import_ui23.Typography, { variant: "h5" }, /* @__PURE__ */ React23.createElement(
2029
2859
  ValueField,
2030
2860
  {
2031
2861
  value,
@@ -2037,91 +2867,87 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
2037
2867
  onValidationChange: setValueFieldError,
2038
2868
  propType
2039
2869
  }
2040
- ))), errorMessage && /* @__PURE__ */ React22.createElement(import_ui22.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React22.createElement(import_ui22.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React22.createElement(import_ui22.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleRestore }, (0, import_i18n15.__)("Restore", "elementor")))));
2870
+ ))), errorMessage && /* @__PURE__ */ React23.createElement(import_ui23.FormHelperText, { error: true }, errorMessage)), /* @__PURE__ */ React23.createElement(import_ui23.CardActions, { sx: { pt: 0.5, pb: 1 } }, /* @__PURE__ */ React23.createElement(import_ui23.Button, { size: "small", variant: "contained", disabled: isSubmitDisabled, onClick: handleRestore }, (0, import_i18n16.__)("Restore", "elementor")))));
2041
2871
  };
2042
2872
 
2043
2873
  // src/components/ui/deleted-variable-alert.tsx
2044
- var React23 = __toESM(require("react"));
2045
- var import_editor_editing_panel6 = require("@elementor/editor-editing-panel");
2046
- var import_ui23 = require("@elementor/ui");
2047
- var import_i18n16 = require("@wordpress/i18n");
2874
+ var React24 = __toESM(require("react"));
2875
+ var import_ui24 = require("@elementor/ui");
2876
+ var import_i18n17 = require("@wordpress/i18n");
2048
2877
  var DeletedVariableAlert = ({ onClose, onUnlink, onRestore, label }) => {
2049
- const sectionWidth = (0, import_editor_editing_panel6.useSectionWidth)();
2050
- return /* @__PURE__ */ React23.createElement(import_ui23.ClickAwayListener, { onClickAway: onClose }, /* @__PURE__ */ React23.createElement(
2051
- import_ui23.Alert,
2878
+ return /* @__PURE__ */ React24.createElement(import_ui24.ClickAwayListener, { onClickAway: onClose }, /* @__PURE__ */ React24.createElement(
2879
+ import_ui24.Alert,
2052
2880
  {
2053
2881
  variant: "standard",
2054
2882
  severity: "warning",
2055
2883
  onClose,
2056
- action: /* @__PURE__ */ React23.createElement(React23.Fragment, null, onUnlink && /* @__PURE__ */ React23.createElement(import_ui23.AlertAction, { variant: "contained", onClick: onUnlink }, (0, import_i18n16.__)("Unlink", "elementor")), onRestore && /* @__PURE__ */ React23.createElement(import_ui23.AlertAction, { variant: "outlined", onClick: onRestore }, (0, import_i18n16.__)("Restore", "elementor"))),
2057
- sx: { width: sectionWidth }
2884
+ action: /* @__PURE__ */ React24.createElement(React24.Fragment, null, onUnlink && /* @__PURE__ */ React24.createElement(import_ui24.AlertAction, { variant: "contained", onClick: onUnlink }, (0, import_i18n17.__)("Unlink", "elementor")), onRestore && /* @__PURE__ */ React24.createElement(import_ui24.AlertAction, { variant: "outlined", onClick: onRestore }, (0, import_i18n17.__)("Restore", "elementor"))),
2885
+ sx: { maxWidth: 300 }
2058
2886
  },
2059
- /* @__PURE__ */ React23.createElement(import_ui23.AlertTitle, null, (0, import_i18n16.__)("Deleted variable", "elementor")),
2060
- (0, import_i18n16.__)("The variable", "elementor"),
2061
- " '",
2062
- label,
2063
- "'",
2064
- " ",
2065
- (0, import_i18n16.__)(
2887
+ /* @__PURE__ */ React24.createElement(import_ui24.AlertTitle, null, (0, import_i18n17.__)("Deleted variable", "elementor")),
2888
+ /* @__PURE__ */ React24.createElement(import_ui24.Typography, { variant: "body2", color: "textPrimary" }, (0, import_i18n17.__)("The variable", "elementor"), "\xA0'", /* @__PURE__ */ React24.createElement(import_ui24.Typography, { variant: "body2", component: "span", sx: { lineBreak: "anywhere" } }, label), "'\xA0", (0, import_i18n17.__)(
2066
2889
  "has been deleted, but it is still referenced in this location. You may restore the variable or unlink it to assign a different value.",
2067
2890
  "elementor"
2068
- )
2891
+ ))
2069
2892
  ));
2070
2893
  };
2071
2894
 
2072
- // src/components/ui/tags/deleted-tag.tsx
2073
- var React24 = __toESM(require("react"));
2074
- var import_icons12 = require("@elementor/icons");
2075
- var import_ui24 = require("@elementor/ui");
2076
- var import_i18n17 = require("@wordpress/i18n");
2077
- var DeletedTag = React24.forwardRef(({ label, onClick, ...props }, ref) => {
2078
- return /* @__PURE__ */ React24.createElement(
2079
- import_ui24.Chip,
2080
- {
2081
- ref,
2082
- size: "tiny",
2083
- color: "warning",
2084
- shape: "rounded",
2085
- variant: "standard",
2086
- onClick,
2087
- icon: /* @__PURE__ */ React24.createElement(import_icons12.AlertTriangleFilledIcon, null),
2088
- label: /* @__PURE__ */ React24.createElement(import_ui24.Tooltip, { title: label, placement: "top" }, /* @__PURE__ */ React24.createElement(import_ui24.Box, { sx: { display: "flex", gap: 0.5, alignItems: "center" } }, /* @__PURE__ */ React24.createElement(import_ui24.Typography, { variant: "caption", noWrap: true }, label), /* @__PURE__ */ React24.createElement(import_ui24.Typography, { variant: "caption", noWrap: true, sx: { textOverflow: "initial", overflow: "visible" } }, "(", (0, import_i18n17.__)("deleted", "elementor"), ")"))),
2089
- sx: {
2090
- height: (theme) => theme.spacing(3.5),
2091
- borderRadius: (theme) => theme.spacing(1),
2092
- justifyContent: "flex-start",
2093
- width: "100%"
2094
- },
2095
- ...props
2096
- }
2097
- );
2098
- });
2895
+ // src/components/ui/tags/warning-variable-tag.tsx
2896
+ var React25 = __toESM(require("react"));
2897
+ var import_icons14 = require("@elementor/icons");
2898
+ var import_ui25 = require("@elementor/ui");
2899
+ var WarningVariableTag = React25.forwardRef(
2900
+ ({ label, suffix, onClick, icon, ...props }, ref) => {
2901
+ const displayText = suffix ? `${label} (${suffix})` : label;
2902
+ return /* @__PURE__ */ React25.createElement(
2903
+ import_ui25.Chip,
2904
+ {
2905
+ ref,
2906
+ size: "tiny",
2907
+ color: "warning",
2908
+ shape: "rounded",
2909
+ variant: "standard",
2910
+ onClick,
2911
+ icon: /* @__PURE__ */ React25.createElement(import_icons14.AlertTriangleFilledIcon, null),
2912
+ label: /* @__PURE__ */ React25.createElement(import_ui25.Tooltip, { title: displayText, placement: "top" }, /* @__PURE__ */ React25.createElement(import_ui25.Box, { sx: { display: "inline-grid", minWidth: 0 } }, /* @__PURE__ */ React25.createElement(import_ui25.Typography, { variant: "caption", noWrap: true, sx: { lineHeight: 1.34 } }, displayText))),
2913
+ sx: {
2914
+ height: (theme) => theme.spacing(3.5),
2915
+ borderRadius: (theme) => theme.spacing(1),
2916
+ justifyContent: "flex-start",
2917
+ width: "100%"
2918
+ },
2919
+ ...props
2920
+ }
2921
+ );
2922
+ }
2923
+ );
2924
+ WarningVariableTag.displayName = "WarningVariableTag";
2099
2925
 
2100
2926
  // src/components/ui/variable/deleted-variable.tsx
2101
2927
  var DeletedVariable = ({ variable, propTypeKey }) => {
2102
2928
  const { propTypeUtil } = getVariableType(propTypeKey);
2103
- const { setValue } = (0, import_editor_controls8.useBoundProp)();
2929
+ const boundProp = (0, import_editor_controls8.useBoundProp)();
2104
2930
  const userPermissions = usePermissions();
2105
- const [showInfotip, setShowInfotip] = (0, import_react16.useState)(false);
2931
+ const [showInfotip, setShowInfotip] = (0, import_react20.useState)(false);
2106
2932
  const toggleInfotip = () => setShowInfotip((prev) => !prev);
2107
2933
  const closeInfotip = () => setShowInfotip(false);
2108
- const deletedChipAnchorRef = (0, import_react16.useRef)(null);
2109
- const popupId = (0, import_react16.useId)();
2110
- const popupState = (0, import_ui25.usePopupState)({
2934
+ const deletedChipAnchorRef = (0, import_react20.useRef)(null);
2935
+ const popupId = (0, import_react20.useId)();
2936
+ const popupState = (0, import_ui26.usePopupState)({
2111
2937
  variant: "popover",
2112
2938
  popupId: `elementor-variables-restore-${popupId}`
2113
2939
  });
2114
2940
  const handlers = {};
2115
2941
  if (userPermissions.canUnlink()) {
2116
- handlers.onUnlink = createUnlinkHandler(variable, propTypeKey, setValue);
2942
+ handlers.onUnlink = createUnlinkHandler(variable, propTypeKey, boundProp.setValue);
2117
2943
  }
2118
2944
  if (userPermissions.canRestore()) {
2119
2945
  handlers.onRestore = () => {
2120
2946
  if (!variable.key) {
2121
2947
  return;
2122
2948
  }
2123
- restoreVariable(variable.key).then((key) => {
2124
- setValue(propTypeUtil.create(key));
2949
+ restoreVariable(variable.key).then((id2) => {
2950
+ resolveBoundPropAndSetValue(propTypeUtil.create(id2), boundProp);
2125
2951
  closeInfotip();
2126
2952
  }).catch(() => {
2127
2953
  closeInfotip();
@@ -2133,15 +2959,15 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
2133
2959
  const handleRestoreWithOverrides = () => {
2134
2960
  popupState.close();
2135
2961
  };
2136
- return /* @__PURE__ */ React25.createElement(React25.Fragment, null, /* @__PURE__ */ React25.createElement(import_ui25.Box, { ref: deletedChipAnchorRef }, showInfotip && /* @__PURE__ */ React25.createElement(import_ui25.Backdrop, { open: true, onClick: closeInfotip, invisible: true }), /* @__PURE__ */ React25.createElement(
2137
- import_ui25.Infotip,
2962
+ return /* @__PURE__ */ React26.createElement(React26.Fragment, null, /* @__PURE__ */ React26.createElement(import_ui26.Box, { ref: deletedChipAnchorRef }, showInfotip && /* @__PURE__ */ React26.createElement(import_ui26.Backdrop, { open: true, onClick: closeInfotip, invisible: true }), /* @__PURE__ */ React26.createElement(
2963
+ import_ui26.Infotip,
2138
2964
  {
2139
2965
  color: "warning",
2140
2966
  placement: "right-start",
2141
2967
  open: showInfotip,
2142
2968
  disableHoverListener: true,
2143
2969
  onClose: closeInfotip,
2144
- content: /* @__PURE__ */ React25.createElement(
2970
+ content: /* @__PURE__ */ React26.createElement(
2145
2971
  DeletedVariableAlert,
2146
2972
  {
2147
2973
  onClose: closeInfotip,
@@ -2161,9 +2987,16 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
2161
2987
  }
2162
2988
  }
2163
2989
  },
2164
- /* @__PURE__ */ React25.createElement(DeletedTag, { label: variable.label, onClick: toggleInfotip })
2165
- ), /* @__PURE__ */ React25.createElement(
2166
- import_ui25.Popover,
2990
+ /* @__PURE__ */ React26.createElement(
2991
+ WarningVariableTag,
2992
+ {
2993
+ label: variable.label,
2994
+ onClick: toggleInfotip,
2995
+ suffix: (0, import_i18n18.__)("deleted", "elementor")
2996
+ }
2997
+ )
2998
+ ), /* @__PURE__ */ React26.createElement(
2999
+ import_ui26.Popover,
2167
3000
  {
2168
3001
  disableScrollLock: true,
2169
3002
  anchorOrigin: { vertical: "bottom", horizontal: "right" },
@@ -2171,9 +3004,9 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
2171
3004
  PaperProps: {
2172
3005
  sx: { my: 1 }
2173
3006
  },
2174
- ...(0, import_ui25.bindPopover)(popupState)
3007
+ ...(0, import_ui26.bindPopover)(popupState)
2175
3008
  },
2176
- /* @__PURE__ */ React25.createElement(VariableTypeProvider, { propTypeKey }, /* @__PURE__ */ React25.createElement(
3009
+ /* @__PURE__ */ React26.createElement(VariableTypeProvider, { propTypeKey }, /* @__PURE__ */ React26.createElement(
2177
3010
  VariableRestore,
2178
3011
  {
2179
3012
  variableId: variable.key ?? "",
@@ -2186,83 +3019,51 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
2186
3019
 
2187
3020
  // src/components/ui/variable/mismatch-variable.tsx
2188
3021
  var React28 = __toESM(require("react"));
2189
- var import_react17 = require("react");
3022
+ var import_react21 = require("react");
2190
3023
  var import_editor_controls9 = require("@elementor/editor-controls");
2191
3024
  var import_ui28 = require("@elementor/ui");
3025
+ var import_i18n20 = require("@wordpress/i18n");
2192
3026
 
2193
3027
  // src/components/ui/mismatch-variable-alert.tsx
2194
- var React26 = __toESM(require("react"));
2195
- var import_editor_editing_panel7 = require("@elementor/editor-editing-panel");
2196
- var import_ui26 = require("@elementor/ui");
2197
- var import_i18n18 = require("@wordpress/i18n");
3028
+ var React27 = __toESM(require("react"));
3029
+ var import_ui27 = require("@elementor/ui");
3030
+ var import_i18n19 = require("@wordpress/i18n");
2198
3031
  var i18n = {
2199
- title: (0, import_i18n18.__)("Variable has changed", "elementor"),
2200
- message: (0, import_i18n18.__)(
3032
+ title: (0, import_i18n19.__)("Variable has changed", "elementor"),
3033
+ message: (0, import_i18n19.__)(
2201
3034
  `This variable is no longer compatible with this property. You can clear it or select a different one.`,
2202
3035
  "elementor"
2203
3036
  ),
2204
3037
  buttons: {
2205
- clear: (0, import_i18n18.__)("Clear", "elementor"),
2206
- select: (0, import_i18n18.__)("Select variable", "elementor")
3038
+ clear: (0, import_i18n19.__)("Clear", "elementor"),
3039
+ select: (0, import_i18n19.__)("Select variable", "elementor")
2207
3040
  }
2208
3041
  };
2209
3042
  var MismatchVariableAlert = ({ onClose, onClear, triggerSelect }) => {
2210
- const sectionWidth = (0, import_editor_editing_panel7.useSectionWidth)();
2211
- return /* @__PURE__ */ React26.createElement(import_ui26.ClickAwayListener, { onClickAway: onClose }, /* @__PURE__ */ React26.createElement(
2212
- import_ui26.Alert,
3043
+ return /* @__PURE__ */ React27.createElement(import_ui27.ClickAwayListener, { onClickAway: onClose }, /* @__PURE__ */ React27.createElement(
3044
+ import_ui27.Alert,
2213
3045
  {
2214
3046
  variant: "standard",
2215
3047
  severity: "warning",
2216
3048
  onClose,
2217
- action: /* @__PURE__ */ React26.createElement(React26.Fragment, null, onClear && /* @__PURE__ */ React26.createElement(import_ui26.AlertAction, { variant: "contained", onClick: onClear }, i18n.buttons.clear), triggerSelect && /* @__PURE__ */ React26.createElement(import_ui26.AlertAction, { variant: "outlined", onClick: triggerSelect }, i18n.buttons.select)),
2218
- sx: {
2219
- width: sectionWidth,
2220
- minWidth: 300
2221
- }
3049
+ action: /* @__PURE__ */ React27.createElement(React27.Fragment, null, onClear && /* @__PURE__ */ React27.createElement(import_ui27.AlertAction, { variant: "contained", onClick: onClear }, i18n.buttons.clear), triggerSelect && /* @__PURE__ */ React27.createElement(import_ui27.AlertAction, { variant: "outlined", onClick: triggerSelect }, i18n.buttons.select)),
3050
+ sx: { maxWidth: 300 }
2222
3051
  },
2223
- /* @__PURE__ */ React26.createElement(import_ui26.AlertTitle, null, i18n.title),
2224
- i18n.message
3052
+ /* @__PURE__ */ React27.createElement(import_ui27.AlertTitle, null, i18n.title),
3053
+ /* @__PURE__ */ React27.createElement(import_ui27.Typography, { variant: "body2", color: "textPrimary" }, i18n.message)
2225
3054
  ));
2226
3055
  };
2227
3056
 
2228
- // src/components/ui/tags/mismatch-tag.tsx
2229
- var React27 = __toESM(require("react"));
2230
- var import_icons13 = require("@elementor/icons");
2231
- var import_ui27 = require("@elementor/ui");
2232
- var import_i18n19 = require("@wordpress/i18n");
2233
- var MismatchTag = React27.forwardRef(({ label, onClick, ...props }, ref) => {
2234
- return /* @__PURE__ */ React27.createElement(
2235
- import_ui27.Chip,
2236
- {
2237
- ref,
2238
- size: "tiny",
2239
- color: "warning",
2240
- shape: "rounded",
2241
- variant: "standard",
2242
- onClick,
2243
- icon: /* @__PURE__ */ React27.createElement(import_icons13.AlertTriangleFilledIcon, null),
2244
- label: /* @__PURE__ */ React27.createElement(import_ui27.Tooltip, { title: label, placement: "top" }, /* @__PURE__ */ React27.createElement(import_ui27.Box, { sx: { display: "flex", gap: 0.5, alignItems: "center" } }, /* @__PURE__ */ React27.createElement(import_ui27.Typography, { variant: "caption", noWrap: true }, label), /* @__PURE__ */ React27.createElement(import_ui27.Typography, { variant: "caption", noWrap: true, sx: { textOverflow: "initial", overflow: "visible" } }, "(", (0, import_i18n19.__)("changed", "elementor"), ")"))),
2245
- sx: {
2246
- height: (theme) => theme.spacing(3.5),
2247
- borderRadius: (theme) => theme.spacing(1),
2248
- justifyContent: "flex-start",
2249
- width: "100%"
2250
- },
2251
- ...props
2252
- }
2253
- );
2254
- });
2255
-
2256
3057
  // src/components/ui/variable/mismatch-variable.tsx
2257
3058
  var MismatchVariable = ({ variable }) => {
2258
- const { setValue } = (0, import_editor_controls9.useBoundProp)();
2259
- const anchorRef = (0, import_react17.useRef)(null);
2260
- const popupId = (0, import_react17.useId)();
3059
+ const { setValue, value } = (0, import_editor_controls9.useBoundProp)();
3060
+ const anchorRef = (0, import_react21.useRef)(null);
3061
+ const popupId = (0, import_react21.useId)();
2261
3062
  const popupState = (0, import_ui28.usePopupState)({
2262
3063
  variant: "popover",
2263
3064
  popupId: `elementor-variables-list-${popupId}`
2264
3065
  });
2265
- const [infotipVisible, setInfotipVisible] = (0, import_react17.useState)(false);
3066
+ const [infotipVisible, setInfotipVisible] = (0, import_react21.useState)(false);
2266
3067
  const toggleInfotip = () => setInfotipVisible((prev) => !prev);
2267
3068
  const closeInfotip = () => setInfotipVisible(false);
2268
3069
  const triggerSelect = () => {
@@ -2274,6 +3075,7 @@ var MismatchVariable = ({ variable }) => {
2274
3075
  closeInfotip();
2275
3076
  setValue(null);
2276
3077
  };
3078
+ const showClearButton = !!value;
2277
3079
  return /* @__PURE__ */ React28.createElement(import_ui28.Box, { ref: anchorRef }, infotipVisible && /* @__PURE__ */ React28.createElement(import_ui28.Backdrop, { open: true, onClick: closeInfotip, invisible: true }), /* @__PURE__ */ React28.createElement(
2278
3080
  import_ui28.Infotip,
2279
3081
  {
@@ -2286,7 +3088,7 @@ var MismatchVariable = ({ variable }) => {
2286
3088
  MismatchVariableAlert,
2287
3089
  {
2288
3090
  onClose: closeInfotip,
2289
- onClear: clearValue,
3091
+ onClear: showClearButton ? clearValue : void 0,
2290
3092
  triggerSelect
2291
3093
  }
2292
3094
  ),
@@ -2301,7 +3103,14 @@ var MismatchVariable = ({ variable }) => {
2301
3103
  }
2302
3104
  }
2303
3105
  },
2304
- /* @__PURE__ */ React28.createElement(MismatchTag, { label: variable.label, onClick: toggleInfotip })
3106
+ /* @__PURE__ */ React28.createElement(
3107
+ WarningVariableTag,
3108
+ {
3109
+ label: variable.label,
3110
+ onClick: toggleInfotip,
3111
+ suffix: (0, import_i18n20.__)("changed", "elementor")
3112
+ }
3113
+ )
2305
3114
  ), /* @__PURE__ */ React28.createElement(
2306
3115
  import_ui28.Popover,
2307
3116
  {
@@ -2326,79 +3135,50 @@ var MismatchVariable = ({ variable }) => {
2326
3135
  };
2327
3136
 
2328
3137
  // src/components/ui/variable/missing-variable.tsx
2329
- var React31 = __toESM(require("react"));
2330
- var import_react18 = require("react");
3138
+ var React30 = __toESM(require("react"));
3139
+ var import_react22 = require("react");
2331
3140
  var import_editor_controls10 = require("@elementor/editor-controls");
2332
- var import_ui31 = require("@elementor/ui");
2333
- var import_i18n21 = require("@wordpress/i18n");
3141
+ var import_ui30 = require("@elementor/ui");
3142
+ var import_i18n22 = require("@wordpress/i18n");
2334
3143
 
2335
3144
  // src/components/ui/missing-variable-alert.tsx
2336
3145
  var React29 = __toESM(require("react"));
2337
- var import_editor_editing_panel8 = require("@elementor/editor-editing-panel");
2338
3146
  var import_ui29 = require("@elementor/ui");
2339
- var import_i18n20 = require("@wordpress/i18n");
3147
+ var import_i18n21 = require("@wordpress/i18n");
2340
3148
  var MissingVariableAlert = ({ onClose, onClear }) => {
2341
- const sectionWidth = (0, import_editor_editing_panel8.useSectionWidth)();
2342
3149
  return /* @__PURE__ */ React29.createElement(import_ui29.ClickAwayListener, { onClickAway: onClose }, /* @__PURE__ */ React29.createElement(
2343
3150
  import_ui29.Alert,
2344
3151
  {
2345
3152
  variant: "standard",
2346
3153
  severity: "warning",
2347
3154
  onClose,
2348
- action: /* @__PURE__ */ React29.createElement(React29.Fragment, null, onClear && /* @__PURE__ */ React29.createElement(import_ui29.AlertAction, { variant: "contained", onClick: onClear }, (0, import_i18n20.__)("Clear", "elementor"))),
2349
- sx: { width: sectionWidth }
3155
+ action: /* @__PURE__ */ React29.createElement(React29.Fragment, null, onClear && /* @__PURE__ */ React29.createElement(import_ui29.AlertAction, { variant: "contained", onClick: onClear }, (0, import_i18n21.__)("Clear", "elementor"))),
3156
+ sx: { maxWidth: 300 }
2350
3157
  },
2351
- /* @__PURE__ */ React29.createElement(import_ui29.AlertTitle, null, (0, import_i18n20.__)("This variable is missing", "elementor")),
2352
- (0, import_i18n20.__)(
3158
+ /* @__PURE__ */ React29.createElement(import_ui29.AlertTitle, null, (0, import_i18n21.__)("This variable is missing", "elementor")),
3159
+ /* @__PURE__ */ React29.createElement(import_ui29.Typography, { variant: "body2", color: "textPrimary" }, (0, import_i18n21.__)(
2353
3160
  "It may have been deleted. Try clearing this field and select a different value or variable.",
2354
3161
  "elementor"
2355
- )
3162
+ ))
2356
3163
  ));
2357
3164
  };
2358
3165
 
2359
- // src/components/ui/tags/missing-tag.tsx
2360
- var React30 = __toESM(require("react"));
2361
- var import_icons14 = require("@elementor/icons");
2362
- var import_ui30 = require("@elementor/ui");
2363
- var MissingTag = React30.forwardRef(({ label, onClick, ...props }, ref) => {
2364
- return /* @__PURE__ */ React30.createElement(
2365
- import_ui30.Chip,
2366
- {
2367
- ref,
2368
- size: "tiny",
2369
- color: "warning",
2370
- shape: "rounded",
2371
- variant: "standard",
2372
- onClick,
2373
- icon: /* @__PURE__ */ React30.createElement(import_icons14.AlertTriangleFilledIcon, null),
2374
- label,
2375
- sx: {
2376
- height: (theme) => theme.spacing(3.5),
2377
- borderRadius: (theme) => theme.spacing(1),
2378
- justifyContent: "flex-start",
2379
- width: "100%"
2380
- },
2381
- ...props
2382
- }
2383
- );
2384
- });
2385
-
2386
3166
  // src/components/ui/variable/missing-variable.tsx
2387
3167
  var MissingVariable = () => {
2388
3168
  const { setValue } = (0, import_editor_controls10.useBoundProp)();
2389
- const [infotipVisible, setInfotipVisible] = (0, import_react18.useState)(false);
3169
+ const [infotipVisible, setInfotipVisible] = (0, import_react22.useState)(false);
2390
3170
  const toggleInfotip = () => setInfotipVisible((prev) => !prev);
2391
3171
  const closeInfotip = () => setInfotipVisible(false);
2392
3172
  const clearValue = () => setValue(null);
2393
- return /* @__PURE__ */ React31.createElement(React31.Fragment, null, infotipVisible && /* @__PURE__ */ React31.createElement(import_ui31.Backdrop, { open: true, onClick: closeInfotip, invisible: true }), /* @__PURE__ */ React31.createElement(
2394
- import_ui31.Infotip,
3173
+ return /* @__PURE__ */ React30.createElement(React30.Fragment, null, infotipVisible && /* @__PURE__ */ React30.createElement(import_ui30.Backdrop, { open: true, onClick: closeInfotip, invisible: true }), /* @__PURE__ */ React30.createElement(
3174
+ import_ui30.Infotip,
2395
3175
  {
2396
3176
  color: "warning",
2397
3177
  placement: "right-start",
2398
3178
  open: infotipVisible,
2399
3179
  disableHoverListener: true,
2400
3180
  onClose: closeInfotip,
2401
- content: /* @__PURE__ */ React31.createElement(MissingVariableAlert, { onClose: closeInfotip, onClear: clearValue }),
3181
+ content: /* @__PURE__ */ React30.createElement(MissingVariableAlert, { onClose: closeInfotip, onClear: clearValue }),
2402
3182
  slotProps: {
2403
3183
  popper: {
2404
3184
  modifiers: [
@@ -2410,47 +3190,47 @@ var MissingVariable = () => {
2410
3190
  }
2411
3191
  }
2412
3192
  },
2413
- /* @__PURE__ */ React31.createElement(MissingTag, { label: (0, import_i18n21.__)("Missing variable", "elementor"), onClick: toggleInfotip })
3193
+ /* @__PURE__ */ React30.createElement(WarningVariableTag, { label: (0, import_i18n22.__)("Missing variable", "elementor"), onClick: toggleInfotip })
2414
3194
  ));
2415
3195
  };
2416
3196
 
2417
3197
  // src/controls/variable-control.tsx
2418
3198
  var VariableControl = () => {
2419
3199
  const boundProp = (0, import_editor_controls11.useBoundProp)();
2420
- const boundPropValue = boundProp.value;
3200
+ const boundPropValue = boundProp.value ?? boundProp.placeholder;
2421
3201
  const assignedVariable = useVariable(boundPropValue?.value);
2422
3202
  if (!assignedVariable) {
2423
- return /* @__PURE__ */ React32.createElement(MissingVariable, null);
3203
+ return /* @__PURE__ */ React31.createElement(MissingVariable, null);
2424
3204
  }
2425
3205
  const { $$type: propTypeKey } = boundPropValue;
2426
3206
  if (assignedVariable?.deleted) {
2427
- return /* @__PURE__ */ React32.createElement(DeletedVariable, { variable: assignedVariable, propTypeKey });
3207
+ return /* @__PURE__ */ React31.createElement(DeletedVariable, { variable: assignedVariable, propTypeKey });
2428
3208
  }
2429
3209
  const { isCompatible } = getVariableType(assignedVariable.type);
2430
3210
  if (isCompatible && !isCompatible(boundProp?.propType, assignedVariable)) {
2431
- return /* @__PURE__ */ React32.createElement(MismatchVariable, { variable: assignedVariable });
3211
+ return /* @__PURE__ */ React31.createElement(MismatchVariable, { variable: assignedVariable });
2432
3212
  }
2433
- return /* @__PURE__ */ React32.createElement(AssignedVariable, { variable: assignedVariable, propTypeKey });
3213
+ return /* @__PURE__ */ React31.createElement(AssignedVariable, { variable: assignedVariable, propTypeKey });
2434
3214
  };
2435
3215
 
2436
3216
  // src/hooks/use-prop-variable-action.tsx
2437
- var React33 = __toESM(require("react"));
2438
- var import_editor_editing_panel9 = require("@elementor/editor-editing-panel");
3217
+ var React32 = __toESM(require("react"));
3218
+ var import_editor_editing_panel6 = require("@elementor/editor-editing-panel");
2439
3219
  var import_icons15 = require("@elementor/icons");
2440
- var import_i18n22 = require("@wordpress/i18n");
3220
+ var import_i18n23 = require("@wordpress/i18n");
2441
3221
  var usePropVariableAction = () => {
2442
- const { propType, path } = (0, import_editor_editing_panel9.useBoundProp)();
3222
+ const { propType, path } = (0, import_editor_editing_panel6.useBoundProp)();
2443
3223
  const variable = resolveVariableFromPropType(propType);
2444
3224
  return {
2445
3225
  visible: Boolean(variable),
2446
3226
  icon: import_icons15.ColorFilterIcon,
2447
- title: (0, import_i18n22.__)("Variables", "elementor"),
3227
+ title: (0, import_i18n23.__)("Variables", "elementor"),
2448
3228
  content: ({ close: closePopover }) => {
2449
3229
  if (!variable) {
2450
3230
  return null;
2451
3231
  }
2452
3232
  trackOpenVariablePopover(path, variable.variableType);
2453
- return /* @__PURE__ */ React33.createElement(VariableSelectionPopover, { closePopover, propTypeKey: variable.propTypeUtil.key });
3233
+ return /* @__PURE__ */ React32.createElement(VariableSelectionPopover, { closePopover, propTypeKey: variable.propTypeUtil.key });
2454
3234
  }
2455
3235
  };
2456
3236
  };
@@ -2474,19 +3254,297 @@ var trackOpenVariablePopover = (path, variableType) => {
2474
3254
  });
2475
3255
  };
2476
3256
 
3257
+ // src/mcp/index.ts
3258
+ var import_editor_mcp6 = require("@elementor/editor-mcp");
3259
+
3260
+ // src/mcp/create-variable-tool.ts
3261
+ var import_editor_mcp = require("@elementor/editor-mcp");
3262
+ var import_schema3 = require("@elementor/schema");
3263
+ var InputSchema = {
3264
+ type: import_schema3.z.string().describe('The type of the variable. Example values: "global-color-variable" or "global-font-variable".'),
3265
+ label: import_schema3.z.string().describe("The label of the variable, displayed to the user"),
3266
+ value: import_schema3.z.string().describe("The value of the variable, should correspond to the type")
3267
+ };
3268
+ var OutputSchema = {
3269
+ status: import_schema3.z.enum(["ok", "error"]).describe("The status of the operation"),
3270
+ message: import_schema3.z.string().optional().describe("Optional message providing additional information about the operation")
3271
+ };
3272
+ var initCreateVariableTool = () => {
3273
+ (0, import_editor_mcp.getMCPByDomain)("variables").addTool({
3274
+ name: "create-global-variable",
3275
+ schema: InputSchema,
3276
+ outputSchema: OutputSchema,
3277
+ description: `Create a new global variable
3278
+ ## When to use this tool:
3279
+ - When a user requests to create a new global variable in the Elementor editor.
3280
+ - When you need to add a new variable to be used in the editor.
3281
+
3282
+ ## Prequisites:
3283
+ - Ensure you have the most up-to-date list of existing global variables to avoid label duplication. You can use the "list-global-variables" tool to fetch the current variables.
3284
+ - Make sure when creating a new variable, the label is unique and not already in use.
3285
+ - If the user does not provide a label, ask them to provide one before proceeding.
3286
+ - If the user does not provide a type, ask them to provide one before proceeding.
3287
+ - If the user does not provide a value, ask them to provide one before proceeding.
3288
+
3289
+ ## Required parameters:
3290
+ - type: The type of the variable. Possible values are 'global-color-variable' or 'global-font-variable'.
3291
+ - label: The label of the variable, displayed to the user. Must be unique and not already in use.
3292
+ - value: The value of the variable. For color variables, this should be a valid CSS color (e.g., 'rgb(255,0,0)', '#ff0000', 'red'). For font variables, this should be a valid font family (e.g., 'Arial', 'serif').
3293
+
3294
+ ## Example tool call (JSON format):
3295
+ \`\`\`json
3296
+ { "type": "global-color-variable", "label": "My Cool Color", "value": "rgb(1,2,3)" }
3297
+ \`\`\`
3298
+
3299
+ ## Example tool response (JSON format):
3300
+ \`\`\`json
3301
+ { "status": "ok" }
3302
+ \`\`\`
3303
+
3304
+ ## Example to a failed tool response, which must be displayed to the end user. If the error message is not plain, attempt to find the most useful part of the message and display it.
3305
+ { "status": "error", "message": "Unsupported type 'global-kuku-variable'" }
3306
+
3307
+ In that case, inform the user the type is unsupported and they should try another type, perhaps consult to online documentation.
3308
+ `,
3309
+ handler: async (params) => {
3310
+ const { type, label, value } = params;
3311
+ try {
3312
+ await service.create({ type, label, value });
3313
+ } catch (error) {
3314
+ const message = error.message || "Unknown server error";
3315
+ return {
3316
+ status: "error",
3317
+ message: `There was an error creating the variable: ${message}`
3318
+ };
3319
+ }
3320
+ return { status: "ok" };
3321
+ }
3322
+ });
3323
+ };
3324
+
3325
+ // src/mcp/delete-variable-tool.ts
3326
+ var import_editor_mcp2 = require("@elementor/editor-mcp");
3327
+ var import_schema4 = require("@elementor/schema");
3328
+ var initDeleteVariableTool = () => {
3329
+ (0, import_editor_mcp2.getMCPByDomain)("variables").addTool({
3330
+ name: "delete-global-variable",
3331
+ schema: {
3332
+ id: import_schema4.z.string().describe("The unique identifier of the variable to be deleted.")
3333
+ },
3334
+ outputSchema: {
3335
+ status: import_schema4.z.enum(["ok", "error"]).describe("The status of the operation")
3336
+ },
3337
+ description: `Delete an existing global variable
3338
+
3339
+ ## When to use this tool:
3340
+ - When a user requests to delete an existing global variable in the Elementor editor.
3341
+ - When you need to remove a variable that is no longer needed or relevant, with the user's confirmation.
3342
+
3343
+ ## Prerequisites:
3344
+ - Ensure you have the most up-to-date list of existing global variables. You can use the "list-global-variables" tool to fetch the current variables.
3345
+ - Reference the variable by the "id" property, given from the "list-global-variables" tool.
3346
+ - Make sure you have the unique identifier of the variable to be deleted before using this tool.
3347
+ - Confirm with the user that they want to proceed with the deletion, as this action is irreversible.
3348
+
3349
+ <notice>
3350
+ A use might reference a variable by it's label, but you must always use the unique identifier (id) to delete it.
3351
+ If you only have the label, use the "list-global-variables" tool to find the corresponding id.
3352
+ </notice>
3353
+
3354
+ <important>
3355
+ This operation is destructive and cannot be undone. Ensure that the user is fully aware of the consequences before proceeding.
3356
+ When a variable is deleted, all references to it in all pages accross the website will lose their effect.
3357
+ </important>`,
3358
+ handler: async (params) => {
3359
+ const { id: id2 } = params;
3360
+ try {
3361
+ await service.delete(id2);
3362
+ return { status: "ok" };
3363
+ } catch (err) {
3364
+ return {
3365
+ status: "error"
3366
+ };
3367
+ }
3368
+ },
3369
+ isDestrcutive: true
3370
+ });
3371
+ };
3372
+
3373
+ // src/mcp/list-variables-tool.ts
3374
+ var import_editor_mcp3 = require("@elementor/editor-mcp");
3375
+ var import_schema5 = require("@elementor/schema");
3376
+ var VariableSchema = {
3377
+ type: import_schema5.z.string().describe("The type of the variable."),
3378
+ label: import_schema5.z.string().describe("The label of the variable, displayed to the user"),
3379
+ value: import_schema5.z.string().describe("The value of the variable."),
3380
+ id: import_schema5.z.string().describe(
3381
+ "The unique identifier of the variable. Used for internal reference, not to be exposed to end users"
3382
+ )
3383
+ };
3384
+ var VariableListSchema = {
3385
+ variables: import_schema5.z.array(import_schema5.z.object(VariableSchema)).describe("List of variables")
3386
+ };
3387
+ var initListVariablesTool = () => {
3388
+ (0, import_editor_mcp3.getMCPByDomain)("variables").addTool({
3389
+ name: "list-global-variables",
3390
+ description: `List editor global variables
3391
+
3392
+ ## When to use this tool:
3393
+ - When a user requests to see all available global variables in the Elementor editor.
3394
+ - When you need to be exact on a variable label, to avoid any mistakes.
3395
+ - When you want to see the most up-to-date list of global variables.
3396
+ - Before using any other variables related tools that makes changes, such as deletion, creation, or updates. This ensures you have the latest information and there is no naming collision or mismatching.
3397
+
3398
+ ## Example tool response (JSON format):
3399
+ \`\`\`json
3400
+ { variables: [
3401
+ { type: 'global-color-variable', label: 'Cool', value: 'rgb(1,2,3)', id: 'some-unique-id' },
3402
+ { type: 'global-font-variable', label: 'Headline', value: 'serif', id: 'some-other-unique-id' },
3403
+ ] }
3404
+ \`\`\`
3405
+
3406
+ Once you get the response, please display the variables in a user-friendly way, unless explicitly requested otherwise.
3407
+ Unless explicitly requested otherwise, response in HTML Format, prefer to use tables or unordered lists.
3408
+
3409
+ Note: **The label is most improtant to be seen as-is without any changes.**
3410
+
3411
+ <important>
3412
+ **Do not omit the label**. This is important for the user to identify the variable.
3413
+ **Do not change the label**, it must be displayed exactly as it is, in it's original characters as received from this tool.
3414
+ </important>
3415
+ `,
3416
+ outputSchema: VariableListSchema,
3417
+ handler: async () => {
3418
+ const variables = service.variables();
3419
+ return {
3420
+ variables: Object.entries(variables).map(([id2, varData]) => ({ id: id2, ...varData }))
3421
+ };
3422
+ }
3423
+ });
3424
+ };
3425
+
3426
+ // src/mcp/update-variable-tool.ts
3427
+ var import_editor_mcp4 = require("@elementor/editor-mcp");
3428
+ var import_schema6 = require("@elementor/schema");
3429
+ var initUpdateVariableTool = () => {
3430
+ (0, import_editor_mcp4.getMCPByDomain)("variables").addTool({
3431
+ schema: {
3432
+ id: import_schema6.z.string().describe("The unique identifier of the variable to be updated or renamed."),
3433
+ label: import_schema6.z.string().describe(
3434
+ "The label of the variable to be stored after the change. If the user only wishes to update the value, this must be strictly equal to the current label."
3435
+ ),
3436
+ value: import_schema6.z.string().describe(
3437
+ "The new value for the variable. For color variables, this should be a valid CSS color (e.g., 'rgb(255,0,0)', '#ff0000', 'red'). For font variables, this should be a valid font family (e.g., 'Arial', 'serif'). If the user wishes to rename only, make sure you provide the existing value."
3438
+ )
3439
+ },
3440
+ outputSchema: {
3441
+ status: import_schema6.z.enum(["ok", "error"]).describe("The status of the operation"),
3442
+ message: import_schema6.z.string().optional().describe("Optional message providing additional information about the operation")
3443
+ },
3444
+ name: "update-global-variable",
3445
+ description: `Update an existing global variable
3446
+
3447
+ ## When to use this tool:
3448
+ - When a user requests to update an existing global variable in the Elementor editor.
3449
+ - When you need to modify the value of an existing variable.
3450
+ - When you want to rename an existing variable (change its label).
3451
+ - When you want to both rename and modify the value of an existing variable.
3452
+
3453
+ ## Prerequisites:
3454
+ - Ensure you have the most up-to-date list of existing global variables to avoid label duplication. You can use the "list-global-variables" tool to fetch the current variables.
3455
+ - Make sure when updating a variable, the new label is unique and not already in use by another variable.
3456
+ - Make sure you understand whether you are updating a value, renaming, or both.
3457
+ - Reference the variable by the "id" property, given from the "list-global-variables" tool.
3458
+ - If the user wishes to rename, make sure you have the existing value.
3459
+ - If the user wishes to update the value, make sure you have to **correct label**.
3460
+ - You must have the unique identifier, the current label, the current value, and the new value or label or both, before using this tool.
3461
+
3462
+ ## Required parameters:
3463
+ - id: The unique identifier of the variable to be updated or renamed.
3464
+ - label: The label of the variable to be stored after the change. If the user only wishes to update the value, this must be strictly equal to the current label.
3465
+ - value: The new value for the variable. For color variables, this should be a valid CSS color (e.g., 'rgb(255,0,0)', '#ff0000', 'red'). For font variables, this should be a valid font family (e.g., 'Arial', 'serif'). If the user wishes to rename only, make sure you provide the existing value.
3466
+
3467
+ ## Example tool call (JSON format):
3468
+ \`\`\`json
3469
+ { "id": "some-unique-id", "label": "Cool", "value": "rgb(0,140,250)" }
3470
+ \`\`\`
3471
+
3472
+ ## Example responses (JSON format):
3473
+ Successful update:
3474
+ \`\`\`json
3475
+ { "status": "ok" }
3476
+ \`\`\`
3477
+
3478
+ Failed update, which must be displayed to the end user. If the error message is not plain, attempt to find the most useful part of the message and display it.
3479
+ \`\`\`json
3480
+ { "status": "error", "message": "Label 'Cool' is already in use by another variable." }
3481
+ \`\`\`
3482
+ `,
3483
+ handler: async (params) => {
3484
+ const { id: id2, label, value } = params;
3485
+ try {
3486
+ await service.update(id2, { label, value });
3487
+ return { status: "ok" };
3488
+ } catch (error) {
3489
+ const message = error.message || "Unknown server error";
3490
+ return {
3491
+ status: "error",
3492
+ message: `There was an error creating the variable: ${message}`
3493
+ };
3494
+ }
3495
+ }
3496
+ });
3497
+ };
3498
+
3499
+ // src/mcp/variables-resource.ts
3500
+ var import_editor_mcp5 = require("@elementor/editor-mcp");
3501
+ var GLOBAL_VARIABLES_URI = "elementor://variables";
3502
+ var initVariablesResource = () => {
3503
+ const { mcpServer } = (0, import_editor_mcp5.getMCPByDomain)("variables");
3504
+ mcpServer.resource(
3505
+ "global-variables",
3506
+ GLOBAL_VARIABLES_URI,
3507
+ {
3508
+ description: "Global variables list. Variables are being used in this way: If it is directly in the schema, you need to put the ID which is the key inside the object."
3509
+ },
3510
+ async () => {
3511
+ return {
3512
+ contents: [{ uri: GLOBAL_VARIABLES_URI, text: localStorage["elementor-global-variables"] }]
3513
+ };
3514
+ }
3515
+ );
3516
+ window.addEventListener("variables:updated", () => {
3517
+ mcpServer.server.sendResourceUpdated({
3518
+ uri: GLOBAL_VARIABLES_URI,
3519
+ contents: [{ uri: GLOBAL_VARIABLES_URI, text: localStorage["elementor-global-variables"] }]
3520
+ });
3521
+ });
3522
+ };
3523
+
3524
+ // src/mcp/index.ts
3525
+ function initMcp() {
3526
+ const { setMCPDescription } = (0, import_editor_mcp6.getMCPByDomain)("variables");
3527
+ setMCPDescription(`Elementor Editor Variables MCP`);
3528
+ initListVariablesTool();
3529
+ initCreateVariableTool();
3530
+ initUpdateVariableTool();
3531
+ initDeleteVariableTool();
3532
+ initVariablesResource();
3533
+ }
3534
+
2477
3535
  // src/register-variable-types.tsx
2478
- var React36 = __toESM(require("react"));
2479
- var import_editor_props3 = require("@elementor/editor-props");
3536
+ var React35 = __toESM(require("react"));
3537
+ var import_editor_props4 = require("@elementor/editor-props");
2480
3538
  var import_icons17 = require("@elementor/icons");
2481
3539
 
2482
3540
  // src/components/fields/color-field.tsx
2483
- var React34 = __toESM(require("react"));
2484
- var import_react19 = require("react");
2485
- var import_ui32 = require("@elementor/ui");
3541
+ var React33 = __toESM(require("react"));
3542
+ var import_react23 = require("react");
3543
+ var import_ui31 = require("@elementor/ui");
2486
3544
  var ColorField = ({ value, onChange, onValidationChange }) => {
2487
- const [color, setColor] = (0, import_react19.useState)(value);
2488
- const [errorMessage, setErrorMessage] = (0, import_react19.useState)("");
2489
- const defaultRef = (0, import_react19.useRef)(null);
3545
+ const [color, setColor] = (0, import_react23.useState)(value);
3546
+ const [errorMessage, setErrorMessage] = (0, import_react23.useState)("");
3547
+ const defaultRef = (0, import_react23.useRef)(null);
2490
3548
  const anchorRef = usePopoverContentRef() ?? defaultRef.current;
2491
3549
  const handleChange = (newValue) => {
2492
3550
  setColor(newValue);
@@ -2495,9 +3553,10 @@ var ColorField = ({ value, onChange, onValidationChange }) => {
2495
3553
  onValidationChange?.(errorMsg);
2496
3554
  onChange(errorMsg ? "" : newValue);
2497
3555
  };
2498
- return /* @__PURE__ */ React34.createElement(
2499
- import_ui32.UnstableColorField,
3556
+ return /* @__PURE__ */ React33.createElement(
3557
+ import_ui31.UnstableColorField,
2500
3558
  {
3559
+ id: "color-variable-field",
2501
3560
  size: "tiny",
2502
3561
  fullWidth: true,
2503
3562
  value: color,
@@ -2523,21 +3582,21 @@ var ColorField = ({ value, onChange, onValidationChange }) => {
2523
3582
  };
2524
3583
 
2525
3584
  // src/components/fields/font-field.tsx
2526
- var React35 = __toESM(require("react"));
2527
- var import_react20 = require("react");
3585
+ var React34 = __toESM(require("react"));
3586
+ var import_react24 = require("react");
2528
3587
  var import_editor_controls12 = require("@elementor/editor-controls");
2529
- var import_editor_editing_panel10 = require("@elementor/editor-editing-panel");
3588
+ var import_editor_editing_panel7 = require("@elementor/editor-editing-panel");
2530
3589
  var import_icons16 = require("@elementor/icons");
2531
- var import_ui33 = require("@elementor/ui");
2532
- var import_i18n23 = require("@wordpress/i18n");
3590
+ var import_ui32 = require("@elementor/ui");
3591
+ var import_i18n24 = require("@wordpress/i18n");
2533
3592
  var FontField = ({ value, onChange, onValidationChange }) => {
2534
- const [fontFamily, setFontFamily] = (0, import_react20.useState)(value);
2535
- const defaultRef = (0, import_react20.useRef)(null);
3593
+ const [fontFamily, setFontFamily] = (0, import_react24.useState)(value);
3594
+ const defaultRef = (0, import_react24.useRef)(null);
2536
3595
  const anchorRef = usePopoverContentRef() ?? defaultRef.current;
2537
- const fontPopoverState = (0, import_ui33.usePopupState)({ variant: "popover" });
2538
- const fontFamilies = (0, import_editor_editing_panel10.useFontFamilies)();
2539
- const sectionWidth = (0, import_editor_editing_panel10.useSectionWidth)();
2540
- const mapFontSubs = React35.useMemo(() => {
3596
+ const fontPopoverState = (0, import_ui32.usePopupState)({ variant: "popover" });
3597
+ const fontFamilies = (0, import_editor_editing_panel7.useFontFamilies)();
3598
+ const sectionWidth = (0, import_editor_editing_panel7.useSectionWidth)();
3599
+ const mapFontSubs = React34.useMemo(() => {
2541
3600
  return fontFamilies.map(({ label, fonts }) => ({
2542
3601
  label,
2543
3602
  items: fonts
@@ -2553,36 +3612,37 @@ var FontField = ({ value, onChange, onValidationChange }) => {
2553
3612
  handleChange(newFontFamily);
2554
3613
  fontPopoverState.close();
2555
3614
  };
2556
- const id2 = (0, import_react20.useId)();
2557
- return /* @__PURE__ */ React35.createElement(React35.Fragment, null, /* @__PURE__ */ React35.createElement(
2558
- import_ui33.UnstableTag,
3615
+ const id2 = (0, import_react24.useId)();
3616
+ return /* @__PURE__ */ React34.createElement(React34.Fragment, null, /* @__PURE__ */ React34.createElement(
3617
+ import_ui32.UnstableTag,
2559
3618
  {
2560
3619
  id: id2,
2561
3620
  variant: "outlined",
2562
3621
  label: fontFamily,
2563
- endIcon: /* @__PURE__ */ React35.createElement(import_icons16.ChevronDownIcon, { fontSize: "tiny" }),
2564
- ...(0, import_ui33.bindTrigger)(fontPopoverState),
3622
+ endIcon: /* @__PURE__ */ React34.createElement(import_icons16.ChevronDownIcon, { fontSize: "tiny" }),
3623
+ ...(0, import_ui32.bindTrigger)(fontPopoverState),
2565
3624
  fullWidth: true
2566
3625
  }
2567
- ), /* @__PURE__ */ React35.createElement(
2568
- import_ui33.Popover,
3626
+ ), /* @__PURE__ */ React34.createElement(
3627
+ import_ui32.Popover,
2569
3628
  {
2570
3629
  disablePortal: true,
2571
3630
  disableScrollLock: true,
2572
3631
  anchorEl: anchorRef,
2573
3632
  anchorOrigin: { vertical: "top", horizontal: "right" },
2574
3633
  transformOrigin: { vertical: "top", horizontal: -28 },
2575
- ...(0, import_ui33.bindPopover)(fontPopoverState)
3634
+ ...(0, import_ui32.bindPopover)(fontPopoverState)
2576
3635
  },
2577
- /* @__PURE__ */ React35.createElement(
3636
+ /* @__PURE__ */ React34.createElement(
2578
3637
  import_editor_controls12.ItemSelector,
2579
3638
  {
3639
+ id: "font-family-variables-selector",
2580
3640
  itemsList: mapFontSubs,
2581
3641
  selectedItem: fontFamily,
2582
3642
  onItemChange: handleFontFamilyChange,
2583
3643
  onClose: fontPopoverState.close,
2584
3644
  sectionWidth,
2585
- title: (0, import_i18n23.__)("Font Family", "elementor"),
3645
+ title: (0, import_i18n24.__)("Font family", "elementor"),
2586
3646
  itemStyle: (item) => ({ fontFamily: item.value }),
2587
3647
  onDebounce: import_editor_controls12.enqueueFont,
2588
3648
  icon: import_icons16.TextIcon
@@ -2597,24 +3657,26 @@ function registerVariableTypes() {
2597
3657
  valueField: ColorField,
2598
3658
  icon: import_icons17.BrushIcon,
2599
3659
  propTypeUtil: colorVariablePropTypeUtil,
2600
- fallbackPropTypeUtil: import_editor_props3.colorPropTypeUtil,
3660
+ fallbackPropTypeUtil: import_editor_props4.colorPropTypeUtil,
2601
3661
  variableType: "color",
2602
- startIcon: ({ value }) => /* @__PURE__ */ React36.createElement(ColorIndicator, { size: "inherit", component: "span", value })
3662
+ startIcon: ({ value }) => /* @__PURE__ */ React35.createElement(ColorIndicator, { size: "inherit", component: "span", value }),
3663
+ defaultValue: "#ffffff"
2603
3664
  });
2604
3665
  registerVariableType({
2605
3666
  valueField: FontField,
2606
3667
  icon: import_icons17.TextIcon,
2607
3668
  propTypeUtil: fontVariablePropTypeUtil,
2608
- fallbackPropTypeUtil: import_editor_props3.stringPropTypeUtil,
2609
- variableType: "font"
3669
+ fallbackPropTypeUtil: import_editor_props4.stringPropTypeUtil,
3670
+ variableType: "font",
3671
+ defaultValue: "Roboto"
2610
3672
  });
2611
3673
  }
2612
3674
 
2613
3675
  // src/renderers/style-variables-renderer.tsx
2614
- var React37 = __toESM(require("react"));
2615
- var import_react21 = require("react");
3676
+ var React36 = __toESM(require("react"));
3677
+ var import_react25 = require("react");
2616
3678
  var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
2617
- var import_ui34 = require("@elementor/ui");
3679
+ var import_ui33 = require("@elementor/ui");
2618
3680
 
2619
3681
  // src/sync/get-canvas-iframe-document.ts
2620
3682
  function getCanvasIframeDocument() {
@@ -2633,14 +3695,14 @@ function StyleVariablesRenderer() {
2633
3695
  }
2634
3696
  const cssVariables = convertToCssVariables(styleVariables);
2635
3697
  const wrappedCss = `${VARIABLES_WRAPPER}{${cssVariables}}`;
2636
- return /* @__PURE__ */ React37.createElement(import_ui34.Portal, { container }, /* @__PURE__ */ React37.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
3698
+ return /* @__PURE__ */ React36.createElement(import_ui33.Portal, { container }, /* @__PURE__ */ React36.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
2637
3699
  }
2638
3700
  function usePortalContainer() {
2639
3701
  return (0, import_editor_v1_adapters3.__privateUseListenTo)((0, import_editor_v1_adapters3.commandEndEvent)("editor/documents/attach-preview"), () => getCanvasIframeDocument()?.head);
2640
3702
  }
2641
3703
  function useStyleVariables() {
2642
- const [variables, setVariables] = (0, import_react21.useState)({});
2643
- (0, import_react21.useEffect)(() => {
3704
+ const [variables, setVariables] = (0, import_react25.useState)({});
3705
+ (0, import_react25.useEffect)(() => {
2644
3706
  const unsubscribe = styleVariablesRepository.subscribe(setVariables);
2645
3707
  return () => {
2646
3708
  unsubscribe();
@@ -2660,25 +3722,25 @@ function convertToCssVariables(variables) {
2660
3722
 
2661
3723
  // src/repeater-injections.ts
2662
3724
  var import_editor_controls13 = require("@elementor/editor-controls");
2663
- var import_editor_props4 = require("@elementor/editor-props");
3725
+ var import_editor_props5 = require("@elementor/editor-props");
2664
3726
 
2665
3727
  // src/components/variables-repeater-item-slot.tsx
2666
- var React38 = __toESM(require("react"));
3728
+ var React37 = __toESM(require("react"));
2667
3729
  var useColorVariable = (value) => {
2668
3730
  const variableId = value?.value?.color?.value;
2669
3731
  return useVariable(variableId || "");
2670
3732
  };
2671
3733
  var BackgroundRepeaterColorIndicator = ({ value }) => {
2672
3734
  const colorVariable = useColorVariable(value);
2673
- return /* @__PURE__ */ React38.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
3735
+ return /* @__PURE__ */ React37.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
2674
3736
  };
2675
3737
  var BackgroundRepeaterLabel = ({ value }) => {
2676
3738
  const colorVariable = useColorVariable(value);
2677
- return /* @__PURE__ */ React38.createElement("span", null, colorVariable?.label);
3739
+ return /* @__PURE__ */ React37.createElement("span", null, colorVariable?.label);
2678
3740
  };
2679
3741
  var BoxShadowRepeaterColorIndicator = ({ value }) => {
2680
3742
  const colorVariable = useColorVariable(value);
2681
- return /* @__PURE__ */ React38.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
3743
+ return /* @__PURE__ */ React37.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
2682
3744
  };
2683
3745
 
2684
3746
  // src/repeater-injections.ts
@@ -2687,21 +3749,21 @@ function registerRepeaterInjections() {
2687
3749
  id: "color-variables-background-icon",
2688
3750
  component: BackgroundRepeaterColorIndicator,
2689
3751
  condition: ({ value: prop }) => {
2690
- return hasAssignedColorVariable(import_editor_props4.backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
3752
+ return hasAssignedColorVariable(import_editor_props5.backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
2691
3753
  }
2692
3754
  });
2693
3755
  (0, import_editor_controls13.injectIntoRepeaterItemIcon)({
2694
3756
  id: "color-variables-icon",
2695
3757
  component: BoxShadowRepeaterColorIndicator,
2696
3758
  condition: ({ value: prop }) => {
2697
- return hasAssignedColorVariable(import_editor_props4.shadowPropTypeUtil.extract(prop)?.color);
3759
+ return hasAssignedColorVariable(import_editor_props5.shadowPropTypeUtil.extract(prop)?.color);
2698
3760
  }
2699
3761
  });
2700
3762
  (0, import_editor_controls13.injectIntoRepeaterItemLabel)({
2701
3763
  id: "color-variables-label",
2702
3764
  component: BackgroundRepeaterLabel,
2703
3765
  condition: ({ value: prop }) => {
2704
- return hasAssignedColorVariable(import_editor_props4.backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
3766
+ return hasAssignedColorVariable(import_editor_props5.backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
2705
3767
  }
2706
3768
  });
2707
3769
  }
@@ -2710,34 +3772,45 @@ var hasAssignedColorVariable = (propValue) => {
2710
3772
  };
2711
3773
 
2712
3774
  // src/init.ts
2713
- var { registerPopoverAction } = import_editor_editing_panel11.controlActionsMenu;
3775
+ var { registerPopoverAction } = import_editor_editing_panel8.controlActionsMenu;
2714
3776
  function init() {
2715
3777
  registerVariableTypes();
2716
3778
  registerRepeaterInjections();
2717
- (0, import_editor_editing_panel11.registerControlReplacement)({
3779
+ (0, import_editor_editing_panel8.registerControlReplacement)({
2718
3780
  component: VariableControl,
2719
- condition: ({ value }) => hasAssignedVariable(value)
3781
+ condition: ({ value, placeholder }) => {
3782
+ if (hasVariableAssigned(value)) {
3783
+ return true;
3784
+ }
3785
+ if (value) {
3786
+ return false;
3787
+ }
3788
+ return hasVariableAssigned(placeholder);
3789
+ }
2720
3790
  });
2721
3791
  registerPopoverAction({
2722
3792
  id: "variables",
2723
3793
  useProps: usePropVariableAction
2724
3794
  });
2725
- service.init();
3795
+ service.init().then(() => {
3796
+ initMcp();
3797
+ });
2726
3798
  (0, import_editor.injectIntoTop)({
2727
3799
  id: "canvas-style-variables-render",
2728
3800
  component: StyleVariablesRenderer
2729
3801
  });
2730
3802
  (0, import_editor_panels2.__registerPanel)(panel);
2731
3803
  }
2732
- function hasAssignedVariable(propValue) {
2733
- if (propValue && typeof propValue === "object" && "$$type" in propValue) {
2734
- return hasVariableType(propValue.$$type);
3804
+ function hasVariableAssigned(value) {
3805
+ if ((0, import_editor_props6.isTransformable)(value)) {
3806
+ return hasVariableType(value.$$type);
2735
3807
  }
2736
3808
  return false;
2737
3809
  }
2738
3810
  // Annotate the CommonJS export names for ESM import in node:
2739
3811
  0 && (module.exports = {
2740
3812
  init,
2741
- registerVariableType
3813
+ registerVariableType,
3814
+ registerVariableTypes
2742
3815
  });
2743
3816
  //# sourceMappingURL=index.js.map