@elementor/editor-variables 3.33.0-256 → 3.33.0-258

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -52,6 +52,43 @@ var import_icons6 = require("@elementor/icons");
52
52
  var import_ui12 = require("@elementor/ui");
53
53
  var import_i18n9 = require("@wordpress/i18n");
54
54
 
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
+ };
91
+
55
92
  // src/utils/validations.ts
56
93
  var import_icons = require("@elementor/icons");
57
94
  var import_i18n = require("@wordpress/i18n");
@@ -148,146 +185,70 @@ var validateValue = (value) => {
148
185
  return "";
149
186
  };
150
187
 
151
- // src/components/ui/delete-confirmation-dialog.tsx
152
- var React = __toESM(require("react"));
153
- var import_icons2 = require("@elementor/icons");
154
- var import_ui = require("@elementor/ui");
155
- var import_i18n2 = require("@wordpress/i18n");
156
- var TITLE_ID = "delete-variable-dialog";
157
- var DeleteConfirmationDialog = ({
158
- open,
159
- label,
160
- closeDialog,
161
- onConfirm
162
- }) => {
163
- return /* @__PURE__ */ React.createElement(import_ui.Dialog, { open, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React.createElement(import_ui.DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React.createElement(import_icons2.AlertOctagonFilledIcon, { color: "error" }), (0, import_i18n2.__)("Delete this variable?", "elementor")), /* @__PURE__ */ React.createElement(import_ui.DialogContent, null, /* @__PURE__ */ React.createElement(import_ui.DialogContentText, { variant: "body2", color: "textPrimary" }, (0, import_i18n2.__)("All elements using", "elementor"), "\xA0", /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "subtitle2", component: "span", sx: { lineBreak: "anywhere" } }, label), "\xA0", (0, import_i18n2.__)("will keep their current values, but the variable itself will be removed.", "elementor"))), /* @__PURE__ */ React.createElement(import_ui.DialogActions, null, /* @__PURE__ */ React.createElement(import_ui.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n2.__)("Not now", "elementor")), /* @__PURE__ */ React.createElement(import_ui.Button, { variant: "contained", color: "error", onClick: onConfirm }, (0, import_i18n2.__)("Delete", "elementor"))));
164
- };
188
+ // src/variables-registry/create-variable-type-registry.ts
189
+ var import_editor_canvas3 = require("@elementor/editor-canvas");
190
+ var import_editor_editing_panel = require("@elementor/editor-editing-panel");
165
191
 
166
- // src/components/ui/empty-state.tsx
167
- var React2 = __toESM(require("react"));
192
+ // src/transformers/inheritance-transformer.tsx
193
+ var React = __toESM(require("react"));
194
+ var import_editor_canvas = require("@elementor/editor-canvas");
168
195
  var import_ui2 = require("@elementor/ui");
169
196
  var import_i18n3 = require("@wordpress/i18n");
170
197
 
171
- // src/hooks/use-permissions.ts
172
- var import_editor_current_user = require("@elementor/editor-current-user");
173
- var usePermissions = () => {
174
- const { canUser } = (0, import_editor_current_user.useCurrentUserCapabilities)();
175
- return {
176
- canAssign: () => canUser("edit_posts"),
177
- canUnlink: () => canUser("edit_posts"),
178
- canAdd: () => canUser("manage_options"),
179
- canDelete: () => canUser("manage_options"),
180
- canEdit: () => canUser("manage_options"),
181
- canRestore: () => canUser("manage_options"),
182
- canManageSettings: () => canUser("manage_options")
183
- };
184
- };
185
-
186
- // src/components/ui/empty-state.tsx
187
- var EmptyState = ({ icon, title, message, onAdd }) => {
188
- const canAdd = usePermissions().canAdd();
189
- return /* @__PURE__ */ React2.createElement(
190
- import_ui2.Stack,
191
- {
192
- gap: 1,
193
- alignItems: "center",
194
- justifyContent: "flex-start",
195
- height: "100%",
196
- color: "text.secondary",
197
- sx: { p: 2.5, pt: 8, pb: 5.5 }
198
- },
199
- icon,
200
- canAdd ? /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(Content, { title, message }), onAdd && /* @__PURE__ */ React2.createElement(import_ui2.Button, { variant: "outlined", color: "secondary", size: "small", onClick: onAdd }, (0, import_i18n3.__)("Create a variable", "elementor"))) : /* @__PURE__ */ React2.createElement(
201
- Content,
202
- {
203
- title: (0, import_i18n3.__)("There are no variables", "elementor"),
204
- message: (0, import_i18n3.__)("With your current role, you can only connect and detach variables.", "elementor")
205
- }
206
- )
207
- );
208
- };
209
- function Content({ title, message }) {
210
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(import_ui2.Typography, { align: "center", variant: "subtitle2" }, title), /* @__PURE__ */ React2.createElement(import_ui2.Typography, { align: "center", variant: "caption", maxWidth: "180px" }, message));
211
- }
198
+ // src/components/ui/color-indicator.tsx
199
+ var import_ui = require("@elementor/ui");
200
+ var ColorIndicator = (0, import_ui.styled)(import_ui.UnstableColorIndicator)(({ theme }) => ({
201
+ borderRadius: `${theme.shape.borderRadius / 2}px`,
202
+ marginRight: theme.spacing(0.25)
203
+ }));
212
204
 
