@elementor/editor-variables 4.0.0-manual → 4.0.0
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 +549 -400
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +478 -325
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
- package/src/components/global-styles-import-listener.tsx +33 -0
- package/src/components/open-panel-from-event.tsx +46 -0
- package/src/components/ui/variable-promotion-chip.tsx +14 -4
- package/src/components/variable-creation.tsx +2 -1
- package/src/components/variable-edit.tsx +2 -1
- package/src/components/variable-restore.tsx +2 -1
- package/src/components/variables-manager/ui/variable-table-row.tsx +3 -0
- package/src/components/variables-manager/variables-manager-create-menu.tsx +16 -3
- package/src/components/variables-manager/variables-manager-panel.tsx +31 -14
- package/src/components/variables-selection.tsx +18 -1
- package/src/init.ts +14 -1
- package/src/mcp/index.ts +13 -7
- package/src/mcp/manage-variable-tool.ts +4 -3
- package/src/mcp/variables-resource.ts +5 -8
- package/src/register-variable-types.tsx +15 -11
- package/src/renderers/style-variables-renderer.tsx +1 -1
- package/src/service.ts +5 -5
- package/src/utils/tracking.ts +29 -0
package/dist/index.js
CHANGED
|
@@ -44,182 +44,17 @@ module.exports = __toCommonJS(index_exports);
|
|
|
44
44
|
|
|
45
45
|
// src/init.ts
|
|
46
46
|
var import_editor = require("@elementor/editor");
|
|
47
|
-
var
|
|
47
|
+
var import_editor_controls18 = require("@elementor/editor-controls");
|
|
48
|
+
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
48
49
|
var import_editor_panels2 = require("@elementor/editor-panels");
|
|
49
50
|
var import_editor_props7 = require("@elementor/editor-props");
|
|
50
51
|
var import_menus = require("@elementor/menus");
|
|
51
52
|
|
|
52
|
-
// src/components/
|
|
53
|
-
var
|
|
54
|
-
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
55
|
-
|
|
56
|
-
// src/components/variables-manager/variables-manager-panel.tsx
|
|
57
|
-
var React14 = __toESM(require("react"));
|
|
58
|
-
var import_react13 = require("react");
|
|
59
|
-
var import_editor_current_user2 = require("@elementor/editor-current-user");
|
|
60
|
-
var import_editor_panels = require("@elementor/editor-panels");
|
|
61
|
-
var import_editor_ui5 = require("@elementor/editor-ui");
|
|
62
|
-
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
63
|
-
var import_icons5 = require("@elementor/icons");
|
|
64
|
-
var import_ui14 = require("@elementor/ui");
|
|
65
|
-
var import_i18n10 = require("@wordpress/i18n");
|
|
66
|
-
|
|
67
|
-
// src/utils/tracking.ts
|
|
68
|
-
var import_events = require("@elementor/events");
|
|
69
|
-
var trackVariableEvent = ({ varType, controlPath, action }) => {
|
|
70
|
-
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
71
|
-
if (!config?.names?.variables?.[action]) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const name = config.names.variables[action];
|
|
75
|
-
dispatchEvent?.(name, {
|
|
76
|
-
location: config?.locations?.variables || "",
|
|
77
|
-
secondaryLocation: config?.secondaryLocations?.variablesPopover || "",
|
|
78
|
-
trigger: config?.triggers?.click || "",
|
|
79
|
-
var_type: varType,
|
|
80
|
-
control_path: controlPath,
|
|
81
|
-
action_type: name
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
var trackVariablesManagerEvent = ({ action, varType, controlPath }) => {
|
|
85
|
-
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
86
|
-
if (!config?.names?.variables?.[action]) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
const name = config.names.variables[action];
|
|
90
|
-
const eventData = {
|
|
91
|
-
location: config?.locations?.variablesManager || "",
|
|
92
|
-
trigger: config?.triggers?.click || "",
|
|
93
|
-
action_type: name
|
|
94
|
-
};
|
|
95
|
-
if (varType) {
|
|
96
|
-
eventData.var_type = varType;
|
|
97
|
-
}
|
|
98
|
-
if (controlPath) {
|
|
99
|
-
eventData.style_control_path = controlPath;
|
|
100
|
-
}
|
|
101
|
-
dispatchEvent?.(name, eventData);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// src/utils/validations.ts
|
|
105
|
-
var import_icons = require("@elementor/icons");
|
|
106
|
-
var import_i18n = require("@wordpress/i18n");
|
|
107
|
-
var ERROR_MESSAGES = {
|
|
108
|
-
MISSING_VARIABLE_NAME: (0, import_i18n.__)("Give your variable a name.", "elementor"),
|
|
109
|
-
MISSING_VARIABLE_VALUE: (0, import_i18n.__)("Add a value to complete your variable.", "elementor"),
|
|
110
|
-
INVALID_CHARACTERS: (0, import_i18n.__)("Use letters, numbers, dashes (-), or underscores (_) for the name.", "elementor"),
|
|
111
|
-
NO_NON_SPECIAL_CHARACTER: (0, import_i18n.__)("Names have to include at least one non-special character.", "elementor"),
|
|
112
|
-
VARIABLE_LABEL_MAX_LENGTH: (0, import_i18n.__)("Keep names up to 50 characters.", "elementor"),
|
|
113
|
-
DUPLICATED_LABEL: (0, import_i18n.__)("This variable name already exists. Please choose a unique name.", "elementor"),
|
|
114
|
-
UNEXPECTED_ERROR: (0, import_i18n.__)("There was a glitch. Try saving your variable again.", "elementor"),
|
|
115
|
-
BATCH: {
|
|
116
|
-
DUPLICATED_LABELS: (count, name) => (
|
|
117
|
-
// eslint-disable-next-line @wordpress/i18n-translator-comments
|
|
118
|
-
(0, import_i18n.sprintf)((0, import_i18n.__)("We found %1$d duplicated %2$s.", "elementor"), count, name)
|
|
119
|
-
),
|
|
120
|
-
UNEXPECTED_ERROR: (0, import_i18n.__)("There was a glitch.", "elementor"),
|
|
121
|
-
DUPLICATED_LABEL_ACTION: (0, import_i18n.__)("Take me there", "elementor"),
|
|
122
|
-
DUPLICATED_LABEL_ACTION_MESSAGE: (0, import_i18n.__)("Please rename the variables.", "elementor"),
|
|
123
|
-
UNEXPECTED_ERROR_ACTION_MESSAGE: (0, import_i18n.__)("Try saving your variables again.", "elementor")
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
var VARIABLE_LABEL_MAX_LENGTH = 50;
|
|
127
|
-
var mapServerError = (error) => {
|
|
128
|
-
if (error?.response?.data?.code === "duplicated_label") {
|
|
129
|
-
return {
|
|
130
|
-
field: "label",
|
|
131
|
-
message: ERROR_MESSAGES.DUPLICATED_LABEL
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
if (error?.response?.data?.code === "batch_duplicated_label") {
|
|
135
|
-
const errorData = error?.response?.data?.data ?? {};
|
|
136
|
-
const count = Object.keys(errorData).length;
|
|
137
|
-
const name = count === 1 ? "name" : "names";
|
|
138
|
-
const duplicatedIds = Object.keys(errorData);
|
|
139
|
-
return {
|
|
140
|
-
field: "label",
|
|
141
|
-
message: ERROR_MESSAGES.BATCH.DUPLICATED_LABELS(count, name),
|
|
142
|
-
severity: "error",
|
|
143
|
-
IconComponent: import_icons.AlertTriangleFilledIcon,
|
|
144
|
-
action: {
|
|
145
|
-
label: ERROR_MESSAGES.BATCH.DUPLICATED_LABEL_ACTION,
|
|
146
|
-
message: ERROR_MESSAGES.BATCH.DUPLICATED_LABEL_ACTION_MESSAGE,
|
|
147
|
-
data: {
|
|
148
|
-
duplicatedIds
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
if (error?.response?.data?.code === "batch_operation_failed") {
|
|
154
|
-
return {
|
|
155
|
-
field: "label",
|
|
156
|
-
message: ERROR_MESSAGES.BATCH.UNEXPECTED_ERROR,
|
|
157
|
-
severity: "secondary",
|
|
158
|
-
IconComponent: import_icons.InfoCircleFilledIcon,
|
|
159
|
-
action: {
|
|
160
|
-
message: ERROR_MESSAGES.BATCH.UNEXPECTED_ERROR_ACTION_MESSAGE
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
return void 0;
|
|
165
|
-
};
|
|
166
|
-
var validateLabel = (name, variables) => {
|
|
167
|
-
if (!name.trim()) {
|
|
168
|
-
return ERROR_MESSAGES.MISSING_VARIABLE_NAME;
|
|
169
|
-
}
|
|
170
|
-
const allowedChars = /^[a-zA-Z0-9_-]+$/;
|
|
171
|
-
if (!allowedChars.test(name)) {
|
|
172
|
-
return ERROR_MESSAGES.INVALID_CHARACTERS;
|
|
173
|
-
}
|
|
174
|
-
const hasAlphanumeric = /[a-zA-Z0-9]/;
|
|
175
|
-
if (!hasAlphanumeric.test(name)) {
|
|
176
|
-
return ERROR_MESSAGES.NO_NON_SPECIAL_CHARACTER;
|
|
177
|
-
}
|
|
178
|
-
if (VARIABLE_LABEL_MAX_LENGTH < name.length) {
|
|
179
|
-
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
180
|
-
}
|
|
181
|
-
if (Object.values(variables ?? {}).some((variable) => variable.label === name)) {
|
|
182
|
-
return ERROR_MESSAGES.DUPLICATED_LABEL;
|
|
183
|
-
}
|
|
184
|
-
return "";
|
|
185
|
-
};
|
|
186
|
-
var labelHint = (name) => {
|
|
187
|
-
const hintThreshold = VARIABLE_LABEL_MAX_LENGTH * 0.8 - 1;
|
|
188
|
-
if (hintThreshold < name.length) {
|
|
189
|
-
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
190
|
-
}
|
|
191
|
-
return "";
|
|
192
|
-
};
|
|
193
|
-
var validateValue = (value) => {
|
|
194
|
-
if (!value.trim()) {
|
|
195
|
-
return ERROR_MESSAGES.MISSING_VARIABLE_VALUE;
|
|
196
|
-
}
|
|
197
|
-
return "";
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
// src/variables-registry/create-variable-type-registry.ts
|
|
201
|
-
var import_editor_canvas3 = require("@elementor/editor-canvas");
|
|
202
|
-
|
|
203
|
-
// src/transformers/inheritance-transformer.tsx
|
|
204
|
-
var React = __toESM(require("react"));
|
|
205
|
-
var import_editor_canvas = require("@elementor/editor-canvas");
|
|
206
|
-
var import_ui2 = require("@elementor/ui");
|
|
207
|
-
var import_i18n3 = require("@wordpress/i18n");
|
|
208
|
-
|
|
209
|
-
// src/components/ui/color-indicator.tsx
|
|
210
|
-
var import_ui = require("@elementor/ui");
|
|
211
|
-
var ColorIndicator = (0, import_ui.styled)(import_ui.UnstableColorIndicator)(({ theme }) => ({
|
|
212
|
-
borderRadius: `${theme.shape.borderRadius / 2}px`,
|
|
213
|
-
marginRight: theme.spacing(0.25)
|
|
214
|
-
}));
|
|
215
|
-
|
|
216
|
-
// src/prop-types/color-variable-prop-type.ts
|
|
217
|
-
var import_editor_props = require("@elementor/editor-props");
|
|
218
|
-
var import_schema = require("@elementor/schema");
|
|
219
|
-
var colorVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-color-variable", import_schema.z.string());
|
|
53
|
+
// src/components/global-styles-import-listener.tsx
|
|
54
|
+
var import_react = require("react");
|
|
220
55
|
|
|
221
56
|
// src/service.ts
|
|
222
|
-
var
|
|
57
|
+
var import_i18n = require("@wordpress/i18n");
|
|
223
58
|
|
|
224
59
|
// src/api.ts
|
|
225
60
|
var import_http_client = require("@elementor/http-client");
|
|
@@ -384,9 +219,9 @@ var Storage = class {
|
|
|
384
219
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
385
220
|
|
|
386
221
|
// src/prop-types/font-variable-prop-type.ts
|
|
387
|
-
var
|
|
388
|
-
var
|
|
389
|
-
var fontVariablePropTypeUtil = (0,
|
|
222
|
+
var import_editor_props = require("@elementor/editor-props");
|
|
223
|
+
var import_schema = require("@elementor/schema");
|
|
224
|
+
var fontVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-font-variable", import_schema.z.string());
|
|
390
225
|
|
|
391
226
|
// src/create-style-variables-repository.ts
|
|
392
227
|
var createStyleVariablesRepository = () => {
|
|
@@ -498,7 +333,7 @@ var service = {
|
|
|
498
333
|
return apiClient.create(type, label, value).then((response) => {
|
|
499
334
|
const { success, data: payload } = response.data;
|
|
500
335
|
if (!success) {
|
|
501
|
-
const errorMessage = payload?.message || (0,
|
|
336
|
+
const errorMessage = payload?.message || (0, import_i18n.__)("Unexpected response from server", "elementor");
|
|
502
337
|
throw new Error(errorMessage);
|
|
503
338
|
}
|
|
504
339
|
return payload;
|
|
@@ -520,7 +355,7 @@ var service = {
|
|
|
520
355
|
return apiClient.update(id2, label, value, type).then((response) => {
|
|
521
356
|
const { success, data: payload } = response.data;
|
|
522
357
|
if (!success) {
|
|
523
|
-
const errorMessage = payload?.message || (0,
|
|
358
|
+
const errorMessage = payload?.message || (0, import_i18n.__)("Unexpected response from server", "elementor");
|
|
524
359
|
throw new Error(errorMessage);
|
|
525
360
|
}
|
|
526
361
|
return payload;
|
|
@@ -601,15 +436,15 @@ var service = {
|
|
|
601
436
|
handleWatermark(OP_RW, watermark);
|
|
602
437
|
if (results) {
|
|
603
438
|
results.forEach((result) => {
|
|
439
|
+
const variableId = result.id;
|
|
604
440
|
if (result.variable) {
|
|
605
|
-
const { id: variableId, ...variableData } = result.variable;
|
|
606
441
|
if (result.type === "create") {
|
|
607
|
-
storage.add(variableId,
|
|
442
|
+
storage.add(variableId, result.variable);
|
|
608
443
|
} else {
|
|
609
|
-
storage.update(variableId,
|
|
444
|
+
storage.update(variableId, result.variable);
|
|
610
445
|
}
|
|
611
446
|
styleVariablesRepository.update({
|
|
612
|
-
[variableId]:
|
|
447
|
+
[variableId]: result.variable
|
|
613
448
|
});
|
|
614
449
|
}
|
|
615
450
|
});
|
|
@@ -629,6 +464,219 @@ var handleWatermark = (operation, newWatermark) => {
|
|
|
629
464
|
storage.watermark(newWatermark);
|
|
630
465
|
};
|
|
631
466
|
|
|
467
|
+
// src/components/global-styles-import-listener.tsx
|
|
468
|
+
function GlobalStylesImportListener() {
|
|
469
|
+
(0, import_react.useEffect)(() => {
|
|
470
|
+
const handleGlobalStylesImported = (event) => {
|
|
471
|
+
const importedVars = event.detail?.global_variables;
|
|
472
|
+
if (!importedVars) {
|
|
473
|
+
return;
|
|
474
|
+
}
|
|
475
|
+
if (importedVars.data && typeof importedVars.data === "object") {
|
|
476
|
+
styleVariablesRepository.update(importedVars.data);
|
|
477
|
+
}
|
|
478
|
+
service.load();
|
|
479
|
+
};
|
|
480
|
+
window.addEventListener("elementor/global-styles/imported", handleGlobalStylesImported);
|
|
481
|
+
return () => {
|
|
482
|
+
window.removeEventListener(
|
|
483
|
+
"elementor/global-styles/imported",
|
|
484
|
+
handleGlobalStylesImported
|
|
485
|
+
);
|
|
486
|
+
};
|
|
487
|
+
}, []);
|
|
488
|
+
return null;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
// src/components/open-panel-from-event.tsx
|
|
492
|
+
var import_react15 = require("react");
|
|
493
|
+
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
494
|
+
|
|
495
|
+
// src/components/variables-manager/variables-manager-panel.tsx
|
|
496
|
+
var React14 = __toESM(require("react"));
|
|
497
|
+
var import_react14 = require("react");
|
|
498
|
+
var import_editor_current_user2 = require("@elementor/editor-current-user");
|
|
499
|
+
var import_editor_panels = require("@elementor/editor-panels");
|
|
500
|
+
var import_editor_ui5 = require("@elementor/editor-ui");
|
|
501
|
+
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
502
|
+
var import_icons5 = require("@elementor/icons");
|
|
503
|
+
var import_ui14 = require("@elementor/ui");
|
|
504
|
+
var import_i18n10 = require("@wordpress/i18n");
|
|
505
|
+
|
|
506
|
+
// src/utils/tracking.ts
|
|
507
|
+
var import_events = require("@elementor/events");
|
|
508
|
+
var trackVariableEvent = ({ varType, controlPath, action }) => {
|
|
509
|
+
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
510
|
+
if (!config?.names?.variables?.[action]) {
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
const name = config.names.variables[action];
|
|
514
|
+
dispatchEvent?.(name, {
|
|
515
|
+
location: config?.locations?.variables || "",
|
|
516
|
+
secondaryLocation: config?.secondaryLocations?.variablesPopover || "",
|
|
517
|
+
trigger: config?.triggers?.click || "",
|
|
518
|
+
var_type: varType,
|
|
519
|
+
control_path: controlPath,
|
|
520
|
+
action_type: name
|
|
521
|
+
});
|
|
522
|
+
};
|
|
523
|
+
var trackVariablesManagerEvent = ({ action, varType, controlPath }) => {
|
|
524
|
+
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
525
|
+
if (!config?.names?.variables?.[action]) {
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
const name = config.names.variables[action];
|
|
529
|
+
const eventData = {
|
|
530
|
+
location: config?.locations?.variablesManager || "",
|
|
531
|
+
trigger: config?.triggers?.click || "",
|
|
532
|
+
action_type: name
|
|
533
|
+
};
|
|
534
|
+
if (varType) {
|
|
535
|
+
eventData.var_type = varType;
|
|
536
|
+
}
|
|
537
|
+
if (controlPath) {
|
|
538
|
+
eventData.style_control_path = controlPath;
|
|
539
|
+
}
|
|
540
|
+
dispatchEvent?.(name, eventData);
|
|
541
|
+
};
|
|
542
|
+
var trackVariableSyncToV3 = ({ variableLabel, action }) => {
|
|
543
|
+
try {
|
|
544
|
+
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
545
|
+
if (!config?.names?.variables?.variableSyncToV3) {
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
const name = config.names.variables.variableSyncToV3;
|
|
549
|
+
const isSync = action === "sync";
|
|
550
|
+
dispatchEvent?.(name, {
|
|
551
|
+
interaction_type: "click",
|
|
552
|
+
target_type: variableLabel,
|
|
553
|
+
target_name: isSync ? "sync_to_v3" : "unsync_to_v3",
|
|
554
|
+
interaction_result: isSync ? "var_is_synced_to_V3" : "var_is_unsynced_from_V3",
|
|
555
|
+
target_location: "widget_panel",
|
|
556
|
+
location_l1: "var_manager",
|
|
557
|
+
interaction_description: isSync ? `user_synced_${variableLabel}_to_v3` : `user_unsync_${variableLabel}_from_v3`
|
|
558
|
+
});
|
|
559
|
+
} catch {
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
// src/utils/validations.ts
|
|
564
|
+
var import_icons = require("@elementor/icons");
|
|
565
|
+
var import_i18n2 = require("@wordpress/i18n");
|
|
566
|
+
var ERROR_MESSAGES = {
|
|
567
|
+
MISSING_VARIABLE_NAME: (0, import_i18n2.__)("Give your variable a name.", "elementor"),
|
|
568
|
+
MISSING_VARIABLE_VALUE: (0, import_i18n2.__)("Add a value to complete your variable.", "elementor"),
|
|
569
|
+
INVALID_CHARACTERS: (0, import_i18n2.__)("Use letters, numbers, dashes (-), or underscores (_) for the name.", "elementor"),
|
|
570
|
+
NO_NON_SPECIAL_CHARACTER: (0, import_i18n2.__)("Names have to include at least one non-special character.", "elementor"),
|
|
571
|
+
VARIABLE_LABEL_MAX_LENGTH: (0, import_i18n2.__)("Keep names up to 50 characters.", "elementor"),
|
|
572
|
+
DUPLICATED_LABEL: (0, import_i18n2.__)("This variable name already exists. Please choose a unique name.", "elementor"),
|
|
573
|
+
UNEXPECTED_ERROR: (0, import_i18n2.__)("There was a glitch. Try saving your variable again.", "elementor"),
|
|
574
|
+
BATCH: {
|
|
575
|
+
DUPLICATED_LABELS: (count, name) => (
|
|
576
|
+
// eslint-disable-next-line @wordpress/i18n-translator-comments
|
|
577
|
+
(0, import_i18n2.sprintf)((0, import_i18n2.__)("We found %1$d duplicated %2$s.", "elementor"), count, name)
|
|
578
|
+
),
|
|
579
|
+
UNEXPECTED_ERROR: (0, import_i18n2.__)("There was a glitch.", "elementor"),
|
|
580
|
+
DUPLICATED_LABEL_ACTION: (0, import_i18n2.__)("Take me there", "elementor"),
|
|
581
|
+
DUPLICATED_LABEL_ACTION_MESSAGE: (0, import_i18n2.__)("Please rename the variables.", "elementor"),
|
|
582
|
+
UNEXPECTED_ERROR_ACTION_MESSAGE: (0, import_i18n2.__)("Try saving your variables again.", "elementor")
|
|
583
|
+
}
|
|
584
|
+
};
|
|
585
|
+
var VARIABLE_LABEL_MAX_LENGTH = 50;
|
|
586
|
+
var mapServerError = (error) => {
|
|
587
|
+
if (error?.response?.data?.code === "duplicated_label") {
|
|
588
|
+
return {
|
|
589
|
+
field: "label",
|
|
590
|
+
message: ERROR_MESSAGES.DUPLICATED_LABEL
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
if (error?.response?.data?.code === "batch_duplicated_label") {
|
|
594
|
+
const errorData = error?.response?.data?.data ?? {};
|
|
595
|
+
const count = Object.keys(errorData).length;
|
|
596
|
+
const name = count === 1 ? "name" : "names";
|
|
597
|
+
const duplicatedIds = Object.keys(errorData);
|
|
598
|
+
return {
|
|
599
|
+
field: "label",
|
|
600
|
+
message: ERROR_MESSAGES.BATCH.DUPLICATED_LABELS(count, name),
|
|
601
|
+
severity: "error",
|
|
602
|
+
IconComponent: import_icons.AlertTriangleFilledIcon,
|
|
603
|
+
action: {
|
|
604
|
+
label: ERROR_MESSAGES.BATCH.DUPLICATED_LABEL_ACTION,
|
|
605
|
+
message: ERROR_MESSAGES.BATCH.DUPLICATED_LABEL_ACTION_MESSAGE,
|
|
606
|
+
data: {
|
|
607
|
+
duplicatedIds
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
if (error?.response?.data?.code === "batch_operation_failed") {
|
|
613
|
+
return {
|
|
614
|
+
field: "label",
|
|
615
|
+
message: ERROR_MESSAGES.BATCH.UNEXPECTED_ERROR,
|
|
616
|
+
severity: "secondary",
|
|
617
|
+
IconComponent: import_icons.InfoCircleFilledIcon,
|
|
618
|
+
action: {
|
|
619
|
+
message: ERROR_MESSAGES.BATCH.UNEXPECTED_ERROR_ACTION_MESSAGE
|
|
620
|
+
}
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
return void 0;
|
|
624
|
+
};
|
|
625
|
+
var validateLabel = (name, variables) => {
|
|
626
|
+
if (!name.trim()) {
|
|
627
|
+
return ERROR_MESSAGES.MISSING_VARIABLE_NAME;
|
|
628
|
+
}
|
|
629
|
+
const allowedChars = /^[a-zA-Z0-9_-]+$/;
|
|
630
|
+
if (!allowedChars.test(name)) {
|
|
631
|
+
return ERROR_MESSAGES.INVALID_CHARACTERS;
|
|
632
|
+
}
|
|
633
|
+
const hasAlphanumeric = /[a-zA-Z0-9]/;
|
|
634
|
+
if (!hasAlphanumeric.test(name)) {
|
|
635
|
+
return ERROR_MESSAGES.NO_NON_SPECIAL_CHARACTER;
|
|
636
|
+
}
|
|
637
|
+
if (VARIABLE_LABEL_MAX_LENGTH < name.length) {
|
|
638
|
+
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
639
|
+
}
|
|
640
|
+
if (Object.values(variables ?? {}).some((variable) => variable.label === name)) {
|
|
641
|
+
return ERROR_MESSAGES.DUPLICATED_LABEL;
|
|
642
|
+
}
|
|
643
|
+
return "";
|
|
644
|
+
};
|
|
645
|
+
var labelHint = (name) => {
|
|
646
|
+
const hintThreshold = VARIABLE_LABEL_MAX_LENGTH * 0.8 - 1;
|
|
647
|
+
if (hintThreshold < name.length) {
|
|
648
|
+
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
649
|
+
}
|
|
650
|
+
return "";
|
|
651
|
+
};
|
|
652
|
+
var validateValue = (value) => {
|
|
653
|
+
if (!value.trim()) {
|
|
654
|
+
return ERROR_MESSAGES.MISSING_VARIABLE_VALUE;
|
|
655
|
+
}
|
|
656
|
+
return "";
|
|
657
|
+
};
|
|
658
|
+
|
|
659
|
+
// src/variables-registry/create-variable-type-registry.ts
|
|
660
|
+
var import_editor_canvas3 = require("@elementor/editor-canvas");
|
|
661
|
+
|
|
662
|
+
// src/transformers/inheritance-transformer.tsx
|
|
663
|
+
var React = __toESM(require("react"));
|
|
664
|
+
var import_editor_canvas = require("@elementor/editor-canvas");
|
|
665
|
+
var import_ui2 = require("@elementor/ui");
|
|
666
|
+
var import_i18n3 = require("@wordpress/i18n");
|
|
667
|
+
|
|
668
|
+
// src/components/ui/color-indicator.tsx
|
|
669
|
+
var import_ui = require("@elementor/ui");
|
|
670
|
+
var ColorIndicator = (0, import_ui.styled)(import_ui.UnstableColorIndicator)(({ theme }) => ({
|
|
671
|
+
borderRadius: `${theme.shape.borderRadius / 2}px`,
|
|
672
|
+
marginRight: theme.spacing(0.25)
|
|
673
|
+
}));
|
|
674
|
+
|
|
675
|
+
// src/prop-types/color-variable-prop-type.ts
|
|
676
|
+
var import_editor_props2 = require("@elementor/editor-props");
|
|
677
|
+
var import_schema2 = require("@elementor/schema");
|
|
678
|
+
var colorVariablePropTypeUtil = (0, import_editor_props2.createPropUtils)("global-color-variable", import_schema2.z.string());
|
|
679
|
+
|
|
632
680
|
// src/transformers/utils/resolve-css-variable.ts
|
|
633
681
|
var resolveCssVariable = (id2, variable) => {
|
|
634
682
|
let name = id2;
|
|
@@ -831,13 +879,13 @@ var NoSearchResults = ({ searchValue, onClear, icon }) => {
|
|
|
831
879
|
};
|
|
832
880
|
|
|
833
881
|
// src/components/variables-manager/hooks/use-auto-edit.ts
|
|
834
|
-
var
|
|
882
|
+
var import_react2 = require("react");
|
|
835
883
|
var useAutoEdit = () => {
|
|
836
|
-
const [autoEditVariableId, setAutoEditVariableId] = (0,
|
|
837
|
-
const startAutoEdit = (0,
|
|
884
|
+
const [autoEditVariableId, setAutoEditVariableId] = (0, import_react2.useState)(void 0);
|
|
885
|
+
const startAutoEdit = (0, import_react2.useCallback)((variableId) => {
|
|
838
886
|
setAutoEditVariableId(variableId);
|
|
839
887
|
}, []);
|
|
840
|
-
const handleAutoEditComplete = (0,
|
|
888
|
+
const handleAutoEditComplete = (0, import_react2.useCallback)(() => {
|
|
841
889
|
setTimeout(() => {
|
|
842
890
|
setAutoEditVariableId(void 0);
|
|
843
891
|
}, 100);
|
|
@@ -850,10 +898,10 @@ var useAutoEdit = () => {
|
|
|
850
898
|
};
|
|
851
899
|
|
|
852
900
|
// src/components/variables-manager/hooks/use-error-navigation.ts
|
|
853
|
-
var
|
|
901
|
+
var import_react3 = require("react");
|
|
854
902
|
var useErrorNavigation = () => {
|
|
855
|
-
const currentIndexRef = (0,
|
|
856
|
-
const createNavigationCallback = (0,
|
|
903
|
+
const currentIndexRef = (0, import_react3.useRef)(0);
|
|
904
|
+
const createNavigationCallback = (0, import_react3.useCallback)(
|
|
857
905
|
(ids, onNavigate, onComplete) => {
|
|
858
906
|
return () => {
|
|
859
907
|
if (!ids?.length) {
|
|
@@ -875,7 +923,7 @@ var useErrorNavigation = () => {
|
|
|
875
923
|
},
|
|
876
924
|
[]
|
|
877
925
|
);
|
|
878
|
-
const resetNavigation = (0,
|
|
926
|
+
const resetNavigation = (0, import_react3.useCallback)(() => {
|
|
879
927
|
currentIndexRef.current = 0;
|
|
880
928
|
}, []);
|
|
881
929
|
return {
|
|
@@ -885,21 +933,21 @@ var useErrorNavigation = () => {
|
|
|
885
933
|
};
|
|
886
934
|
|
|
887
935
|
// src/components/variables-manager/hooks/use-variables-manager-state.ts
|
|
888
|
-
var
|
|
936
|
+
var import_react6 = require("react");
|
|
889
937
|
|
|
890
938
|
// src/hooks/use-prop-variables.ts
|
|
891
|
-
var
|
|
939
|
+
var import_react5 = require("react");
|
|
892
940
|
var import_editor_controls = require("@elementor/editor-controls");
|
|
893
941
|
|
|
894
942
|
// src/context/variable-type-context.tsx
|
|
895
943
|
var React5 = __toESM(require("react"));
|
|
896
|
-
var
|
|
897
|
-
var VariableTypeContext = (0,
|
|
944
|
+
var import_react4 = require("react");
|
|
945
|
+
var VariableTypeContext = (0, import_react4.createContext)(null);
|
|
898
946
|
function VariableTypeProvider({ children, propTypeKey }) {
|
|
899
947
|
return /* @__PURE__ */ React5.createElement(VariableTypeContext.Provider, { value: propTypeKey }, children);
|
|
900
948
|
}
|
|
901
949
|
function useVariableType() {
|
|
902
|
-
const context = (0,
|
|
950
|
+
const context = (0, import_react4.useContext)(VariableTypeContext);
|
|
903
951
|
if (context === null) {
|
|
904
952
|
throw new Error("useVariableType must be used within a VariableTypeProvider");
|
|
905
953
|
}
|
|
@@ -982,7 +1030,7 @@ var useVariableSelectionFilter = (variables) => {
|
|
|
982
1030
|
return selectionFilter ? selectionFilter(variables, propType) : variables;
|
|
983
1031
|
};
|
|
984
1032
|
var usePropVariables = (propKey) => {
|
|
985
|
-
return (0,
|
|
1033
|
+
return (0, import_react5.useMemo)(() => normalizeVariables(propKey), [propKey]);
|
|
986
1034
|
};
|
|
987
1035
|
var getMatchingTypes = (propKey) => {
|
|
988
1036
|
const matchingTypes = [];
|
|
@@ -1016,20 +1064,20 @@ var restoreVariable = (restoreId, label, value, type) => {
|
|
|
1016
1064
|
|
|
1017
1065
|
// src/components/variables-manager/hooks/use-variables-manager-state.ts
|
|
1018
1066
|
var useVariablesManagerState = () => {
|
|
1019
|
-
const [variables, setVariables] = (0,
|
|
1020
|
-
const [deletedVariables, setDeletedVariables] = (0,
|
|
1021
|
-
const [isSaveDisabled, setIsSaveDisabled] = (0,
|
|
1022
|
-
const [isDirty, setIsDirty] = (0,
|
|
1023
|
-
const [isSaving, setIsSaving] = (0,
|
|
1024
|
-
const [searchValue, setSearchValue] = (0,
|
|
1025
|
-
const handleOnChange = (0,
|
|
1067
|
+
const [variables, setVariables] = (0, import_react6.useState)(() => getVariables(false));
|
|
1068
|
+
const [deletedVariables, setDeletedVariables] = (0, import_react6.useState)([]);
|
|
1069
|
+
const [isSaveDisabled, setIsSaveDisabled] = (0, import_react6.useState)(false);
|
|
1070
|
+
const [isDirty, setIsDirty] = (0, import_react6.useState)(false);
|
|
1071
|
+
const [isSaving, setIsSaving] = (0, import_react6.useState)(false);
|
|
1072
|
+
const [searchValue, setSearchValue] = (0, import_react6.useState)("");
|
|
1073
|
+
const handleOnChange = (0, import_react6.useCallback)(
|
|
1026
1074
|
(newVariables) => {
|
|
1027
1075
|
setVariables({ ...variables, ...newVariables });
|
|
1028
1076
|
setIsDirty(true);
|
|
1029
1077
|
},
|
|
1030
1078
|
[variables]
|
|
1031
1079
|
);
|
|
1032
|
-
const createVariable2 = (0,
|
|
1080
|
+
const createVariable2 = (0, import_react6.useCallback)((type, defaultName, defaultValue) => {
|
|
1033
1081
|
const newId = generateTempId();
|
|
1034
1082
|
const newVariable = {
|
|
1035
1083
|
id: newId,
|
|
@@ -1041,19 +1089,19 @@ var useVariablesManagerState = () => {
|
|
|
1041
1089
|
setIsDirty(true);
|
|
1042
1090
|
return newId;
|
|
1043
1091
|
}, []);
|
|
1044
|
-
const handleDeleteVariable = (0,
|
|
1092
|
+
const handleDeleteVariable = (0, import_react6.useCallback)((itemId) => {
|
|
1045
1093
|
setDeletedVariables((prev) => [...prev, itemId]);
|
|
1046
1094
|
setVariables((prev) => ({ ...prev, [itemId]: { ...prev[itemId], deleted: true } }));
|
|
1047
1095
|
setIsDirty(true);
|
|
1048
1096
|
}, []);
|
|
1049
|
-
const handleStartSync = (0,
|
|
1097
|
+
const handleStartSync = (0, import_react6.useCallback)((itemId) => {
|
|
1050
1098
|
setVariables((prev) => ({
|
|
1051
1099
|
...prev,
|
|
1052
1100
|
[itemId]: { ...prev[itemId], sync_to_v3: true }
|
|
1053
1101
|
}));
|
|
1054
1102
|
setIsDirty(true);
|
|
1055
1103
|
}, []);
|
|
1056
|
-
const handleStopSync = (0,
|
|
1104
|
+
const handleStopSync = (0, import_react6.useCallback)((itemId) => {
|
|
1057
1105
|
setVariables((prev) => ({
|
|
1058
1106
|
...prev,
|
|
1059
1107
|
[itemId]: { ...prev[itemId], sync_to_v3: false }
|
|
@@ -1063,7 +1111,7 @@ var useVariablesManagerState = () => {
|
|
|
1063
1111
|
const handleSearch = (searchTerm) => {
|
|
1064
1112
|
setSearchValue(searchTerm);
|
|
1065
1113
|
};
|
|
1066
|
-
const handleSave = (0,
|
|
1114
|
+
const handleSave = (0, import_react6.useCallback)(async () => {
|
|
1067
1115
|
const originalVariables = getVariables(false);
|
|
1068
1116
|
setIsSaving(true);
|
|
1069
1117
|
const result = await service.batchSave(originalVariables, variables, deletedVariables);
|
|
@@ -1076,7 +1124,7 @@ var useVariablesManagerState = () => {
|
|
|
1076
1124
|
}
|
|
1077
1125
|
return { success: result.success };
|
|
1078
1126
|
}, [variables, deletedVariables]);
|
|
1079
|
-
const filteredVariables = (0,
|
|
1127
|
+
const filteredVariables = (0, import_react6.useCallback)(() => {
|
|
1080
1128
|
const list = variablesToList(variables).filter((v) => !v.deleted);
|
|
1081
1129
|
const typeFiltered = applySelectionFilters(list, getVariableTypes());
|
|
1082
1130
|
const searchFiltered = filterBySearch(typeFiltered, searchValue);
|
|
@@ -1103,7 +1151,7 @@ var useVariablesManagerState = () => {
|
|
|
1103
1151
|
|
|
1104
1152
|
// src/components/variables-manager/variables-manager-create-menu.tsx
|
|
1105
1153
|
var React7 = __toESM(require("react"));
|
|
1106
|
-
var
|
|
1154
|
+
var import_react8 = require("react");
|
|
1107
1155
|
var import_icons2 = require("@elementor/icons");
|
|
1108
1156
|
var import_ui7 = require("@elementor/ui");
|
|
1109
1157
|
var import_utils2 = require("@elementor/utils");
|
|
@@ -1126,17 +1174,25 @@ var useQuotaPermissions = (variableType) => {
|
|
|
1126
1174
|
|
|
1127
1175
|
// src/components/ui/variable-promotion-chip.tsx
|
|
1128
1176
|
var React6 = __toESM(require("react"));
|
|
1129
|
-
var
|
|
1177
|
+
var import_react7 = require("react");
|
|
1178
|
+
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
1130
1179
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
1131
1180
|
var import_ui6 = require("@elementor/ui");
|
|
1132
1181
|
var import_utils = require("@elementor/utils");
|
|
1133
1182
|
var import_i18n7 = require("@wordpress/i18n");
|
|
1134
|
-
var VariablePromotionChip = (0,
|
|
1135
|
-
({ variableType, upgradeUrl }, ref) => {
|
|
1136
|
-
const [isOpen, setIsOpen] = (0,
|
|
1183
|
+
var VariablePromotionChip = (0, import_react7.forwardRef)(
|
|
1184
|
+
({ variableType, upgradeUrl, trackingData }, ref) => {
|
|
1185
|
+
const [isOpen, setIsOpen] = (0, import_react7.useState)(false);
|
|
1137
1186
|
(0, import_editor_ui2.useCanvasClickHandler)(isOpen, () => setIsOpen(false));
|
|
1138
|
-
const toggle = ()
|
|
1139
|
-
|
|
1187
|
+
const toggle = (0, import_react7.useCallback)(() => {
|
|
1188
|
+
setIsOpen((prev) => {
|
|
1189
|
+
if (!prev) {
|
|
1190
|
+
(0, import_editor_controls2.trackViewPromotion)(trackingData);
|
|
1191
|
+
}
|
|
1192
|
+
return !prev;
|
|
1193
|
+
});
|
|
1194
|
+
}, [trackingData]);
|
|
1195
|
+
(0, import_react7.useImperativeHandle)(ref, () => ({ toggle }), [toggle]);
|
|
1140
1196
|
const title = (0, import_i18n7.sprintf)(
|
|
1141
1197
|
/* translators: %s: Variable Type. */
|
|
1142
1198
|
(0, import_i18n7.__)("%s variables", "elementor"),
|
|
@@ -1158,7 +1214,8 @@ var VariablePromotionChip = (0, import_react6.forwardRef)(
|
|
|
1158
1214
|
onClose: (e) => {
|
|
1159
1215
|
e.stopPropagation();
|
|
1160
1216
|
setIsOpen(false);
|
|
1161
|
-
}
|
|
1217
|
+
},
|
|
1218
|
+
onCtaClick: () => (0, import_editor_controls2.trackUpgradePromotionClick)(trackingData)
|
|
1162
1219
|
},
|
|
1163
1220
|
/* @__PURE__ */ React6.createElement(
|
|
1164
1221
|
import_ui6.Box,
|
|
@@ -1176,11 +1233,16 @@ var VariablePromotionChip = (0, import_react6.forwardRef)(
|
|
|
1176
1233
|
);
|
|
1177
1234
|
|
|
1178
1235
|
// src/components/variables-manager/variables-manager-create-menu.tsx
|
|
1236
|
+
var TRACKING_DATA = {
|
|
1237
|
+
target_name: "variables_manager",
|
|
1238
|
+
target_location: "variables_manager",
|
|
1239
|
+
location_l1: "create variable menu"
|
|
1240
|
+
};
|
|
1179
1241
|
var SIZE = "tiny";
|
|
1180
1242
|
var VariableManagerCreateMenu = ({ variables, onCreate, menuState }) => {
|
|
1181
|
-
const buttonRef = (0,
|
|
1243
|
+
const buttonRef = (0, import_react8.useRef)(null);
|
|
1182
1244
|
const variableTypes = getVariableTypes();
|
|
1183
|
-
const menuOptionConfigs = (0,
|
|
1245
|
+
const menuOptionConfigs = (0, import_react8.useMemo)(
|
|
1184
1246
|
() => Object.entries(variableTypes).filter(([, variable]) => !!variable.defaultValue).map(([key, variable]) => ({
|
|
1185
1247
|
key,
|
|
1186
1248
|
propTypeKey: variable.propTypeUtil.key,
|
|
@@ -1239,7 +1301,7 @@ var MenuOption = ({
|
|
|
1239
1301
|
onCreate,
|
|
1240
1302
|
onClose
|
|
1241
1303
|
}) => {
|
|
1242
|
-
const promotionRef = (0,
|
|
1304
|
+
const promotionRef = (0, import_react8.useRef)(null);
|
|
1243
1305
|
const userQuotaPermissions = useQuotaPermissions(config.propTypeKey);
|
|
1244
1306
|
const displayName = (0, import_utils2.capitalize)(config.variableType);
|
|
1245
1307
|
const isDisabled = !userQuotaPermissions.canAdd();
|
|
@@ -1253,29 +1315,35 @@ var MenuOption = ({
|
|
|
1253
1315
|
trackVariablesManagerEvent({ action: "add", varType: config.variableType });
|
|
1254
1316
|
onClose();
|
|
1255
1317
|
};
|
|
1256
|
-
return /* @__PURE__ */ React7.createElement(import_ui7.MenuItem, { onClick: handleClick, sx: { gap: 1.5, cursor: "pointer" } }, (0,
|
|
1318
|
+
return /* @__PURE__ */ React7.createElement(import_ui7.MenuItem, { onClick: handleClick, sx: { gap: 1.5, cursor: "pointer" } }, (0, import_react8.createElement)(config.icon, { fontSize: SIZE, color: isDisabled ? "disabled" : "action" }), /* @__PURE__ */ React7.createElement(import_ui7.Typography, { variant: "caption", color: isDisabled ? "text.disabled" : "text.primary" }, displayName), isDisabled && /* @__PURE__ */ React7.createElement(
|
|
1257
1319
|
VariablePromotionChip,
|
|
1258
1320
|
{
|
|
1259
1321
|
variableType: config.variableType,
|
|
1260
1322
|
upgradeUrl: `https://go.elementor.com/go-pro-manager-${config.variableType}-variable/`,
|
|
1261
|
-
ref: promotionRef
|
|
1323
|
+
ref: promotionRef,
|
|
1324
|
+
trackingData: TRACKING_DATA
|
|
1262
1325
|
}
|
|
1263
1326
|
));
|
|
1264
1327
|
};
|
|
1265
1328
|
var getDefaultName = (variables, baseName) => {
|
|
1266
1329
|
const pattern = new RegExp(`^${baseName}-(\\d+)$`, "i");
|
|
1267
|
-
|
|
1330
|
+
const takenNumbers = /* @__PURE__ */ new Set();
|
|
1268
1331
|
Object.values(variables).forEach((variable) => {
|
|
1269
|
-
|
|
1270
|
-
|
|
1332
|
+
const match = variable.label.match(pattern);
|
|
1333
|
+
if (match) {
|
|
1334
|
+
takenNumbers.add(parseInt(match[1], 10));
|
|
1271
1335
|
}
|
|
1272
1336
|
});
|
|
1337
|
+
let counter = 1;
|
|
1338
|
+
while (takenNumbers.has(counter)) {
|
|
1339
|
+
counter++;
|
|
1340
|
+
}
|
|
1273
1341
|
return `${baseName}-${counter}`;
|
|
1274
1342
|
};
|
|
1275
1343
|
|
|
1276
1344
|
// src/components/variables-manager/variables-manager-table.tsx
|
|
1277
1345
|
var React13 = __toESM(require("react"));
|
|
1278
|
-
var
|
|
1346
|
+
var import_react13 = require("react");
|
|
1279
1347
|
var import_ui13 = require("@elementor/ui");
|
|
1280
1348
|
var import_i18n9 = require("@wordpress/i18n");
|
|
1281
1349
|
|
|
@@ -1305,21 +1373,21 @@ var VariableTableCell = ({
|
|
|
1305
1373
|
|
|
1306
1374
|
// src/components/variables-manager/ui/variable-table-row.tsx
|
|
1307
1375
|
var React12 = __toESM(require("react"));
|
|
1308
|
-
var
|
|
1376
|
+
var import_react12 = require("react");
|
|
1309
1377
|
var import_editor_ui4 = require("@elementor/editor-ui");
|
|
1310
1378
|
var import_icons4 = require("@elementor/icons");
|
|
1311
1379
|
var import_ui12 = require("@elementor/ui");
|
|
1312
1380
|
|
|
1313
1381
|
// src/components/fields/label-field.tsx
|
|
1314
1382
|
var React9 = __toESM(require("react"));
|
|
1315
|
-
var
|
|
1383
|
+
var import_react9 = require("react");
|
|
1316
1384
|
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
1317
1385
|
var import_ui9 = require("@elementor/ui");
|
|
1318
1386
|
function isLabelEqual(a, b) {
|
|
1319
1387
|
return a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
1320
1388
|
}
|
|
1321
1389
|
var useLabelError = (initialError) => {
|
|
1322
|
-
const [error, setError] = (0,
|
|
1390
|
+
const [error, setError] = (0, import_react9.useState)(initialError ?? { value: "", message: "" });
|
|
1323
1391
|
return {
|
|
1324
1392
|
labelFieldError: error,
|
|
1325
1393
|
setLabelFieldError: setError
|
|
@@ -1338,9 +1406,9 @@ var LabelField = ({
|
|
|
1338
1406
|
variables,
|
|
1339
1407
|
onKeyDown
|
|
1340
1408
|
}) => {
|
|
1341
|
-
const [label, setLabel] = (0,
|
|
1342
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
1343
|
-
const fieldRef = (0,
|
|
1409
|
+
const [label, setLabel] = (0, import_react9.useState)(value);
|
|
1410
|
+
const [errorMessage, setErrorMessage] = (0, import_react9.useState)("");
|
|
1411
|
+
const fieldRef = (0, import_react9.useRef)(null);
|
|
1344
1412
|
const handleChange = (newValue) => {
|
|
1345
1413
|
setLabel(newValue);
|
|
1346
1414
|
const errorMsg2 = validateLabel(newValue, variables);
|
|
@@ -1392,7 +1460,7 @@ var LabelField = ({
|
|
|
1392
1460
|
|
|
1393
1461
|
// src/components/variables-manager/variable-editable-cell.tsx
|
|
1394
1462
|
var React10 = __toESM(require("react"));
|
|
1395
|
-
var
|
|
1463
|
+
var import_react10 = require("react");
|
|
1396
1464
|
var import_ui10 = require("@elementor/ui");
|
|
1397
1465
|
var VariableEditableCell = React10.memo(
|
|
1398
1466
|
({
|
|
@@ -1408,22 +1476,22 @@ var VariableEditableCell = React10.memo(
|
|
|
1408
1476
|
fieldType,
|
|
1409
1477
|
disabled = false
|
|
1410
1478
|
}) => {
|
|
1411
|
-
const [value, setValue] = (0,
|
|
1412
|
-
const [isEditing, setIsEditing] = (0,
|
|
1479
|
+
const [value, setValue] = (0, import_react10.useState)(initialValue);
|
|
1480
|
+
const [isEditing, setIsEditing] = (0, import_react10.useState)(false);
|
|
1413
1481
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
1414
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
1415
|
-
const rowRef = (0,
|
|
1416
|
-
const handleSave = (0,
|
|
1482
|
+
const [valueFieldError, setValueFieldError] = (0, import_react10.useState)("");
|
|
1483
|
+
const rowRef = (0, import_react10.useRef)(null);
|
|
1484
|
+
const handleSave = (0, import_react10.useCallback)(() => {
|
|
1417
1485
|
const hasError = fieldType === "label" && labelFieldError?.message || fieldType === "value" && valueFieldError;
|
|
1418
1486
|
if (!hasError) {
|
|
1419
1487
|
onChange(value);
|
|
1420
1488
|
}
|
|
1421
1489
|
setIsEditing(false);
|
|
1422
1490
|
}, [value, onChange, fieldType, labelFieldError, valueFieldError]);
|
|
1423
|
-
(0,
|
|
1491
|
+
(0, import_react10.useEffect)(() => {
|
|
1424
1492
|
onRowRef?.(rowRef?.current);
|
|
1425
1493
|
}, [onRowRef]);
|
|
1426
|
-
(0,
|
|
1494
|
+
(0, import_react10.useEffect)(() => {
|
|
1427
1495
|
if (autoEdit && !isEditing && !disabled) {
|
|
1428
1496
|
setIsEditing(true);
|
|
1429
1497
|
onAutoEditComplete?.();
|
|
@@ -1449,10 +1517,10 @@ var VariableEditableCell = React10.memo(
|
|
|
1449
1517
|
setIsEditing(true);
|
|
1450
1518
|
}
|
|
1451
1519
|
};
|
|
1452
|
-
const handleChange = (0,
|
|
1520
|
+
const handleChange = (0, import_react10.useCallback)((newValue) => {
|
|
1453
1521
|
setValue(newValue);
|
|
1454
1522
|
}, []);
|
|
1455
|
-
const handleValidationChange = (0,
|
|
1523
|
+
const handleValidationChange = (0, import_react10.useCallback)(
|
|
1456
1524
|
(errorMsg) => {
|
|
1457
1525
|
if (fieldType === "label") {
|
|
1458
1526
|
setLabelFieldError({
|
|
@@ -1516,7 +1584,7 @@ var VariableEditableCell = React10.memo(
|
|
|
1516
1584
|
|
|
1517
1585
|
// src/components/variables-manager/ui/variable-edit-menu.tsx
|
|
1518
1586
|
var React11 = __toESM(require("react"));
|
|
1519
|
-
var
|
|
1587
|
+
var import_react11 = require("react");
|
|
1520
1588
|
var import_icons3 = require("@elementor/icons");
|
|
1521
1589
|
var import_ui11 = require("@elementor/ui");
|
|
1522
1590
|
var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
|
|
@@ -1573,7 +1641,7 @@ var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
|
|
|
1573
1641
|
gap: 1
|
|
1574
1642
|
}
|
|
1575
1643
|
},
|
|
1576
|
-
action.icon && (0,
|
|
1644
|
+
action.icon && (0, import_react11.createElement)(action.icon, {
|
|
1577
1645
|
fontSize: "inherit"
|
|
1578
1646
|
}),
|
|
1579
1647
|
" ",
|
|
@@ -1583,6 +1651,7 @@ var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
|
|
|
1583
1651
|
};
|
|
1584
1652
|
|
|
1585
1653
|
// src/components/variables-manager/ui/variable-table-row.tsx
|
|
1654
|
+
var TRACKING_DATA2 = { target_name: "variables_manager", target_location: "variables_manager" };
|
|
1586
1655
|
var VariableRow = (props) => {
|
|
1587
1656
|
const {
|
|
1588
1657
|
row,
|
|
@@ -1603,7 +1672,7 @@ var VariableRow = (props) => {
|
|
|
1603
1672
|
setTriggerRef,
|
|
1604
1673
|
isSorting
|
|
1605
1674
|
} = props;
|
|
1606
|
-
const promotionRef = (0,
|
|
1675
|
+
const promotionRef = (0, import_react12.useRef)(null);
|
|
1607
1676
|
const isDisabled = !useQuotaPermissions(row.type).canEdit();
|
|
1608
1677
|
const showIndicationBefore = showDropIndication && dropPosition === "before";
|
|
1609
1678
|
const showIndicationAfter = showDropIndication && dropPosition === "after";
|
|
@@ -1661,7 +1730,7 @@ var VariableRow = (props) => {
|
|
|
1661
1730
|
});
|
|
1662
1731
|
}
|
|
1663
1732
|
},
|
|
1664
|
-
prefixElement: (0,
|
|
1733
|
+
prefixElement: (0, import_react12.createElement)(row.icon, {
|
|
1665
1734
|
fontSize: "inherit",
|
|
1666
1735
|
color: isDisabled ? "disabled" : "inherit"
|
|
1667
1736
|
}),
|
|
@@ -1745,7 +1814,8 @@ var VariableRow = (props) => {
|
|
|
1745
1814
|
{
|
|
1746
1815
|
variableType: row.variableType,
|
|
1747
1816
|
upgradeUrl: `https://go.elementor.com/renew-license-manager-${row.variableType}-variable`,
|
|
1748
|
-
ref: promotionRef
|
|
1817
|
+
ref: promotionRef,
|
|
1818
|
+
trackingData: TRACKING_DATA2
|
|
1749
1819
|
}
|
|
1750
1820
|
), /* @__PURE__ */ React12.createElement(VariableEditMenu, { menuActions: menuActions(row.id), disabled: isSorting, itemId: row.id })))
|
|
1751
1821
|
);
|
|
@@ -1760,9 +1830,9 @@ var VariablesManagerTable = ({
|
|
|
1760
1830
|
onAutoEditComplete,
|
|
1761
1831
|
onFieldError
|
|
1762
1832
|
}) => {
|
|
1763
|
-
const tableContainerRef = (0,
|
|
1764
|
-
const variableRowRefs = (0,
|
|
1765
|
-
(0,
|
|
1833
|
+
const tableContainerRef = (0, import_react13.useRef)(null);
|
|
1834
|
+
const variableRowRefs = (0, import_react13.useRef)(/* @__PURE__ */ new Map());
|
|
1835
|
+
(0, import_react13.useEffect)(() => {
|
|
1766
1836
|
if (autoEditVariableId && tableContainerRef.current) {
|
|
1767
1837
|
const rowElement = variableRowRefs.current.get(autoEditVariableId);
|
|
1768
1838
|
if (rowElement) {
|
|
@@ -1883,8 +1953,8 @@ function VariablesManagerPanel() {
|
|
|
1883
1953
|
handleOnChange,
|
|
1884
1954
|
createVariable: createVariable2,
|
|
1885
1955
|
handleDeleteVariable,
|
|
1886
|
-
handleStartSync,
|
|
1887
|
-
handleStopSync,
|
|
1956
|
+
handleStartSync: startSyncFromState,
|
|
1957
|
+
handleStopSync: stopSyncFromState,
|
|
1888
1958
|
handleSave,
|
|
1889
1959
|
isSaving,
|
|
1890
1960
|
handleSearch,
|
|
@@ -1893,9 +1963,9 @@ function VariablesManagerPanel() {
|
|
|
1893
1963
|
} = useVariablesManagerState();
|
|
1894
1964
|
const { autoEditVariableId, startAutoEdit, handleAutoEditComplete } = useAutoEdit();
|
|
1895
1965
|
const { createNavigationCallback, resetNavigation } = useErrorNavigation();
|
|
1896
|
-
const [deleteConfirmation, setDeleteConfirmation] = (0,
|
|
1897
|
-
const [stopSyncConfirmation, setStopSyncConfirmation] = (0,
|
|
1898
|
-
const [serverError, setServerError] = (0,
|
|
1966
|
+
const [deleteConfirmation, setDeleteConfirmation] = (0, import_react14.useState)(null);
|
|
1967
|
+
const [stopSyncConfirmation, setStopSyncConfirmation] = (0, import_react14.useState)(null);
|
|
1968
|
+
const [serverError, setServerError] = (0, import_react14.useState)(null);
|
|
1899
1969
|
usePreventUnload(isDirty);
|
|
1900
1970
|
const handleClosePanel = () => {
|
|
1901
1971
|
if (isDirty) {
|
|
@@ -1904,7 +1974,7 @@ function VariablesManagerPanel() {
|
|
|
1904
1974
|
}
|
|
1905
1975
|
closePanel();
|
|
1906
1976
|
};
|
|
1907
|
-
const handleCreateVariable = (0,
|
|
1977
|
+
const handleCreateVariable = (0, import_react14.useCallback)(
|
|
1908
1978
|
(type, defaultName, defaultValue) => {
|
|
1909
1979
|
const newId = createVariable2(type, defaultName, defaultValue);
|
|
1910
1980
|
if (newId) {
|
|
@@ -1938,31 +2008,44 @@ function VariablesManagerPanel() {
|
|
|
1938
2008
|
setIsSaving(false);
|
|
1939
2009
|
}
|
|
1940
2010
|
};
|
|
1941
|
-
const handleDeleteVariableWithConfirmation = (0,
|
|
2011
|
+
const handleDeleteVariableWithConfirmation = (0, import_react14.useCallback)(
|
|
1942
2012
|
(itemId) => {
|
|
1943
2013
|
handleDeleteVariable(itemId);
|
|
1944
2014
|
setDeleteConfirmation(null);
|
|
1945
2015
|
},
|
|
1946
2016
|
[handleDeleteVariable]
|
|
1947
2017
|
);
|
|
1948
|
-
const
|
|
2018
|
+
const commitStopSync = (0, import_react14.useCallback)(
|
|
2019
|
+
(itemId) => {
|
|
2020
|
+
stopSyncFromState(itemId);
|
|
2021
|
+
const variable = variables[itemId];
|
|
2022
|
+
if (variable) {
|
|
2023
|
+
trackVariableSyncToV3({ variableLabel: variable.label, action: "unsync" });
|
|
2024
|
+
}
|
|
2025
|
+
},
|
|
2026
|
+
[stopSyncFromState, variables]
|
|
2027
|
+
);
|
|
2028
|
+
const handleStartSync = (0, import_react14.useCallback)(
|
|
1949
2029
|
(itemId) => {
|
|
1950
|
-
|
|
1951
|
-
|
|
2030
|
+
startSyncFromState(itemId);
|
|
2031
|
+
const variable = variables[itemId];
|
|
2032
|
+
if (variable) {
|
|
2033
|
+
trackVariableSyncToV3({ variableLabel: variable.label, action: "sync" });
|
|
2034
|
+
}
|
|
1952
2035
|
},
|
|
1953
|
-
[
|
|
2036
|
+
[startSyncFromState, variables]
|
|
1954
2037
|
);
|
|
1955
|
-
const
|
|
2038
|
+
const handleStopSync = (0, import_react14.useCallback)(
|
|
1956
2039
|
(itemId) => {
|
|
1957
2040
|
if (!isStopSyncSuppressed) {
|
|
1958
2041
|
setStopSyncConfirmation(itemId);
|
|
1959
2042
|
} else {
|
|
1960
|
-
|
|
2043
|
+
commitStopSync(itemId);
|
|
1961
2044
|
}
|
|
1962
2045
|
},
|
|
1963
|
-
[isStopSyncSuppressed,
|
|
2046
|
+
[isStopSyncSuppressed, commitStopSync]
|
|
1964
2047
|
);
|
|
1965
|
-
const buildMenuActions = (0,
|
|
2048
|
+
const buildMenuActions = (0, import_react14.useCallback)(
|
|
1966
2049
|
(variableId) => {
|
|
1967
2050
|
const variable = variables[variableId];
|
|
1968
2051
|
if (!variable) {
|
|
@@ -1973,7 +2056,7 @@ function VariablesManagerPanel() {
|
|
|
1973
2056
|
variableId,
|
|
1974
2057
|
handlers: {
|
|
1975
2058
|
onStartSync: handleStartSync,
|
|
1976
|
-
onStopSync:
|
|
2059
|
+
onStopSync: handleStopSync
|
|
1977
2060
|
}
|
|
1978
2061
|
});
|
|
1979
2062
|
const deleteAction = {
|
|
@@ -1991,7 +2074,7 @@ function VariablesManagerPanel() {
|
|
|
1991
2074
|
};
|
|
1992
2075
|
return [...typeActions, deleteAction];
|
|
1993
2076
|
},
|
|
1994
|
-
[variables, handleStartSync,
|
|
2077
|
+
[variables, handleStartSync, handleStopSync]
|
|
1995
2078
|
);
|
|
1996
2079
|
const hasVariables = Object.keys(variables).length > 0;
|
|
1997
2080
|
return /* @__PURE__ */ React14.createElement(import_editor_ui5.ThemeProvider, null, /* @__PURE__ */ React14.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React14.createElement(
|
|
@@ -2126,7 +2209,10 @@ function VariablesManagerPanel() {
|
|
|
2126
2209
|
{
|
|
2127
2210
|
open: true,
|
|
2128
2211
|
onClose: () => setStopSyncConfirmation(null),
|
|
2129
|
-
onConfirm: () =>
|
|
2212
|
+
onConfirm: () => {
|
|
2213
|
+
commitStopSync(stopSyncConfirmation);
|
|
2214
|
+
setStopSyncConfirmation(null);
|
|
2215
|
+
}
|
|
2130
2216
|
}
|
|
2131
2217
|
), isSaveChangesDialogOpen && /* @__PURE__ */ React14.createElement(import_editor_ui5.SaveChangesDialog, null, /* @__PURE__ */ React14.createElement(import_editor_ui5.SaveChangesDialog.Title, { onClose: closeSaveChangesDialog }, (0, import_i18n10.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React14.createElement(import_editor_ui5.SaveChangesDialog.Content, null, /* @__PURE__ */ React14.createElement(import_editor_ui5.SaveChangesDialog.ContentText, null, (0, import_i18n10.__)("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React14.createElement(
|
|
2132
2218
|
import_editor_ui5.SaveChangesDialog.Actions,
|
|
@@ -2154,7 +2240,7 @@ function VariablesManagerPanel() {
|
|
|
2154
2240
|
)));
|
|
2155
2241
|
}
|
|
2156
2242
|
var usePreventUnload = (isDirty) => {
|
|
2157
|
-
(0,
|
|
2243
|
+
(0, import_react14.useEffect)(() => {
|
|
2158
2244
|
const handleBeforeUnload = (event) => {
|
|
2159
2245
|
if (isDirty) {
|
|
2160
2246
|
event.preventDefault();
|
|
@@ -2169,7 +2255,7 @@ var usePreventUnload = (isDirty) => {
|
|
|
2169
2255
|
var StopSyncConfirmationDialog = ({ open, onClose, onConfirm }) => {
|
|
2170
2256
|
const [, suppressStopSyncMessage] = (0, import_editor_current_user2.useSuppressedMessage)(STOP_SYNC_MESSAGE_KEY);
|
|
2171
2257
|
return /* @__PURE__ */ React14.createElement(import_editor_ui5.ConfirmationDialog, { open, onClose }, /* @__PURE__ */ React14.createElement(import_editor_ui5.ConfirmationDialog.Title, { icon: import_icons5.ColorFilterIcon, iconColor: "primary" }, (0, import_i18n10.__)("Stop syncing variable color", "elementor")), /* @__PURE__ */ React14.createElement(import_editor_ui5.ConfirmationDialog.Content, null, /* @__PURE__ */ React14.createElement(import_editor_ui5.ConfirmationDialog.ContentText, null, (0, import_i18n10.__)(
|
|
2172
|
-
"This will disconnect the variable color from
|
|
2258
|
+
"This will disconnect the variable color from Global Colors. Existing uses on your site will automatically switch to a default color.",
|
|
2173
2259
|
"elementor"
|
|
2174
2260
|
))), /* @__PURE__ */ React14.createElement(
|
|
2175
2261
|
import_editor_ui5.ConfirmationDialog.Actions,
|
|
@@ -2185,20 +2271,54 @@ var StopSyncConfirmationDialog = ({ open, onClose, onConfirm }) => {
|
|
|
2185
2271
|
));
|
|
2186
2272
|
};
|
|
2187
2273
|
|
|
2274
|
+
// src/components/open-panel-from-event.tsx
|
|
2275
|
+
var EVENT_NAME = "elementor/open-variables-manager";
|
|
2276
|
+
var DEFAULT_PANEL_ROUTE = "panel/elements/categories";
|
|
2277
|
+
function OpenPanelFromEvent() {
|
|
2278
|
+
const { open } = usePanelActions();
|
|
2279
|
+
const pendingRef = (0, import_react15.useRef)(false);
|
|
2280
|
+
const [readyToOpen, setReadyToOpen] = (0, import_react15.useState)(false);
|
|
2281
|
+
(0, import_react15.useEffect)(() => {
|
|
2282
|
+
if (readyToOpen) {
|
|
2283
|
+
setReadyToOpen(false);
|
|
2284
|
+
open();
|
|
2285
|
+
}
|
|
2286
|
+
}, [readyToOpen, open]);
|
|
2287
|
+
(0, import_react15.useEffect)(() => {
|
|
2288
|
+
return (0, import_editor_v1_adapters3.__privateListenTo)((0, import_editor_v1_adapters3.routeOpenEvent)(DEFAULT_PANEL_ROUTE), () => {
|
|
2289
|
+
if (pendingRef.current) {
|
|
2290
|
+
pendingRef.current = false;
|
|
2291
|
+
setReadyToOpen(true);
|
|
2292
|
+
}
|
|
2293
|
+
});
|
|
2294
|
+
}, []);
|
|
2295
|
+
(0, import_react15.useEffect)(() => {
|
|
2296
|
+
const handler = () => {
|
|
2297
|
+
pendingRef.current = true;
|
|
2298
|
+
(0, import_editor_v1_adapters3.__privateOpenRoute)(DEFAULT_PANEL_ROUTE);
|
|
2299
|
+
};
|
|
2300
|
+
window.addEventListener(EVENT_NAME, handler);
|
|
2301
|
+
return () => window.removeEventListener(EVENT_NAME, handler);
|
|
2302
|
+
}, []);
|
|
2303
|
+
return null;
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2188
2306
|
// src/components/open-panel-from-url.tsx
|
|
2307
|
+
var import_react16 = require("react");
|
|
2308
|
+
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
2189
2309
|
var ACTIVE_PANEL_PARAM = "active-panel";
|
|
2190
2310
|
var PANEL_ID = "variables-manager";
|
|
2191
|
-
var
|
|
2311
|
+
var DEFAULT_PANEL_ROUTE2 = "panel/elements";
|
|
2192
2312
|
function OpenPanelFromUrl() {
|
|
2193
2313
|
const { open } = usePanelActions();
|
|
2194
|
-
const hasOpened = (0,
|
|
2195
|
-
(0,
|
|
2314
|
+
const hasOpened = (0, import_react16.useRef)(false);
|
|
2315
|
+
(0, import_react16.useEffect)(() => {
|
|
2196
2316
|
const urlParams = new URLSearchParams(window.location.search);
|
|
2197
2317
|
const activePanel = urlParams.get(ACTIVE_PANEL_PARAM);
|
|
2198
2318
|
if (activePanel !== PANEL_ID) {
|
|
2199
2319
|
return;
|
|
2200
2320
|
}
|
|
2201
|
-
const cleanup = (0,
|
|
2321
|
+
const cleanup = (0, import_editor_v1_adapters4.__privateListenTo)((0, import_editor_v1_adapters4.routeOpenEvent)(DEFAULT_PANEL_ROUTE2), () => {
|
|
2202
2322
|
if (hasOpened.current) {
|
|
2203
2323
|
return;
|
|
2204
2324
|
}
|
|
@@ -2214,12 +2334,12 @@ function OpenPanelFromUrl() {
|
|
|
2214
2334
|
|
|
2215
2335
|
// src/controls/variable-control.tsx
|
|
2216
2336
|
var React33 = __toESM(require("react"));
|
|
2217
|
-
var
|
|
2337
|
+
var import_editor_controls13 = require("@elementor/editor-controls");
|
|
2218
2338
|
|
|
2219
2339
|
// src/components/ui/variable/assigned-variable.tsx
|
|
2220
|
-
var
|
|
2340
|
+
var import_react23 = require("react");
|
|
2221
2341
|
var React24 = __toESM(require("react"));
|
|
2222
|
-
var
|
|
2342
|
+
var import_editor_controls8 = require("@elementor/editor-controls");
|
|
2223
2343
|
var import_icons12 = require("@elementor/icons");
|
|
2224
2344
|
var import_ui24 = require("@elementor/ui");
|
|
2225
2345
|
|
|
@@ -2241,35 +2361,35 @@ function createUnlinkHandler(variable, propTypeKey, setValue) {
|
|
|
2241
2361
|
|
|
2242
2362
|
// src/components/variable-selection-popover.tsx
|
|
2243
2363
|
var React22 = __toESM(require("react"));
|
|
2244
|
-
var
|
|
2245
|
-
var
|
|
2364
|
+
var import_react22 = require("react");
|
|
2365
|
+
var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
|
|
2246
2366
|
|
|
2247
2367
|
// src/context/variable-selection-popover.context.tsx
|
|
2248
2368
|
var React15 = __toESM(require("react"));
|
|
2249
|
-
var
|
|
2369
|
+
var import_react17 = require("react");
|
|
2250
2370
|
var import_ui15 = require("@elementor/ui");
|
|
2251
|
-
var PopoverContentRefContext = (0,
|
|
2371
|
+
var PopoverContentRefContext = (0, import_react17.createContext)(null);
|
|
2252
2372
|
var PopoverContentRefContextProvider = ({ children }) => {
|
|
2253
|
-
const [anchorRef, setAnchorRef] = (0,
|
|
2373
|
+
const [anchorRef, setAnchorRef] = (0, import_react17.useState)(null);
|
|
2254
2374
|
return /* @__PURE__ */ React15.createElement(PopoverContentRefContext.Provider, { value: anchorRef }, /* @__PURE__ */ React15.createElement(import_ui15.Box, { ref: setAnchorRef }, children));
|
|
2255
2375
|
};
|
|
2256
2376
|
var usePopoverContentRef = () => {
|
|
2257
|
-
return (0,
|
|
2377
|
+
return (0, import_react17.useContext)(PopoverContentRefContext);
|
|
2258
2378
|
};
|
|
2259
2379
|
|
|
2260
2380
|
// src/components/variable-creation.tsx
|
|
2261
2381
|
var React17 = __toESM(require("react"));
|
|
2262
|
-
var
|
|
2263
|
-
var
|
|
2382
|
+
var import_react18 = require("react");
|
|
2383
|
+
var import_editor_controls5 = require("@elementor/editor-controls");
|
|
2264
2384
|
var import_editor_ui6 = require("@elementor/editor-ui");
|
|
2265
2385
|
var import_icons6 = require("@elementor/icons");
|
|
2266
2386
|
var import_ui17 = require("@elementor/ui");
|
|
2267
2387
|
var import_i18n11 = require("@wordpress/i18n");
|
|
2268
2388
|
|
|
2269
2389
|
// src/hooks/use-initial-value.ts
|
|
2270
|
-
var
|
|
2390
|
+
var import_editor_controls3 = require("@elementor/editor-controls");
|
|
2271
2391
|
var useInitialValue = () => {
|
|
2272
|
-
const { value: initial } = (0,
|
|
2392
|
+
const { value: initial } = (0, import_editor_controls3.useBoundProp)();
|
|
2273
2393
|
const hasAssignedVariable = hasVariableType(initial?.$$type) && Boolean(initial?.value);
|
|
2274
2394
|
const variable = useVariable(hasAssignedVariable ? initial.value : "");
|
|
2275
2395
|
if (hasAssignedVariable) {
|
|
@@ -2279,11 +2399,11 @@ var useInitialValue = () => {
|
|
|
2279
2399
|
};
|
|
2280
2400
|
|
|
2281
2401
|
// src/hooks/use-variable-bound-prop.ts
|
|
2282
|
-
var
|
|
2402
|
+
var import_editor_controls4 = require("@elementor/editor-controls");
|
|
2283
2403
|
var import_editor_props3 = require("@elementor/editor-props");
|
|
2284
2404
|
var useVariableBoundProp = () => {
|
|
2285
2405
|
const { propTypeUtil } = useVariableType();
|
|
2286
|
-
const boundProp = (0,
|
|
2406
|
+
const boundProp = (0, import_editor_controls4.useBoundProp)(propTypeUtil);
|
|
2287
2407
|
return {
|
|
2288
2408
|
...boundProp,
|
|
2289
2409
|
setVariableValue: (value) => resolveBoundPropAndSetValue(value, boundProp),
|
|
@@ -2318,13 +2438,13 @@ var SIZE2 = "tiny";
|
|
|
2318
2438
|
var VariableCreation = ({ onGoBack, onClose }) => {
|
|
2319
2439
|
const { icon: VariableIcon, valueField: ValueField, variableType, propTypeUtil } = useVariableType();
|
|
2320
2440
|
const { setVariableValue: setVariable, path } = useVariableBoundProp();
|
|
2321
|
-
const { propType } = (0,
|
|
2441
|
+
const { propType } = (0, import_editor_controls5.useBoundProp)();
|
|
2322
2442
|
const initialValue = useInitialValue();
|
|
2323
|
-
const [value, setValue] = (0,
|
|
2324
|
-
const [label, setLabel] = (0,
|
|
2325
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
2326
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
2327
|
-
const [propTypeKey, setPropTypeKey] = (0,
|
|
2443
|
+
const [value, setValue] = (0, import_react18.useState)(initialValue);
|
|
2444
|
+
const [label, setLabel] = (0, import_react18.useState)("");
|
|
2445
|
+
const [errorMessage, setErrorMessage] = (0, import_react18.useState)("");
|
|
2446
|
+
const [valueFieldError, setValueFieldError] = (0, import_react18.useState)("");
|
|
2447
|
+
const [propTypeKey, setPropTypeKey] = (0, import_react18.useState)(propTypeUtil.key);
|
|
2328
2448
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
2329
2449
|
const resetFields = () => {
|
|
2330
2450
|
setValue("");
|
|
@@ -2388,7 +2508,7 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2388
2508
|
title: (0, import_i18n11.__)("Create variable", "elementor"),
|
|
2389
2509
|
onClose: closePopover
|
|
2390
2510
|
}
|
|
2391
|
-
), /* @__PURE__ */ React17.createElement(import_ui17.Divider, null), /* @__PURE__ */ React17.createElement(
|
|
2511
|
+
), /* @__PURE__ */ React17.createElement(import_ui17.Divider, null), /* @__PURE__ */ React17.createElement(import_editor_controls5.PopoverContent, { p: 2 }, /* @__PURE__ */ React17.createElement(
|
|
2392
2512
|
FormField,
|
|
2393
2513
|
{
|
|
2394
2514
|
id: "variable-label",
|
|
@@ -2408,11 +2528,12 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2408
2528
|
},
|
|
2409
2529
|
onErrorChange: (errorMsg) => {
|
|
2410
2530
|
setLabelFieldError({
|
|
2411
|
-
value:
|
|
2531
|
+
value: "",
|
|
2412
2532
|
message: errorMsg
|
|
2413
2533
|
});
|
|
2414
2534
|
},
|
|
2415
|
-
onKeyDown: handleKeyDown
|
|
2535
|
+
onKeyDown: handleKeyDown,
|
|
2536
|
+
focusOnShow: true
|
|
2416
2537
|
}
|
|
2417
2538
|
)
|
|
2418
2539
|
), ValueField && /* @__PURE__ */ React17.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n11.__)("Value", "elementor") }, /* @__PURE__ */ React17.createElement(import_ui17.Typography, { variant: "h5", id: "variable-value-wrapper" }, /* @__PURE__ */ React17.createElement(
|
|
@@ -2444,8 +2565,8 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2444
2565
|
|
|
2445
2566
|
// src/components/variable-edit.tsx
|
|
2446
2567
|
var React19 = __toESM(require("react"));
|
|
2447
|
-
var
|
|
2448
|
-
var
|
|
2568
|
+
var import_react20 = require("react");
|
|
2569
|
+
var import_editor_controls6 = require("@elementor/editor-controls");
|
|
2449
2570
|
var import_editor_current_user3 = require("@elementor/editor-current-user");
|
|
2450
2571
|
var import_editor_ui7 = require("@elementor/editor-ui");
|
|
2451
2572
|
var import_icons8 = require("@elementor/icons");
|
|
@@ -2454,7 +2575,7 @@ var import_i18n13 = require("@wordpress/i18n");
|
|
|
2454
2575
|
|
|
2455
2576
|
// src/components/ui/edit-confirmation-dialog.tsx
|
|
2456
2577
|
var React18 = __toESM(require("react"));
|
|
2457
|
-
var
|
|
2578
|
+
var import_react19 = require("react");
|
|
2458
2579
|
var import_icons7 = require("@elementor/icons");
|
|
2459
2580
|
var import_ui18 = require("@elementor/ui");
|
|
2460
2581
|
var import_i18n12 = require("@wordpress/i18n");
|
|
@@ -2464,7 +2585,7 @@ var EditConfirmationDialog = ({
|
|
|
2464
2585
|
onConfirm,
|
|
2465
2586
|
onSuppressMessage
|
|
2466
2587
|
}) => {
|
|
2467
|
-
const [dontShowAgain, setDontShowAgain] = (0,
|
|
2588
|
+
const [dontShowAgain, setDontShowAgain] = (0, import_react19.useState)(false);
|
|
2468
2589
|
const handleSave = () => {
|
|
2469
2590
|
if (dontShowAgain) {
|
|
2470
2591
|
onSuppressMessage?.();
|
|
@@ -2496,22 +2617,22 @@ var DELETE_LABEL = (0, import_i18n13.__)("Delete variable", "elementor");
|
|
|
2496
2617
|
var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
2497
2618
|
const { icon: VariableIcon, valueField: ValueField, variableType, propTypeUtil } = useVariableType();
|
|
2498
2619
|
const { setVariableValue: notifyBoundPropChange, variableId } = useVariableBoundProp();
|
|
2499
|
-
const { propType } = (0,
|
|
2620
|
+
const { propType } = (0, import_editor_controls6.useBoundProp)();
|
|
2500
2621
|
const [isMessageSuppressed, suppressMessage] = (0, import_editor_current_user3.useSuppressedMessage)(EDIT_CONFIRMATION_DIALOG_ID);
|
|
2501
|
-
const [deleteConfirmation, setDeleteConfirmation] = (0,
|
|
2502
|
-
const [editConfirmation, setEditConfirmation] = (0,
|
|
2503
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
2504
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
2622
|
+
const [deleteConfirmation, setDeleteConfirmation] = (0, import_react20.useState)(false);
|
|
2623
|
+
const [editConfirmation, setEditConfirmation] = (0, import_react20.useState)(false);
|
|
2624
|
+
const [errorMessage, setErrorMessage] = (0, import_react20.useState)("");
|
|
2625
|
+
const [valueFieldError, setValueFieldError] = (0, import_react20.useState)("");
|
|
2505
2626
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
2506
2627
|
const variable = useVariable(editId);
|
|
2507
|
-
const [propTypeKey, setPropTypeKey] = (0,
|
|
2628
|
+
const [propTypeKey, setPropTypeKey] = (0, import_react20.useState)(variable?.type ?? propTypeUtil.key);
|
|
2508
2629
|
if (!variable) {
|
|
2509
2630
|
throw new Error(`Global ${variableType} variable not found`);
|
|
2510
2631
|
}
|
|
2511
2632
|
const userPermissions = usePermissions();
|
|
2512
|
-
const [value, setValue] = (0,
|
|
2513
|
-
const [label, setLabel] = (0,
|
|
2514
|
-
(0,
|
|
2633
|
+
const [value, setValue] = (0, import_react20.useState)(() => variable.value);
|
|
2634
|
+
const [label, setLabel] = (0, import_react20.useState)(() => variable.label);
|
|
2635
|
+
(0, import_react20.useEffect)(() => {
|
|
2515
2636
|
styleVariablesRepository.update({
|
|
2516
2637
|
[editId]: {
|
|
2517
2638
|
...variable,
|
|
@@ -2614,7 +2735,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2614
2735
|
), /* @__PURE__ */ React19.createElement(VariableIcon, { fontSize: SIZE3 })),
|
|
2615
2736
|
actions
|
|
2616
2737
|
}
|
|
2617
|
-
), /* @__PURE__ */ React19.createElement(import_ui19.Divider, null), /* @__PURE__ */ React19.createElement(
|
|
2738
|
+
), /* @__PURE__ */ React19.createElement(import_ui19.Divider, null), /* @__PURE__ */ React19.createElement(import_editor_controls6.PopoverContent, { p: 2 }, /* @__PURE__ */ React19.createElement(
|
|
2618
2739
|
FormField,
|
|
2619
2740
|
{
|
|
2620
2741
|
id: "variable-label",
|
|
@@ -2634,11 +2755,12 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2634
2755
|
},
|
|
2635
2756
|
onErrorChange: (errorMsg) => {
|
|
2636
2757
|
setLabelFieldError({
|
|
2637
|
-
value:
|
|
2758
|
+
value: "",
|
|
2638
2759
|
message: errorMsg
|
|
2639
2760
|
});
|
|
2640
2761
|
},
|
|
2641
|
-
onKeyDown: handleKeyDown
|
|
2762
|
+
onKeyDown: handleKeyDown,
|
|
2763
|
+
focusOnShow: true
|
|
2642
2764
|
}
|
|
2643
2765
|
)
|
|
2644
2766
|
), ValueField && /* @__PURE__ */ React19.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n13.__)("Value", "elementor") }, /* @__PURE__ */ React19.createElement(import_ui19.Typography, { variant: "h5" }, /* @__PURE__ */ React19.createElement(
|
|
@@ -2675,8 +2797,9 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2675
2797
|
};
|
|
2676
2798
|
|
|
2677
2799
|
// src/components/variables-selection.tsx
|
|
2678
|
-
var
|
|
2800
|
+
var import_react21 = require("react");
|
|
2679
2801
|
var React21 = __toESM(require("react"));
|
|
2802
|
+
var import_editor_controls7 = require("@elementor/editor-controls");
|
|
2680
2803
|
var import_editor_ui9 = require("@elementor/editor-ui");
|
|
2681
2804
|
var import_editor_ui10 = require("@elementor/editor-ui");
|
|
2682
2805
|
var import_icons10 = require("@elementor/icons");
|
|
@@ -2782,7 +2905,7 @@ var getProUpgradeUrl = (variableType) => `https://go.elementor.com/renew-license
|
|
|
2782
2905
|
var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled = false }) => {
|
|
2783
2906
|
const { icon: VariableIcon, startIcon, variableType, propTypeUtil, emptyState } = useVariableType();
|
|
2784
2907
|
const { value: variable, setValue: setVariable, path } = useVariableBoundProp();
|
|
2785
|
-
const [searchValue, setSearchValue] = (0,
|
|
2908
|
+
const [searchValue, setSearchValue] = (0, import_react21.useState)("");
|
|
2786
2909
|
const {
|
|
2787
2910
|
list: variables,
|
|
2788
2911
|
hasMatches: hasSearchResults,
|
|
@@ -2859,6 +2982,15 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled =
|
|
|
2859
2982
|
const handleClearSearch = () => {
|
|
2860
2983
|
setSearchValue("");
|
|
2861
2984
|
};
|
|
2985
|
+
(0, import_react21.useEffect)(() => {
|
|
2986
|
+
if (disabled) {
|
|
2987
|
+
(0, import_editor_controls7.trackViewPromotion)({
|
|
2988
|
+
target_name: "variables_popover",
|
|
2989
|
+
target_location: "widget_panel",
|
|
2990
|
+
location_l1: "variables_list"
|
|
2991
|
+
});
|
|
2992
|
+
}
|
|
2993
|
+
}, [disabled]);
|
|
2862
2994
|
return /* @__PURE__ */ React21.createElement(import_editor_ui9.SectionPopoverBody, null, /* @__PURE__ */ React21.createElement(
|
|
2863
2995
|
import_editor_ui9.PopoverHeader,
|
|
2864
2996
|
{
|
|
@@ -2895,7 +3027,11 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled =
|
|
|
2895
3027
|
(0, import_i18n15.__)("Upgrade to continue creating and editing %s variables.", "elementor"),
|
|
2896
3028
|
variableType
|
|
2897
3029
|
),
|
|
2898
|
-
upgradeUrl: getProUpgradeUrl(variableType)
|
|
3030
|
+
upgradeUrl: getProUpgradeUrl(variableType),
|
|
3031
|
+
onCtaClick: () => (0, import_editor_controls7.trackUpgradePromotionClick)({
|
|
3032
|
+
target_name: "variables_popover",
|
|
3033
|
+
location_l1: "variables_list"
|
|
3034
|
+
})
|
|
2899
3035
|
}
|
|
2900
3036
|
)), !hasSearchResults && hasVariables && /* @__PURE__ */ React21.createElement(
|
|
2901
3037
|
NoSearchResults,
|
|
@@ -2954,10 +3090,10 @@ var VIEW_LIST = "list";
|
|
|
2954
3090
|
var VIEW_ADD = "add";
|
|
2955
3091
|
var VIEW_EDIT = "edit";
|
|
2956
3092
|
var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
|
|
2957
|
-
const [currentView, setCurrentView] = (0,
|
|
2958
|
-
const [editId, setEditId] = (0,
|
|
3093
|
+
const [currentView, setCurrentView] = (0, import_react22.useState)(VIEW_LIST);
|
|
3094
|
+
const [editId, setEditId] = (0, import_react22.useState)("");
|
|
2959
3095
|
const { open } = usePanelActions();
|
|
2960
|
-
const onSettingsAvailable = (0,
|
|
3096
|
+
const onSettingsAvailable = (0, import_editor_v1_adapters5.isExperimentActive)("e_variables_manager") ? () => {
|
|
2961
3097
|
open();
|
|
2962
3098
|
} : void 0;
|
|
2963
3099
|
return /* @__PURE__ */ React22.createElement(VariableTypeProvider, { propTypeKey }, /* @__PURE__ */ React22.createElement(PopoverContentRefContextProvider, null, RenderView({
|
|
@@ -3065,9 +3201,9 @@ var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
|
|
|
3065
3201
|
// src/components/ui/variable/assigned-variable.tsx
|
|
3066
3202
|
var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
3067
3203
|
const { startIcon, propTypeUtil } = getVariableType(propTypeKey);
|
|
3068
|
-
const { setValue } = (0,
|
|
3069
|
-
const anchorRef = (0,
|
|
3070
|
-
const popupId = (0,
|
|
3204
|
+
const { setValue } = (0, import_editor_controls8.useBoundProp)();
|
|
3205
|
+
const anchorRef = (0, import_react23.useRef)(null);
|
|
3206
|
+
const popupId = (0, import_react23.useId)();
|
|
3071
3207
|
const popupState = (0, import_ui24.usePopupState)({
|
|
3072
3208
|
variant: "popover",
|
|
3073
3209
|
popupId: `elementor-variables-list-${popupId}`
|
|
@@ -3107,15 +3243,15 @@ var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
|
3107
3243
|
|
|
3108
3244
|
// src/components/ui/variable/deleted-variable.tsx
|
|
3109
3245
|
var React28 = __toESM(require("react"));
|
|
3110
|
-
var
|
|
3111
|
-
var
|
|
3246
|
+
var import_react25 = require("react");
|
|
3247
|
+
var import_editor_controls10 = require("@elementor/editor-controls");
|
|
3112
3248
|
var import_ui28 = require("@elementor/ui");
|
|
3113
3249
|
var import_i18n19 = require("@wordpress/i18n");
|
|
3114
3250
|
|
|
3115
3251
|
// src/components/variable-restore.tsx
|
|
3116
3252
|
var React25 = __toESM(require("react"));
|
|
3117
|
-
var
|
|
3118
|
-
var
|
|
3253
|
+
var import_react24 = require("react");
|
|
3254
|
+
var import_editor_controls9 = require("@elementor/editor-controls");
|
|
3119
3255
|
var import_editor_ui11 = require("@elementor/editor-ui");
|
|
3120
3256
|
var import_ui25 = require("@elementor/ui");
|
|
3121
3257
|
var import_i18n17 = require("@wordpress/i18n");
|
|
@@ -3123,16 +3259,16 @@ var SIZE7 = "tiny";
|
|
|
3123
3259
|
var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
3124
3260
|
const { icon: VariableIcon, valueField: ValueField, variableType, propTypeUtil } = useVariableType();
|
|
3125
3261
|
const { setVariableValue: notifyBoundPropChange } = useVariableBoundProp();
|
|
3126
|
-
const { propType } = (0,
|
|
3262
|
+
const { propType } = (0, import_editor_controls9.useBoundProp)();
|
|
3127
3263
|
const variable = useVariable(variableId);
|
|
3128
3264
|
if (!variable) {
|
|
3129
3265
|
throw new Error(`Global ${variableType} variable not found`);
|
|
3130
3266
|
}
|
|
3131
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
3132
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
3133
|
-
const [label, setLabel] = (0,
|
|
3134
|
-
const [value, setValue] = (0,
|
|
3135
|
-
const [propTypeKey, setPropTypeKey] = (0,
|
|
3267
|
+
const [errorMessage, setErrorMessage] = (0, import_react24.useState)("");
|
|
3268
|
+
const [valueFieldError, setValueFieldError] = (0, import_react24.useState)("");
|
|
3269
|
+
const [label, setLabel] = (0, import_react24.useState)(variable.label);
|
|
3270
|
+
const [value, setValue] = (0, import_react24.useState)(variable.value);
|
|
3271
|
+
const [propTypeKey, setPropTypeKey] = (0, import_react24.useState)(variable?.type ?? propTypeUtil.key);
|
|
3136
3272
|
const { labelFieldError, setLabelFieldError } = useLabelError({
|
|
3137
3273
|
value: variable.label,
|
|
3138
3274
|
message: ERROR_MESSAGES.DUPLICATED_LABEL
|
|
@@ -3185,7 +3321,7 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
3185
3321
|
title: (0, import_i18n17.__)("Restore variable", "elementor"),
|
|
3186
3322
|
onClose
|
|
3187
3323
|
}
|
|
3188
|
-
), /* @__PURE__ */ React25.createElement(import_ui25.Divider, null), /* @__PURE__ */ React25.createElement(
|
|
3324
|
+
), /* @__PURE__ */ React25.createElement(import_ui25.Divider, null), /* @__PURE__ */ React25.createElement(import_editor_controls9.PopoverContent, { p: 2 }, /* @__PURE__ */ React25.createElement(
|
|
3189
3325
|
FormField,
|
|
3190
3326
|
{
|
|
3191
3327
|
id: "variable-label",
|
|
@@ -3205,11 +3341,12 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
3205
3341
|
},
|
|
3206
3342
|
onErrorChange: (errorMsg) => {
|
|
3207
3343
|
setLabelFieldError({
|
|
3208
|
-
value:
|
|
3344
|
+
value: "",
|
|
3209
3345
|
message: errorMsg
|
|
3210
3346
|
});
|
|
3211
3347
|
},
|
|
3212
|
-
onKeyDown: handleKeyDown
|
|
3348
|
+
onKeyDown: handleKeyDown,
|
|
3349
|
+
focusOnShow: true
|
|
3213
3350
|
}
|
|
3214
3351
|
)
|
|
3215
3352
|
), ValueField && /* @__PURE__ */ React25.createElement(FormField, { errorMsg: valueFieldError, label: (0, import_i18n17.__)("Value", "elementor") }, /* @__PURE__ */ React25.createElement(import_ui25.Typography, { variant: "h5" }, /* @__PURE__ */ React25.createElement(
|
|
@@ -3286,13 +3423,13 @@ WarningVariableTag.displayName = "WarningVariableTag";
|
|
|
3286
3423
|
// src/components/ui/variable/deleted-variable.tsx
|
|
3287
3424
|
var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
3288
3425
|
const { propTypeUtil } = getVariableType(propTypeKey);
|
|
3289
|
-
const boundProp = (0,
|
|
3426
|
+
const boundProp = (0, import_editor_controls10.useBoundProp)();
|
|
3290
3427
|
const userPermissions = usePermissions();
|
|
3291
|
-
const [showInfotip, setShowInfotip] = (0,
|
|
3428
|
+
const [showInfotip, setShowInfotip] = (0, import_react25.useState)(false);
|
|
3292
3429
|
const toggleInfotip = () => setShowInfotip((prev) => !prev);
|
|
3293
3430
|
const closeInfotip = () => setShowInfotip(false);
|
|
3294
|
-
const deletedChipAnchorRef = (0,
|
|
3295
|
-
const popupId = (0,
|
|
3431
|
+
const deletedChipAnchorRef = (0, import_react25.useRef)(null);
|
|
3432
|
+
const popupId = (0, import_react25.useId)();
|
|
3296
3433
|
const popupState = (0, import_ui28.usePopupState)({
|
|
3297
3434
|
variant: "popover",
|
|
3298
3435
|
popupId: `elementor-variables-restore-${popupId}`
|
|
@@ -3379,8 +3516,8 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
3379
3516
|
|
|
3380
3517
|
// src/components/ui/variable/mismatch-variable.tsx
|
|
3381
3518
|
var React30 = __toESM(require("react"));
|
|
3382
|
-
var
|
|
3383
|
-
var
|
|
3519
|
+
var import_react26 = require("react");
|
|
3520
|
+
var import_editor_controls11 = require("@elementor/editor-controls");
|
|
3384
3521
|
var import_ui30 = require("@elementor/ui");
|
|
3385
3522
|
var import_i18n21 = require("@wordpress/i18n");
|
|
3386
3523
|
|
|
@@ -3416,14 +3553,14 @@ var MismatchVariableAlert = ({ onClose, onClear, triggerSelect }) => {
|
|
|
3416
3553
|
|
|
3417
3554
|
// src/components/ui/variable/mismatch-variable.tsx
|
|
3418
3555
|
var MismatchVariable = ({ variable }) => {
|
|
3419
|
-
const { setValue, value } = (0,
|
|
3420
|
-
const anchorRef = (0,
|
|
3421
|
-
const popupId = (0,
|
|
3556
|
+
const { setValue, value } = (0, import_editor_controls11.useBoundProp)();
|
|
3557
|
+
const anchorRef = (0, import_react26.useRef)(null);
|
|
3558
|
+
const popupId = (0, import_react26.useId)();
|
|
3422
3559
|
const popupState = (0, import_ui30.usePopupState)({
|
|
3423
3560
|
variant: "popover",
|
|
3424
3561
|
popupId: `elementor-variables-list-${popupId}`
|
|
3425
3562
|
});
|
|
3426
|
-
const [infotipVisible, setInfotipVisible] = (0,
|
|
3563
|
+
const [infotipVisible, setInfotipVisible] = (0, import_react26.useState)(false);
|
|
3427
3564
|
const toggleInfotip = () => setInfotipVisible((prev) => !prev);
|
|
3428
3565
|
const closeInfotip = () => setInfotipVisible(false);
|
|
3429
3566
|
const triggerSelect = () => {
|
|
@@ -3496,8 +3633,8 @@ var MismatchVariable = ({ variable }) => {
|
|
|
3496
3633
|
|
|
3497
3634
|
// src/components/ui/variable/missing-variable.tsx
|
|
3498
3635
|
var React32 = __toESM(require("react"));
|
|
3499
|
-
var
|
|
3500
|
-
var
|
|
3636
|
+
var import_react27 = require("react");
|
|
3637
|
+
var import_editor_controls12 = require("@elementor/editor-controls");
|
|
3501
3638
|
var import_ui32 = require("@elementor/ui");
|
|
3502
3639
|
var import_i18n23 = require("@wordpress/i18n");
|
|
3503
3640
|
|
|
@@ -3525,8 +3662,8 @@ var MissingVariableAlert = ({ onClose, onClear }) => {
|
|
|
3525
3662
|
|
|
3526
3663
|
// src/components/ui/variable/missing-variable.tsx
|
|
3527
3664
|
var MissingVariable = () => {
|
|
3528
|
-
const { setValue } = (0,
|
|
3529
|
-
const [infotipVisible, setInfotipVisible] = (0,
|
|
3665
|
+
const { setValue } = (0, import_editor_controls12.useBoundProp)();
|
|
3666
|
+
const [infotipVisible, setInfotipVisible] = (0, import_react27.useState)(false);
|
|
3530
3667
|
const toggleInfotip = () => setInfotipVisible((prev) => !prev);
|
|
3531
3668
|
const closeInfotip = () => setInfotipVisible(false);
|
|
3532
3669
|
const clearValue = () => setValue(null);
|
|
@@ -3556,7 +3693,7 @@ var MissingVariable = () => {
|
|
|
3556
3693
|
|
|
3557
3694
|
// src/controls/variable-control.tsx
|
|
3558
3695
|
var VariableControl = () => {
|
|
3559
|
-
const boundProp = (0,
|
|
3696
|
+
const boundProp = (0, import_editor_controls13.useBoundProp)();
|
|
3560
3697
|
const boundPropValue = boundProp.value ?? boundProp.placeholder;
|
|
3561
3698
|
const assignedVariable = useVariable(boundPropValue?.value);
|
|
3562
3699
|
if (!assignedVariable) {
|
|
@@ -3575,11 +3712,11 @@ var VariableControl = () => {
|
|
|
3575
3712
|
|
|
3576
3713
|
// src/hooks/use-prop-variable-action.tsx
|
|
3577
3714
|
var React34 = __toESM(require("react"));
|
|
3578
|
-
var
|
|
3715
|
+
var import_editor_controls14 = require("@elementor/editor-controls");
|
|
3579
3716
|
var import_icons14 = require("@elementor/icons");
|
|
3580
3717
|
var import_i18n24 = require("@wordpress/i18n");
|
|
3581
3718
|
var usePropVariableAction = () => {
|
|
3582
|
-
const { propType, path } = (0,
|
|
3719
|
+
const { propType, path } = (0, import_editor_controls14.useBoundProp)();
|
|
3583
3720
|
const variable = resolveVariableFromPropType(propType);
|
|
3584
3721
|
return {
|
|
3585
3722
|
visible: Boolean(variable),
|
|
@@ -3614,22 +3751,15 @@ var trackOpenVariablePopover = (path, variableType) => {
|
|
|
3614
3751
|
});
|
|
3615
3752
|
};
|
|
3616
3753
|
|
|
3617
|
-
// src/mcp/index.ts
|
|
3618
|
-
var import_editor_mcp3 = require("@elementor/editor-mcp");
|
|
3619
|
-
|
|
3620
3754
|
// src/mcp/manage-variable-tool.ts
|
|
3621
|
-
var import_editor_mcp2 = require("@elementor/editor-mcp");
|
|
3622
3755
|
var import_schema3 = require("@elementor/schema");
|
|
3623
3756
|
|
|
3624
3757
|
// src/mcp/variables-resource.ts
|
|
3625
|
-
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
3626
3758
|
var GLOBAL_VARIABLES_URI = "elementor://global-variables";
|
|
3627
|
-
var initVariablesResource = () => {
|
|
3628
|
-
const canvasMcpEntry = (0, import_editor_mcp.getMCPByDomain)("canvas");
|
|
3629
|
-
const variablesMcpEntry = (0, import_editor_mcp.getMCPByDomain)("variables");
|
|
3759
|
+
var initVariablesResource = (variablesMcpEntry, canvasMcpEntry) => {
|
|
3630
3760
|
[canvasMcpEntry, variablesMcpEntry].forEach((entry) => {
|
|
3631
|
-
const {
|
|
3632
|
-
|
|
3761
|
+
const { resource, sendResourceUpdated } = entry;
|
|
3762
|
+
resource(
|
|
3633
3763
|
"global-variables",
|
|
3634
3764
|
GLOBAL_VARIABLES_URI,
|
|
3635
3765
|
{
|
|
@@ -3648,7 +3778,7 @@ var initVariablesResource = () => {
|
|
|
3648
3778
|
}
|
|
3649
3779
|
);
|
|
3650
3780
|
window.addEventListener("variables:updated", () => {
|
|
3651
|
-
|
|
3781
|
+
sendResourceUpdated({
|
|
3652
3782
|
uri: GLOBAL_VARIABLES_URI
|
|
3653
3783
|
});
|
|
3654
3784
|
});
|
|
@@ -3656,8 +3786,9 @@ var initVariablesResource = () => {
|
|
|
3656
3786
|
};
|
|
3657
3787
|
|
|
3658
3788
|
// src/mcp/manage-variable-tool.ts
|
|
3659
|
-
var initManageVariableTool = () => {
|
|
3660
|
-
|
|
3789
|
+
var initManageVariableTool = (reg) => {
|
|
3790
|
+
const { addTool } = reg;
|
|
3791
|
+
addTool({
|
|
3661
3792
|
name: "manage-global-variable",
|
|
3662
3793
|
schema: {
|
|
3663
3794
|
action: import_schema3.z.enum(["create", "update", "delete"]).describe("Operation to perform"),
|
|
@@ -3727,30 +3858,36 @@ function getServiceActions(svc) {
|
|
|
3727
3858
|
}
|
|
3728
3859
|
|
|
3729
3860
|
// src/mcp/index.ts
|
|
3730
|
-
function initMcp() {
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3861
|
+
function initMcp(reg, canvasMcpEntry) {
|
|
3862
|
+
const { setMCPDescription } = reg;
|
|
3863
|
+
setMCPDescription(
|
|
3864
|
+
`Everything related to V4 ( Atomic ) variables.
|
|
3865
|
+
# Global variables
|
|
3866
|
+
- Create/update/delete global variables
|
|
3867
|
+
- Get list of global variables
|
|
3868
|
+
- Get details of a global variable
|
|
3869
|
+
`
|
|
3870
|
+
);
|
|
3871
|
+
initManageVariableTool(reg);
|
|
3872
|
+
initVariablesResource(reg, canvasMcpEntry);
|
|
3736
3873
|
}
|
|
3737
3874
|
|
|
3738
3875
|
// src/register-variable-types.tsx
|
|
3739
3876
|
var React37 = __toESM(require("react"));
|
|
3877
|
+
var import_editor_controls16 = require("@elementor/editor-controls");
|
|
3740
3878
|
var import_editor_props5 = require("@elementor/editor-props");
|
|
3741
3879
|
var import_editor_ui13 = require("@elementor/editor-ui");
|
|
3742
|
-
var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
|
|
3743
3880
|
var import_icons16 = require("@elementor/icons");
|
|
3744
3881
|
var import_i18n26 = require("@wordpress/i18n");
|
|
3745
3882
|
|
|
3746
3883
|
// src/components/fields/color-field.tsx
|
|
3747
3884
|
var React35 = __toESM(require("react"));
|
|
3748
|
-
var
|
|
3885
|
+
var import_react28 = require("react");
|
|
3749
3886
|
var import_ui33 = require("@elementor/ui");
|
|
3750
3887
|
var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
3751
|
-
const [color, setColor] = (0,
|
|
3752
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
3753
|
-
const defaultRef = (0,
|
|
3888
|
+
const [color, setColor] = (0, import_react28.useState)(value);
|
|
3889
|
+
const [errorMessage, setErrorMessage] = (0, import_react28.useState)("");
|
|
3890
|
+
const defaultRef = (0, import_react28.useRef)(null);
|
|
3754
3891
|
const anchorRef = usePopoverContentRef() ?? defaultRef.current;
|
|
3755
3892
|
const handleChange = (newValue) => {
|
|
3756
3893
|
setColor(newValue);
|
|
@@ -3789,18 +3926,18 @@ var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
|
3789
3926
|
|
|
3790
3927
|
// src/components/fields/font-field.tsx
|
|
3791
3928
|
var React36 = __toESM(require("react"));
|
|
3792
|
-
var
|
|
3793
|
-
var
|
|
3929
|
+
var import_react29 = require("react");
|
|
3930
|
+
var import_editor_controls15 = require("@elementor/editor-controls");
|
|
3794
3931
|
var import_editor_ui12 = require("@elementor/editor-ui");
|
|
3795
3932
|
var import_icons15 = require("@elementor/icons");
|
|
3796
3933
|
var import_ui34 = require("@elementor/ui");
|
|
3797
3934
|
var import_i18n25 = require("@wordpress/i18n");
|
|
3798
3935
|
var FontField = ({ value, onChange, onValidationChange }) => {
|
|
3799
|
-
const [fontFamily, setFontFamily] = (0,
|
|
3800
|
-
const defaultRef = (0,
|
|
3936
|
+
const [fontFamily, setFontFamily] = (0, import_react29.useState)(value);
|
|
3937
|
+
const defaultRef = (0, import_react29.useRef)(null);
|
|
3801
3938
|
const anchorRef = usePopoverContentRef() ?? defaultRef.current;
|
|
3802
3939
|
const fontPopoverState = (0, import_ui34.usePopupState)({ variant: "popover" });
|
|
3803
|
-
const fontFamilies = (0,
|
|
3940
|
+
const fontFamilies = (0, import_editor_controls15.useFontFamilies)();
|
|
3804
3941
|
const sectionWidth = (0, import_editor_ui12.useSectionWidth)();
|
|
3805
3942
|
const mapFontSubs = React36.useMemo(() => {
|
|
3806
3943
|
return fontFamilies.map(({ label, fonts }) => ({
|
|
@@ -3818,7 +3955,7 @@ var FontField = ({ value, onChange, onValidationChange }) => {
|
|
|
3818
3955
|
handleChange(newFontFamily);
|
|
3819
3956
|
fontPopoverState.close();
|
|
3820
3957
|
};
|
|
3821
|
-
const id2 = (0,
|
|
3958
|
+
const id2 = (0, import_react29.useId)();
|
|
3822
3959
|
return /* @__PURE__ */ React36.createElement(React36.Fragment, null, /* @__PURE__ */ React36.createElement(
|
|
3823
3960
|
import_ui34.UnstableTag,
|
|
3824
3961
|
{
|
|
@@ -3840,7 +3977,7 @@ var FontField = ({ value, onChange, onValidationChange }) => {
|
|
|
3840
3977
|
...(0, import_ui34.bindPopover)(fontPopoverState)
|
|
3841
3978
|
},
|
|
3842
3979
|
/* @__PURE__ */ React36.createElement(
|
|
3843
|
-
|
|
3980
|
+
import_editor_controls15.ItemSelector,
|
|
3844
3981
|
{
|
|
3845
3982
|
id: "font-family-variables-selector",
|
|
3846
3983
|
itemsList: mapFontSubs,
|
|
@@ -3850,7 +3987,7 @@ var FontField = ({ value, onChange, onValidationChange }) => {
|
|
|
3850
3987
|
sectionWidth,
|
|
3851
3988
|
title: (0, import_i18n25.__)("Font family", "elementor"),
|
|
3852
3989
|
itemStyle: (item) => ({ fontFamily: item.value }),
|
|
3853
|
-
onDebounce:
|
|
3990
|
+
onDebounce: import_editor_controls15.enqueueFont,
|
|
3854
3991
|
icon: import_icons15.TextIcon
|
|
3855
3992
|
}
|
|
3856
3993
|
)
|
|
@@ -3881,20 +4018,17 @@ function registerVariableTypes() {
|
|
|
3881
4018
|
defaultValue: "#ffffff",
|
|
3882
4019
|
menuActionsFactory: ({ variable, variableId, handlers }) => {
|
|
3883
4020
|
const actions = [];
|
|
3884
|
-
if (!(0, import_editor_v1_adapters5.isExperimentActive)("e_design_system_sync")) {
|
|
3885
|
-
return [];
|
|
3886
|
-
}
|
|
3887
4021
|
if (variable.sync_to_v3) {
|
|
3888
4022
|
actions.push({
|
|
3889
|
-
name: (0, import_i18n26.__)("Stop syncing to
|
|
3890
|
-
icon: import_icons16.
|
|
4023
|
+
name: (0, import_i18n26.__)("Stop syncing to Global Colors", "elementor"),
|
|
4024
|
+
icon: import_icons16.RefreshOffIcon,
|
|
3891
4025
|
color: "text.primary",
|
|
3892
4026
|
onClick: () => handlers.onStopSync(variableId)
|
|
3893
4027
|
});
|
|
3894
4028
|
} else {
|
|
3895
4029
|
actions.push({
|
|
3896
|
-
name: (0, import_i18n26.__)("Sync to
|
|
3897
|
-
icon: import_icons16.
|
|
4030
|
+
name: (0, import_i18n26.__)("Sync to Global Colors", "elementor"),
|
|
4031
|
+
icon: import_icons16.RefreshIcon,
|
|
3898
4032
|
color: "text.primary",
|
|
3899
4033
|
onClick: () => handlers.onStartSync(variableId)
|
|
3900
4034
|
});
|
|
@@ -3919,7 +4053,14 @@ function registerVariableTypes() {
|
|
|
3919
4053
|
styleTransformer: EmptyTransformer,
|
|
3920
4054
|
variableType: "size",
|
|
3921
4055
|
selectionFilter: () => [],
|
|
3922
|
-
emptyState: /* @__PURE__ */ React37.createElement(
|
|
4056
|
+
emptyState: /* @__PURE__ */ React37.createElement(
|
|
4057
|
+
import_editor_ui13.CtaButton,
|
|
4058
|
+
{
|
|
4059
|
+
size: "small",
|
|
4060
|
+
href: "https://go.elementor.com/go-pro-panel-size-variable/",
|
|
4061
|
+
onClick: () => (0, import_editor_controls16.trackUpgradePromotionClick)({ target_name: "variables_popover", location_l1: "variables_list" })
|
|
4062
|
+
}
|
|
4063
|
+
)
|
|
3923
4064
|
};
|
|
3924
4065
|
registerVariableType({
|
|
3925
4066
|
...sizePromotions,
|
|
@@ -3934,10 +4075,10 @@ function registerVariableTypes() {
|
|
|
3934
4075
|
|
|
3935
4076
|
// src/renderers/style-variables-renderer.tsx
|
|
3936
4077
|
var React38 = __toESM(require("react"));
|
|
3937
|
-
var
|
|
4078
|
+
var import_react30 = require("react");
|
|
3938
4079
|
var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
|
|
3939
4080
|
var import_ui35 = require("@elementor/ui");
|
|
3940
|
-
var VARIABLES_WRAPPER = "
|
|
4081
|
+
var VARIABLES_WRAPPER = ":root";
|
|
3941
4082
|
function StyleVariablesRenderer() {
|
|
3942
4083
|
const container = usePortalContainer();
|
|
3943
4084
|
const styleVariables = useStyleVariables();
|
|
@@ -3953,8 +4094,8 @@ function usePortalContainer() {
|
|
|
3953
4094
|
return (0, import_editor_v1_adapters6.__privateUseListenTo)((0, import_editor_v1_adapters6.commandEndEvent)("editor/documents/attach-preview"), () => (0, import_editor_v1_adapters6.getCanvasIframeDocument)()?.head);
|
|
3954
4095
|
}
|
|
3955
4096
|
function useStyleVariables() {
|
|
3956
|
-
const [variables, setVariables] = (0,
|
|
3957
|
-
(0,
|
|
4097
|
+
const [variables, setVariables] = (0, import_react30.useState)({});
|
|
4098
|
+
(0, import_react30.useEffect)(() => {
|
|
3958
4099
|
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
3959
4100
|
return () => {
|
|
3960
4101
|
unsubscribe();
|
|
@@ -3973,7 +4114,7 @@ function convertToCssVariables(variables) {
|
|
|
3973
4114
|
}
|
|
3974
4115
|
|
|
3975
4116
|
// src/repeater-injections.ts
|
|
3976
|
-
var
|
|
4117
|
+
var import_editor_controls17 = require("@elementor/editor-controls");
|
|
3977
4118
|
var import_editor_props6 = require("@elementor/editor-props");
|
|
3978
4119
|
|
|
3979
4120
|
// src/components/variables-repeater-item-slot.tsx
|
|
@@ -3997,21 +4138,21 @@ var BoxShadowRepeaterColorIndicator = ({ value }) => {
|
|
|
3997
4138
|
|
|
3998
4139
|
// src/repeater-injections.ts
|
|
3999
4140
|
function registerRepeaterInjections() {
|
|
4000
|
-
(0,
|
|
4141
|
+
(0, import_editor_controls17.injectIntoRepeaterItemIcon)({
|
|
4001
4142
|
id: "color-variables-background-icon",
|
|
4002
4143
|
component: BackgroundRepeaterColorIndicator,
|
|
4003
4144
|
condition: ({ value: prop }) => {
|
|
4004
4145
|
return hasAssignedColorVariable(import_editor_props6.backgroundColorOverlayPropTypeUtil.extract(prop)?.color);
|
|
4005
4146
|
}
|
|
4006
4147
|
});
|
|
4007
|
-
(0,
|
|
4148
|
+
(0, import_editor_controls17.injectIntoRepeaterItemIcon)({
|
|
4008
4149
|
id: "color-variables-icon",
|
|
4009
4150
|
component: BoxShadowRepeaterColorIndicator,
|
|
4010
4151
|
condition: ({ value: prop }) => {
|
|
4011
4152
|
return hasAssignedColorVariable(import_editor_props6.shadowPropTypeUtil.extract(prop)?.color);
|
|
4012
4153
|
}
|
|
4013
4154
|
});
|
|
4014
|
-
(0,
|
|
4155
|
+
(0, import_editor_controls17.injectIntoRepeaterItemLabel)({
|
|
4015
4156
|
id: "color-variables-label",
|
|
4016
4157
|
component: BackgroundRepeaterLabel,
|
|
4017
4158
|
condition: ({ value: prop }) => {
|
|
@@ -4028,7 +4169,7 @@ var { registerPopoverAction } = import_menus.controlActionsMenu;
|
|
|
4028
4169
|
function init() {
|
|
4029
4170
|
registerVariableTypes();
|
|
4030
4171
|
registerRepeaterInjections();
|
|
4031
|
-
(0,
|
|
4172
|
+
(0, import_editor_controls18.registerControlReplacement)({
|
|
4032
4173
|
component: VariableControl,
|
|
4033
4174
|
condition: ({ value, placeholder }) => {
|
|
4034
4175
|
if (hasVariableAssigned(value)) {
|
|
@@ -4046,16 +4187,24 @@ function init() {
|
|
|
4046
4187
|
useProps: usePropVariableAction
|
|
4047
4188
|
});
|
|
4048
4189
|
service.init().then(() => {
|
|
4049
|
-
initMcp();
|
|
4190
|
+
initMcp((0, import_editor_mcp.getMCPByDomain)("variables"), (0, import_editor_mcp.getMCPByDomain)("canvas"));
|
|
4050
4191
|
});
|
|
4051
4192
|
(0, import_editor.injectIntoTop)({
|
|
4052
4193
|
id: "canvas-style-variables-render",
|
|
4053
4194
|
component: StyleVariablesRenderer
|
|
4054
4195
|
});
|
|
4196
|
+
(0, import_editor.injectIntoLogic)({
|
|
4197
|
+
id: "variables-import-listener",
|
|
4198
|
+
component: GlobalStylesImportListener
|
|
4199
|
+
});
|
|
4055
4200
|
(0, import_editor.injectIntoLogic)({
|
|
4056
4201
|
id: "variables-open-panel-from-url",
|
|
4057
4202
|
component: OpenPanelFromUrl
|
|
4058
4203
|
});
|
|
4204
|
+
(0, import_editor.injectIntoLogic)({
|
|
4205
|
+
id: "variables-open-panel-from-event",
|
|
4206
|
+
component: OpenPanelFromEvent
|
|
4207
|
+
});
|
|
4059
4208
|
(0, import_editor_panels2.__registerPanel)(panel);
|
|
4060
4209
|
}
|
|
4061
4210
|
function hasVariableAssigned(value) {
|