213
- // src/components/ui/no-search-results.tsx
214
- var React3 = __toESM(require("react"));
215
- var import_ui3 = require("@elementor/ui");
216
- var import_i18n4 = require("@wordpress/i18n");
217
- var NoSearchResults = ({ searchValue, onClear, icon }) => {
218
- return /* @__PURE__ */ React3.createElement(
219
- import_ui3.Stack,
220
- {
221
- gap: 1,
222
- alignItems: "center",
223
- justifyContent: "center",
224
- p: 2.5,
225
- color: "text.secondary",
226
- sx: { pb: 3.5, pt: 8 }
227
- },
228
- icon,
229
- /* @__PURE__ */ React3.createElement(import_ui3.Typography, { align: "center", variant: "subtitle2" }, (0, import_i18n4.__)("Sorry, nothing matched", "elementor"), /* @__PURE__ */ React3.createElement("br", null), "\u201C", searchValue, "\u201D."),
230
- /* @__PURE__ */ React3.createElement(import_ui3.Typography, { align: "center", variant: "caption", sx: { display: "flex", flexDirection: "column" } }, (0, import_i18n4.__)("Try something else.", "elementor"), /* @__PURE__ */ React3.createElement(import_ui3.Link, { color: "text.secondary", variant: "caption", component: "button", onClick: onClear }, (0, import_i18n4.__)("Clear & try again", "elementor")))
231
- );
232
- };
205
+ // src/prop-types/color-variable-prop-type.ts
206
+ var import_editor_props = require("@elementor/editor-props");
207
+ var import_schema = require("@elementor/schema");
208
+ var colorVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-color-variable", import_schema.z.string());
233
209
 
234
- // src/components/variables-manager/hooks/use-auto-edit.ts
235
- var import_react = require("react");
236
- var useAutoEdit = () => {
237
- const [autoEditVariableId, setAutoEditVariableId] = (0, import_react.useState)(void 0);
238
- const startAutoEdit = (0, import_react.useCallback)((variableId) => {
239
- setAutoEditVariableId(variableId);
240
- }, []);
241
- const handleAutoEditComplete = (0, import_react.useCallback)(() => {
242
- setTimeout(() => {
243
- setAutoEditVariableId(void 0);
244
- }, 100);
245
- }, []);
246
- return {
247
- autoEditVariableId,
248
- startAutoEdit,
249
- handleAutoEditComplete
250
- };
251
- };
210
+ // src/service.ts
211
+ var import_i18n2 = require("@wordpress/i18n");
252
212
 
253
- // src/components/variables-manager/hooks/use-error-navigation.ts
254
- var import_react2 = require("react");
255
- var useErrorNavigation = () => {
256
- const currentIndexRef = (0, import_react2.useRef)(0);
257
- const createNavigationCallback = (0, import_react2.useCallback)(
258
- (ids, onNavigate, onComplete) => {
259
- return () => {
260
- if (!ids?.length) {
261
- return;
262
- }
263
- const currentIndex = currentIndexRef.current;
264
- const currentId = ids[currentIndex];
265
- if (currentId) {
266
- onNavigate(currentId);
267
- const nextIndex = currentIndex + 1;
268
- if (nextIndex >= ids.length) {
269
- onComplete();
270
- currentIndexRef.current = 0;
271
- } else {
272
- currentIndexRef.current = nextIndex;
273
- }
274
- }
275
- };
276
- },
277
- []
278
- );
279
- const resetNavigation = (0, import_react2.useCallback)(() => {
280
- currentIndexRef.current = 0;
281
- }, []);
282
- return {
283
- createNavigationCallback,
284
- resetNavigation
285
- };
213
+ // src/api.ts
214
+ var import_http_client = require("@elementor/http-client");
215
+ var BASE_PATH = "elementor/v1/variables";
216
+ var apiClient = {
217
+ list: () => {
218
+ return (0, import_http_client.httpService)().get(BASE_PATH + "/list");
219
+ },
220
+ create: (type, label, value) => {
221
+ return (0, import_http_client.httpService)().post(BASE_PATH + "/create", {
222
+ type,
223
+ label,
224
+ value
225
+ });
226
+ },
227
+ update: (id2, label, value) => {
228
+ return (0, import_http_client.httpService)().put(BASE_PATH + "/update", {
229
+ id: id2,
230
+ label,
231
+ value
232
+ });
233
+ },
234
+ delete: (id2) => {
235
+ return (0, import_http_client.httpService)().post(BASE_PATH + "/delete", { id: id2 });
236
+ },
237
+ restore: (id2, label, value) => {
238
+ const payload = { id: id2 };
239
+ if (label) {
240
+ payload.label = label;
241
+ }
242
+ if (value) {
243
+ payload.value = value;
244
+ }
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);
249
+ }
286
250
  };
287
251
 
288
- // src/components/variables-manager/hooks/use-variables-manager-state.ts
289
- var import_react5 = require("react");
290
-
291
252
  // src/batch-operations.ts
292
253
  var generateTempId = () => {
293
254
  const timestamp = Date.now().toString(36);
@@ -348,78 +309,6 @@ var buildOperationsArray = (originalVariables, currentVariables) => {
348
309
  });
349
310
  };
350
311
 
351
- // src/hooks/use-prop-variables.ts
352
- var import_react4 = require("react");
353
- var import_editor_controls = require("@elementor/editor-controls");
354
-
355
- // src/context/variable-type-context.tsx
356
- var React5 = __toESM(require("react"));
357
- var import_react3 = require("react");
358
-
359
- // src/variables-registry/create-variable-type-registry.ts
360
- var import_editor_canvas3 = require("@elementor/editor-canvas");
361
- var import_editor_editing_panel = require("@elementor/editor-editing-panel");
362
-
363
- // src/transformers/inheritance-transformer.tsx
364
- var React4 = __toESM(require("react"));
365
- var import_editor_canvas = require("@elementor/editor-canvas");
366
- var import_ui5 = require("@elementor/ui");
367
- var import_i18n6 = require("@wordpress/i18n");
368
-
369
- // src/components/ui/color-indicator.tsx
370
- var import_ui4 = require("@elementor/ui");
371
- var ColorIndicator = (0, import_ui4.styled)(import_ui4.UnstableColorIndicator)(({ theme }) => ({
372
- borderRadius: `${theme.shape.borderRadius / 2}px`,
373
- marginRight: theme.spacing(0.25)
374
- }));
375
-
376
- // src/prop-types/color-variable-prop-type.ts
377
- var import_editor_props = require("@elementor/editor-props");
378
- var import_schema = require("@elementor/schema");
379
- var colorVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-color-variable", import_schema.z.string());
380
-
381
- // src/service.ts
382
- var import_i18n5 = require("@wordpress/i18n");
383
-
384
- // src/api.ts
385
- var import_http_client = require("@elementor/http-client");
386
- var BASE_PATH = "elementor/v1/variables";
387
- var apiClient = {
388
- list: () => {
389
- return (0, import_http_client.httpService)().get(BASE_PATH + "/list");
390
- },
391
- create: (type, label, value) => {
392
- return (0, import_http_client.httpService)().post(BASE_PATH + "/create", {
393
- type,
394
- label,
395
- value
396
- });
397
- },
398
- update: (id2, label, value) => {
399
- return (0, import_http_client.httpService)().put(BASE_PATH + "/update", {
400
- id: id2,
401
- label,
402
- value
403
- });
404
- },
405
- delete: (id2) => {
406
- return (0, import_http_client.httpService)().post(BASE_PATH + "/delete", { id: id2 });
407
- },
408
- restore: (id2, label, value) => {
409
- const payload = { id: id2 };
410
- if (label) {
411
- payload.label = label;
412
- }
413
- if (value) {
414
- payload.value = value;
415
- }
416
- return (0, import_http_client.httpService)().post(BASE_PATH + "/restore", payload);
417
- },
418
- batch: (payload) => {
419
- return (0, import_http_client.httpService)().post(BASE_PATH + "/batch", payload);
420
- }
421
- };
422
-
423
312
  // src/storage.ts
424
313
  var STORAGE_KEY = "elementor-global-variables";
425
314
  var STORAGE_WATERMARK_KEY = "elementor-global-variables-watermark";
@@ -584,7 +473,7 @@ var service = {
584
473
  return apiClient.create(type, label, value).then((response) => {
585
474
  const { success, data: payload } = response.data;
586
475
  if (!success) {
587
- const errorMessage = payload?.message || (0, import_i18n5.__)("Unexpected response from server", "elementor");
476
+ const errorMessage = payload?.message || (0, import_i18n2.__)("Unexpected response from server", "elementor");
588
477
  throw new Error(errorMessage);
589
478
  }
590
479
  return payload;
@@ -606,7 +495,7 @@ var service = {
606
495
  return apiClient.update(id2, label, value).then((response) => {
607
496
  const { success, data: payload } = response.data;
608
497
  if (!success) {
609
- const errorMessage = payload?.message || (0, import_i18n5.__)("Unexpected response from server", "elementor");
498
+ const errorMessage = payload?.message || (0, import_i18n2.__)("Unexpected response from server", "elementor");
610
499
  throw new Error(errorMessage);
611
500
  }
612
501
  return payload;
@@ -739,11 +628,11 @@ var inheritanceTransformer = (0, import_editor_canvas.createTransformer)((id2) =
739
628
  const variables = service.variables();
740
629
  const variable = variables[id2];
741
630
  if (!variable) {
742
- return /* @__PURE__ */ React4.createElement("span", null, (0, import_i18n6.__)("Missing variable", "elementor"));
631
+ return /* @__PURE__ */ React.createElement("span", null, (0, import_i18n3.__)("Missing variable", "elementor"));
743
632
  }
744
633
  const showColorIndicator = variable.type === colorVariablePropTypeUtil.key;
745
634
  const css = resolveCssVariable(id2, variable);
746
- return /* @__PURE__ */ React4.createElement(import_ui5.Stack, { direction: "row", spacing: 0.5, sx: { paddingInline: "1px" }, alignItems: "center" }, showColorIndicator && /* @__PURE__ */ React4.createElement(ColorIndicator, { size: "inherit", value: variable.value }), /* @__PURE__ */ React4.createElement(import_ui5.Typography, { variant: "caption", overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis" }, css));
635
+ return /* @__PURE__ */ React.createElement(import_ui2.Stack, { direction: "row", spacing: 0.5, sx: { paddingInline: "1px" }, alignItems: "center" }, showColorIndicator && /* @__PURE__ */ React.createElement(ColorIndicator, { size: "inherit", value: variable.value }), /* @__PURE__ */ React.createElement(import_ui2.Typography, { variant: "caption", overflow: "hidden", whiteSpace: "nowrap", textOverflow: "ellipsis" }, css));
747
636
  });
748
637
 
749
638
  // src/transformers/variable-transformer.ts
@@ -825,7 +714,153 @@ function createVariableTypeRegistry() {
825
714
  // src/variables-registry/variable-type-registry.ts
826
715
  var { registerVariableType, getVariableType, getVariableTypes, hasVariableType } = createVariableTypeRegistry();
827
716
 
717
+ // src/components/ui/delete-confirmation-dialog.tsx
718
+ var React2 = __toESM(require("react"));
719
+ var import_icons2 = require("@elementor/icons");
720
+ var import_ui3 = require("@elementor/ui");
721
+ var import_i18n4 = require("@wordpress/i18n");
722
+ var TITLE_ID = "delete-variable-dialog";
723
+ var DeleteConfirmationDialog = ({
724
+ open,
725
+ label,
726
+ closeDialog,
727
+ onConfirm
728
+ }) => {
729
+ 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"))));
730
+ };
731
+
732
+ // src/components/ui/empty-state.tsx
733
+ var React3 = __toESM(require("react"));
734
+ var import_ui4 = require("@elementor/ui");
735
+ var import_i18n5 = require("@wordpress/i18n");
736
+
737
+ // src/hooks/use-permissions.ts
738
+ var import_editor_current_user = require("@elementor/editor-current-user");
739
+ var usePermissions = () => {
740
+ const { canUser } = (0, import_editor_current_user.useCurrentUserCapabilities)();
741
+ return {
742
+ canAssign: () => canUser("edit_posts"),
743
+ canUnlink: () => canUser("edit_posts"),
744
+ canAdd: () => canUser("manage_options"),
745
+ canDelete: () => canUser("manage_options"),
746
+ canEdit: () => canUser("manage_options"),
747
+ canRestore: () => canUser("manage_options"),
748
+ canManageSettings: () => canUser("manage_options")
749
+ };
750
+ };
751
+
752
+ // src/components/ui/empty-state.tsx
753
+ var EmptyState = ({ icon, title, message, onAdd }) => {
754
+ const canAdd = usePermissions().canAdd();
755
+ return /* @__PURE__ */ React3.createElement(
756
+ import_ui4.Stack,
757
+ {
758
+ gap: 1,
759
+ alignItems: "center",
760
+ justifyContent: "flex-start",
761
+ height: "100%",
762
+ color: "text.secondary",
763
+ sx: { p: 2.5, pt: 8, pb: 5.5 }
764
+ },
765
+ icon,
766
+ 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(
767
+ Content,
768
+ {
769
+ title: (0, import_i18n5.__)("There are no variables", "elementor"),
770
+ message: (0, import_i18n5.__)("With your current role, you can only connect and detach variables.", "elementor")
771
+ }
772
+ )
773
+ );
774
+ };
775
+ function Content({ title, message }) {
776
+ 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));
777
+ }
778
+
779
+ // src/components/ui/no-search-results.tsx
780
+ var React4 = __toESM(require("react"));
781
+ var import_ui5 = require("@elementor/ui");
782
+ var import_i18n6 = require("@wordpress/i18n");
783
+ var NoSearchResults = ({ searchValue, onClear, icon }) => {
784
+ return /* @__PURE__ */ React4.createElement(
785
+ import_ui5.Stack,
786
+ {
787
+ gap: 1,
788
+ alignItems: "center",
789
+ justifyContent: "center",
790
+ p: 2.5,
791
+ color: "text.secondary",
792
+ sx: { pb: 3.5, pt: 8 }
793
+ },
794
+ icon,
795
+ /* @__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."),
796
+ /* @__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")))
797
+ );
798
+ };
799
+
800
+ // src/components/variables-manager/hooks/use-auto-edit.ts
801
+ var import_react = require("react");
802
+ var useAutoEdit = () => {
803
+ const [autoEditVariableId, setAutoEditVariableId] = (0, import_react.useState)(void 0);
804
+ const startAutoEdit = (0, import_react.useCallback)((variableId) => {
805
+ setAutoEditVariableId(variableId);
806
+ }, []);
807
+ const handleAutoEditComplete = (0, import_react.useCallback)(() => {
808
+ setTimeout(() => {
809
+ setAutoEditVariableId(void 0);
810
+ }, 100);
811
+ }, []);
812
+ return {
813
+ autoEditVariableId,
814
+ startAutoEdit,
815
+ handleAutoEditComplete
816
+ };
817
+ };
818
+
819
+ // src/components/variables-manager/hooks/use-error-navigation.ts
820
+ var import_react2 = require("react");
821
+ var useErrorNavigation = () => {
822
+ const currentIndexRef = (0, import_react2.useRef)(0);
823
+ const createNavigationCallback = (0, import_react2.useCallback)(
824
+ (ids, onNavigate, onComplete) => {
825
+ return () => {
826
+ if (!ids?.length) {
827
+ return;
828
+ }
829
+ const currentIndex = currentIndexRef.current;
830
+ const currentId = ids[currentIndex];
831
+ if (currentId) {
832
+ onNavigate(currentId);
833
+ const nextIndex = currentIndex + 1;
834
+ if (nextIndex >= ids.length) {
835
+ onComplete();
836
+ currentIndexRef.current = 0;
837
+ } else {
838
+ currentIndexRef.current = nextIndex;
839
+ }
840
+ }
841
+ };
842
+ },
843
+ []
844
+ );
845
+ const resetNavigation = (0, import_react2.useCallback)(() => {
846
+ currentIndexRef.current = 0;
847
+ }, []);
848
+ return {
849
+ createNavigationCallback,
850
+ resetNavigation
851
+ };
852
+ };
853
+
854
+ // src/components/variables-manager/hooks/use-variables-manager-state.ts
855
+ var import_react5 = require("react");
856
+
857
+ // src/hooks/use-prop-variables.ts
858
+ var import_react4 = require("react");
859
+ var import_editor_controls = require("@elementor/editor-controls");
860
+
828
861
  // src/context/variable-type-context.tsx
862
+ var React5 = __toESM(require("react"));
863
+ var import_react3 = require("react");
829
864
  var VariableTypeContext = (0, import_react3.createContext)(null);
830
865
  function VariableTypeProvider({ children, propTypeKey }) {
831
866
  return /* @__PURE__ */ React5.createElement(VariableTypeContext.Provider, { value: propTypeKey }, children);
@@ -1003,6 +1038,7 @@ var VariableManagerCreateMenu = ({
1003
1038
  onClick: () => {
1004
1039
  const defaultName = getDefaultName(variables, key, variable.variableType);
1005
1040
  onCreate(key, defaultName, variable.defaultValue || "");
1041
+ trackVariablesManagerEvent({ action: "add", varType: variable.variableType });
1006
1042
  }
1007
1043
  };
1008
1044
  });
@@ -1662,7 +1698,9 @@ function VariablesManagerPanel() {
1662
1698
  try {
1663
1699
  setServerError(null);
1664
1700
  resetNavigation();
1665
- return await handleSave();
1701
+ const result = await handleSave();
1702
+ trackVariablesManagerEvent({ action: "saveChanges" });
1703
+ return result;
1666
1704
  } catch (error) {
1667
1705
  const mappedError = mapServerError(error);
1668
1706
  const duplicatedIds = mappedError?.action?.data?.duplicatedIds;
@@ -1694,8 +1732,11 @@ function VariablesManagerPanel() {
1694
1732
  icon: import_icons6.TrashIcon,
1695
1733
  color: "error.main",
1696
1734
  onClick: (itemId) => {
1697
- if (variables[itemId]) {
1698
- setDeleteConfirmation({ id: itemId, label: variables[itemId].label });
1735
+ const variable = variables[itemId];
1736
+ if (variable) {
1737
+ setDeleteConfirmation({ id: itemId, label: variable.label });
1738
+ const variableTypeOptions = getVariableType(variable.type);
1739
+ trackVariablesManagerEvent({ action: "delete", varType: variableTypeOptions?.variableType });
1699
1740
  }
1700
1741
  }
1701
1742
  }
@@ -1962,24 +2003,6 @@ var unwrapValue = (input) => {
1962
2003
  return input;
1963
2004
  };
1964
2005
 
1965
- // src/utils/tracking.ts
1966
- var import_mixpanel = require("@elementor/mixpanel");
1967
- var trackVariableEvent = ({ varType, controlPath, action }) => {
1968
- const { dispatchEvent, config } = (0, import_mixpanel.getMixpanel)();
1969
- if (!config?.names?.variables?.[action]) {
1970
- return;
1971
- }
1972
- const name = config.names.variables[action];
1973
- dispatchEvent?.(name, {
1974
- location: config?.locations?.variables || "",
1975
- secondaryLocation: config?.secondaryLocations?.variablesPopover || "",
1976
- trigger: config?.triggers?.click || "",
1977
- var_type: varType,
1978
- control_path: controlPath,
1979
- action_type: name
1980
- });
1981
- };
1982
-
1983
2006
  // src/components/ui/form-field.tsx
1984
2007
  var React14 = __toESM(require("react"));
1985
2008
  var import_ui14 = require("@elementor/ui");
@@ -2474,13 +2497,21 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings }) => {
2474
2497
  );
2475
2498
  }
2476
2499
  if (onSettings) {
2500
+ const handleOpenManager = () => {
2501
+ onSettings();
2502
+ trackVariablesManagerEvent({
2503
+ action: "openManager",
2504
+ varType: variableType,
2505
+ controlPath: path.join(".")
2506
+ });
2507
+ };
2477
2508
  actions.push(
2478
2509
  /* @__PURE__ */ React19.createElement(import_ui20.Tooltip, { key: "settings", placement: "top", title: MANAGER_LABEL }, /* @__PURE__ */ React19.createElement(
2479
2510
  import_ui20.IconButton,
2480
2511
  {
2481
2512
  id: "variables-manager-button",
2482
2513
  size: SIZE5,
2483
- onClick: onSettings,
2514
+ onClick: handleOpenManager,
2484
2515
  "aria-label": MANAGER_LABEL
2485
2516
  },
2486
2517
  /* @__PURE__ */ React19.createElement(import_icons11.SettingsIcon, { fontSize: SIZE5 })