@elementor/editor-variables 4.0.0-683 → 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 +424 -357
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +331 -264
- 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/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/variables-manager-panel.tsx +30 -13
- package/src/init.ts +8 -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 +3 -8
- package/src/service.ts +5 -5
- package/src/utils/tracking.ts +29 -0
package/dist/index.js
CHANGED
|
@@ -45,181 +45,16 @@ module.exports = __toCommonJS(index_exports);
|
|
|
45
45
|
// src/init.ts
|
|
46
46
|
var import_editor = require("@elementor/editor");
|
|
47
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,17 @@ 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");
|
|
1130
1178
|
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
1131
1179
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
1132
1180
|
var import_ui6 = require("@elementor/ui");
|
|
1133
1181
|
var import_utils = require("@elementor/utils");
|
|
1134
1182
|
var import_i18n7 = require("@wordpress/i18n");
|
|
1135
|
-
var VariablePromotionChip = (0,
|
|
1183
|
+
var VariablePromotionChip = (0, import_react7.forwardRef)(
|
|
1136
1184
|
({ variableType, upgradeUrl, trackingData }, ref) => {
|
|
1137
|
-
const [isOpen, setIsOpen] = (0,
|
|
1185
|
+
const [isOpen, setIsOpen] = (0, import_react7.useState)(false);
|
|
1138
1186
|
(0, import_editor_ui2.useCanvasClickHandler)(isOpen, () => setIsOpen(false));
|
|
1139
|
-
const toggle = (0,
|
|
1187
|
+
const toggle = (0, import_react7.useCallback)(() => {
|
|
1140
1188
|
setIsOpen((prev) => {
|
|
1141
1189
|
if (!prev) {
|
|
1142
1190
|
(0, import_editor_controls2.trackViewPromotion)(trackingData);
|
|
@@ -1144,7 +1192,7 @@ var VariablePromotionChip = (0, import_react6.forwardRef)(
|
|
|
1144
1192
|
return !prev;
|
|
1145
1193
|
});
|
|
1146
1194
|
}, [trackingData]);
|
|
1147
|
-
(0,
|
|
1195
|
+
(0, import_react7.useImperativeHandle)(ref, () => ({ toggle }), [toggle]);
|
|
1148
1196
|
const title = (0, import_i18n7.sprintf)(
|
|
1149
1197
|
/* translators: %s: Variable Type. */
|
|
1150
1198
|
(0, import_i18n7.__)("%s variables", "elementor"),
|
|
@@ -1192,9 +1240,9 @@ var TRACKING_DATA = {
|
|
|
1192
1240
|
};
|
|
1193
1241
|
var SIZE = "tiny";
|
|
1194
1242
|
var VariableManagerCreateMenu = ({ variables, onCreate, menuState }) => {
|
|
1195
|
-
const buttonRef = (0,
|
|
1243
|
+
const buttonRef = (0, import_react8.useRef)(null);
|
|
1196
1244
|
const variableTypes = getVariableTypes();
|
|
1197
|
-
const menuOptionConfigs = (0,
|
|
1245
|
+
const menuOptionConfigs = (0, import_react8.useMemo)(
|
|
1198
1246
|
() => Object.entries(variableTypes).filter(([, variable]) => !!variable.defaultValue).map(([key, variable]) => ({
|
|
1199
1247
|
key,
|
|
1200
1248
|
propTypeKey: variable.propTypeUtil.key,
|
|
@@ -1253,7 +1301,7 @@ var MenuOption = ({
|
|
|
1253
1301
|
onCreate,
|
|
1254
1302
|
onClose
|
|
1255
1303
|
}) => {
|
|
1256
|
-
const promotionRef = (0,
|
|
1304
|
+
const promotionRef = (0, import_react8.useRef)(null);
|
|
1257
1305
|
const userQuotaPermissions = useQuotaPermissions(config.propTypeKey);
|
|
1258
1306
|
const displayName = (0, import_utils2.capitalize)(config.variableType);
|
|
1259
1307
|
const isDisabled = !userQuotaPermissions.canAdd();
|
|
@@ -1267,7 +1315,7 @@ var MenuOption = ({
|
|
|
1267
1315
|
trackVariablesManagerEvent({ action: "add", varType: config.variableType });
|
|
1268
1316
|
onClose();
|
|
1269
1317
|
};
|
|
1270
|
-
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(
|
|
1271
1319
|
VariablePromotionChip,
|
|
1272
1320
|
{
|
|
1273
1321
|
variableType: config.variableType,
|
|
@@ -1295,7 +1343,7 @@ var getDefaultName = (variables, baseName) => {
|
|
|
1295
1343
|
|
|
1296
1344
|
// src/components/variables-manager/variables-manager-table.tsx
|
|
1297
1345
|
var React13 = __toESM(require("react"));
|
|
1298
|
-
var
|
|
1346
|
+
var import_react13 = require("react");
|
|
1299
1347
|
var import_ui13 = require("@elementor/ui");
|
|
1300
1348
|
var import_i18n9 = require("@wordpress/i18n");
|
|
1301
1349
|
|
|
@@ -1325,21 +1373,21 @@ var VariableTableCell = ({
|
|
|
1325
1373
|
|
|
1326
1374
|
// src/components/variables-manager/ui/variable-table-row.tsx
|
|
1327
1375
|
var React12 = __toESM(require("react"));
|
|
1328
|
-
var
|
|
1376
|
+
var import_react12 = require("react");
|
|
1329
1377
|
var import_editor_ui4 = require("@elementor/editor-ui");
|
|
1330
1378
|
var import_icons4 = require("@elementor/icons");
|
|
1331
1379
|
var import_ui12 = require("@elementor/ui");
|
|
1332
1380
|
|
|
1333
1381
|
// src/components/fields/label-field.tsx
|
|
1334
1382
|
var React9 = __toESM(require("react"));
|
|
1335
|
-
var
|
|
1383
|
+
var import_react9 = require("react");
|
|
1336
1384
|
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
1337
1385
|
var import_ui9 = require("@elementor/ui");
|
|
1338
1386
|
function isLabelEqual(a, b) {
|
|
1339
1387
|
return a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
1340
1388
|
}
|
|
1341
1389
|
var useLabelError = (initialError) => {
|
|
1342
|
-
const [error, setError] = (0,
|
|
1390
|
+
const [error, setError] = (0, import_react9.useState)(initialError ?? { value: "", message: "" });
|
|
1343
1391
|
return {
|
|
1344
1392
|
labelFieldError: error,
|
|
1345
1393
|
setLabelFieldError: setError
|
|
@@ -1358,9 +1406,9 @@ var LabelField = ({
|
|
|
1358
1406
|
variables,
|
|
1359
1407
|
onKeyDown
|
|
1360
1408
|
}) => {
|
|
1361
|
-
const [label, setLabel] = (0,
|
|
1362
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
1363
|
-
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);
|
|
1364
1412
|
const handleChange = (newValue) => {
|
|
1365
1413
|
setLabel(newValue);
|
|
1366
1414
|
const errorMsg2 = validateLabel(newValue, variables);
|
|
@@ -1412,7 +1460,7 @@ var LabelField = ({
|
|
|
1412
1460
|
|
|
1413
1461
|
// src/components/variables-manager/variable-editable-cell.tsx
|
|
1414
1462
|
var React10 = __toESM(require("react"));
|
|
1415
|
-
var
|
|
1463
|
+
var import_react10 = require("react");
|
|
1416
1464
|
var import_ui10 = require("@elementor/ui");
|
|
1417
1465
|
var VariableEditableCell = React10.memo(
|
|
1418
1466
|
({
|
|
@@ -1428,22 +1476,22 @@ var VariableEditableCell = React10.memo(
|
|
|
1428
1476
|
fieldType,
|
|
1429
1477
|
disabled = false
|
|
1430
1478
|
}) => {
|
|
1431
|
-
const [value, setValue] = (0,
|
|
1432
|
-
const [isEditing, setIsEditing] = (0,
|
|
1479
|
+
const [value, setValue] = (0, import_react10.useState)(initialValue);
|
|
1480
|
+
const [isEditing, setIsEditing] = (0, import_react10.useState)(false);
|
|
1433
1481
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
1434
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
1435
|
-
const rowRef = (0,
|
|
1436
|
-
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)(() => {
|
|
1437
1485
|
const hasError = fieldType === "label" && labelFieldError?.message || fieldType === "value" && valueFieldError;
|
|
1438
1486
|
if (!hasError) {
|
|
1439
1487
|
onChange(value);
|
|
1440
1488
|
}
|
|
1441
1489
|
setIsEditing(false);
|
|
1442
1490
|
}, [value, onChange, fieldType, labelFieldError, valueFieldError]);
|
|
1443
|
-
(0,
|
|
1491
|
+
(0, import_react10.useEffect)(() => {
|
|
1444
1492
|
onRowRef?.(rowRef?.current);
|
|
1445
1493
|
}, [onRowRef]);
|
|
1446
|
-
(0,
|
|
1494
|
+
(0, import_react10.useEffect)(() => {
|
|
1447
1495
|
if (autoEdit && !isEditing && !disabled) {
|
|
1448
1496
|
setIsEditing(true);
|
|
1449
1497
|
onAutoEditComplete?.();
|
|
@@ -1469,10 +1517,10 @@ var VariableEditableCell = React10.memo(
|
|
|
1469
1517
|
setIsEditing(true);
|
|
1470
1518
|
}
|
|
1471
1519
|
};
|
|
1472
|
-
const handleChange = (0,
|
|
1520
|
+
const handleChange = (0, import_react10.useCallback)((newValue) => {
|
|
1473
1521
|
setValue(newValue);
|
|
1474
1522
|
}, []);
|
|
1475
|
-
const handleValidationChange = (0,
|
|
1523
|
+
const handleValidationChange = (0, import_react10.useCallback)(
|
|
1476
1524
|
(errorMsg) => {
|
|
1477
1525
|
if (fieldType === "label") {
|
|
1478
1526
|
setLabelFieldError({
|
|
@@ -1536,7 +1584,7 @@ var VariableEditableCell = React10.memo(
|
|
|
1536
1584
|
|
|
1537
1585
|
// src/components/variables-manager/ui/variable-edit-menu.tsx
|
|
1538
1586
|
var React11 = __toESM(require("react"));
|
|
1539
|
-
var
|
|
1587
|
+
var import_react11 = require("react");
|
|
1540
1588
|
var import_icons3 = require("@elementor/icons");
|
|
1541
1589
|
var import_ui11 = require("@elementor/ui");
|
|
1542
1590
|
var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
|
|
@@ -1593,7 +1641,7 @@ var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
|
|
|
1593
1641
|
gap: 1
|
|
1594
1642
|
}
|
|
1595
1643
|
},
|
|
1596
|
-
action.icon && (0,
|
|
1644
|
+
action.icon && (0, import_react11.createElement)(action.icon, {
|
|
1597
1645
|
fontSize: "inherit"
|
|
1598
1646
|
}),
|
|
1599
1647
|
" ",
|
|
@@ -1624,7 +1672,7 @@ var VariableRow = (props) => {
|
|
|
1624
1672
|
setTriggerRef,
|
|
1625
1673
|
isSorting
|
|
1626
1674
|
} = props;
|
|
1627
|
-
const promotionRef = (0,
|
|
1675
|
+
const promotionRef = (0, import_react12.useRef)(null);
|
|
1628
1676
|
const isDisabled = !useQuotaPermissions(row.type).canEdit();
|
|
1629
1677
|
const showIndicationBefore = showDropIndication && dropPosition === "before";
|
|
1630
1678
|
const showIndicationAfter = showDropIndication && dropPosition === "after";
|
|
@@ -1682,7 +1730,7 @@ var VariableRow = (props) => {
|
|
|
1682
1730
|
});
|
|
1683
1731
|
}
|
|
1684
1732
|
},
|
|
1685
|
-
prefixElement: (0,
|
|
1733
|
+
prefixElement: (0, import_react12.createElement)(row.icon, {
|
|
1686
1734
|
fontSize: "inherit",
|
|
1687
1735
|
color: isDisabled ? "disabled" : "inherit"
|
|
1688
1736
|
}),
|
|
@@ -1782,9 +1830,9 @@ var VariablesManagerTable = ({
|
|
|
1782
1830
|
onAutoEditComplete,
|
|
1783
1831
|
onFieldError
|
|
1784
1832
|
}) => {
|
|
1785
|
-
const tableContainerRef = (0,
|
|
1786
|
-
const variableRowRefs = (0,
|
|
1787
|
-
(0,
|
|
1833
|
+
const tableContainerRef = (0, import_react13.useRef)(null);
|
|
1834
|
+
const variableRowRefs = (0, import_react13.useRef)(/* @__PURE__ */ new Map());
|
|
1835
|
+
(0, import_react13.useEffect)(() => {
|
|
1788
1836
|
if (autoEditVariableId && tableContainerRef.current) {
|
|
1789
1837
|
const rowElement = variableRowRefs.current.get(autoEditVariableId);
|
|
1790
1838
|
if (rowElement) {
|
|
@@ -1905,8 +1953,8 @@ function VariablesManagerPanel() {
|
|
|
1905
1953
|
handleOnChange,
|
|
1906
1954
|
createVariable: createVariable2,
|
|
1907
1955
|
handleDeleteVariable,
|
|
1908
|
-
handleStartSync,
|
|
1909
|
-
handleStopSync,
|
|
1956
|
+
handleStartSync: startSyncFromState,
|
|
1957
|
+
handleStopSync: stopSyncFromState,
|
|
1910
1958
|
handleSave,
|
|
1911
1959
|
isSaving,
|
|
1912
1960
|
handleSearch,
|
|
@@ -1915,9 +1963,9 @@ function VariablesManagerPanel() {
|
|
|
1915
1963
|
} = useVariablesManagerState();
|
|
1916
1964
|
const { autoEditVariableId, startAutoEdit, handleAutoEditComplete } = useAutoEdit();
|
|
1917
1965
|
const { createNavigationCallback, resetNavigation } = useErrorNavigation();
|
|
1918
|
-
const [deleteConfirmation, setDeleteConfirmation] = (0,
|
|
1919
|
-
const [stopSyncConfirmation, setStopSyncConfirmation] = (0,
|
|
1920
|
-
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);
|
|
1921
1969
|
usePreventUnload(isDirty);
|
|
1922
1970
|
const handleClosePanel = () => {
|
|
1923
1971
|
if (isDirty) {
|
|
@@ -1926,7 +1974,7 @@ function VariablesManagerPanel() {
|
|
|
1926
1974
|
}
|
|
1927
1975
|
closePanel();
|
|
1928
1976
|
};
|
|
1929
|
-
const handleCreateVariable = (0,
|
|
1977
|
+
const handleCreateVariable = (0, import_react14.useCallback)(
|
|
1930
1978
|
(type, defaultName, defaultValue) => {
|
|
1931
1979
|
const newId = createVariable2(type, defaultName, defaultValue);
|
|
1932
1980
|
if (newId) {
|
|
@@ -1960,31 +2008,44 @@ function VariablesManagerPanel() {
|
|
|
1960
2008
|
setIsSaving(false);
|
|
1961
2009
|
}
|
|
1962
2010
|
};
|
|
1963
|
-
const handleDeleteVariableWithConfirmation = (0,
|
|
2011
|
+
const handleDeleteVariableWithConfirmation = (0, import_react14.useCallback)(
|
|
1964
2012
|
(itemId) => {
|
|
1965
2013
|
handleDeleteVariable(itemId);
|
|
1966
2014
|
setDeleteConfirmation(null);
|
|
1967
2015
|
},
|
|
1968
2016
|
[handleDeleteVariable]
|
|
1969
2017
|
);
|
|
1970
|
-
const
|
|
2018
|
+
const commitStopSync = (0, import_react14.useCallback)(
|
|
1971
2019
|
(itemId) => {
|
|
1972
|
-
|
|
1973
|
-
|
|
2020
|
+
stopSyncFromState(itemId);
|
|
2021
|
+
const variable = variables[itemId];
|
|
2022
|
+
if (variable) {
|
|
2023
|
+
trackVariableSyncToV3({ variableLabel: variable.label, action: "unsync" });
|
|
2024
|
+
}
|
|
1974
2025
|
},
|
|
1975
|
-
[
|
|
2026
|
+
[stopSyncFromState, variables]
|
|
1976
2027
|
);
|
|
1977
|
-
const
|
|
2028
|
+
const handleStartSync = (0, import_react14.useCallback)(
|
|
2029
|
+
(itemId) => {
|
|
2030
|
+
startSyncFromState(itemId);
|
|
2031
|
+
const variable = variables[itemId];
|
|
2032
|
+
if (variable) {
|
|
2033
|
+
trackVariableSyncToV3({ variableLabel: variable.label, action: "sync" });
|
|
2034
|
+
}
|
|
2035
|
+
},
|
|
2036
|
+
[startSyncFromState, variables]
|
|
2037
|
+
);
|
|
2038
|
+
const handleStopSync = (0, import_react14.useCallback)(
|
|
1978
2039
|
(itemId) => {
|
|
1979
2040
|
if (!isStopSyncSuppressed) {
|
|
1980
2041
|
setStopSyncConfirmation(itemId);
|
|
1981
2042
|
} else {
|
|
1982
|
-
|
|
2043
|
+
commitStopSync(itemId);
|
|
1983
2044
|
}
|
|
1984
2045
|
},
|
|
1985
|
-
[isStopSyncSuppressed,
|
|
2046
|
+
[isStopSyncSuppressed, commitStopSync]
|
|
1986
2047
|
);
|
|
1987
|
-
const buildMenuActions = (0,
|
|
2048
|
+
const buildMenuActions = (0, import_react14.useCallback)(
|
|
1988
2049
|
(variableId) => {
|
|
1989
2050
|
const variable = variables[variableId];
|
|
1990
2051
|
if (!variable) {
|
|
@@ -1995,7 +2056,7 @@ function VariablesManagerPanel() {
|
|
|
1995
2056
|
variableId,
|
|
1996
2057
|
handlers: {
|
|
1997
2058
|
onStartSync: handleStartSync,
|
|
1998
|
-
onStopSync:
|
|
2059
|
+
onStopSync: handleStopSync
|
|
1999
2060
|
}
|
|
2000
2061
|
});
|
|
2001
2062
|
const deleteAction = {
|
|
@@ -2013,7 +2074,7 @@ function VariablesManagerPanel() {
|
|
|
2013
2074
|
};
|
|
2014
2075
|
return [...typeActions, deleteAction];
|
|
2015
2076
|
},
|
|
2016
|
-
[variables, handleStartSync,
|
|
2077
|
+
[variables, handleStartSync, handleStopSync]
|
|
2017
2078
|
);
|
|
2018
2079
|
const hasVariables = Object.keys(variables).length > 0;
|
|
2019
2080
|
return /* @__PURE__ */ React14.createElement(import_editor_ui5.ThemeProvider, null, /* @__PURE__ */ React14.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React14.createElement(
|
|
@@ -2148,7 +2209,10 @@ function VariablesManagerPanel() {
|
|
|
2148
2209
|
{
|
|
2149
2210
|
open: true,
|
|
2150
2211
|
onClose: () => setStopSyncConfirmation(null),
|
|
2151
|
-
onConfirm: () =>
|
|
2212
|
+
onConfirm: () => {
|
|
2213
|
+
commitStopSync(stopSyncConfirmation);
|
|
2214
|
+
setStopSyncConfirmation(null);
|
|
2215
|
+
}
|
|
2152
2216
|
}
|
|
2153
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(
|
|
2154
2218
|
import_editor_ui5.SaveChangesDialog.Actions,
|
|
@@ -2176,7 +2240,7 @@ function VariablesManagerPanel() {
|
|
|
2176
2240
|
)));
|
|
2177
2241
|
}
|
|
2178
2242
|
var usePreventUnload = (isDirty) => {
|
|
2179
|
-
(0,
|
|
2243
|
+
(0, import_react14.useEffect)(() => {
|
|
2180
2244
|
const handleBeforeUnload = (event) => {
|
|
2181
2245
|
if (isDirty) {
|
|
2182
2246
|
event.preventDefault();
|
|
@@ -2212,15 +2276,15 @@ var EVENT_NAME = "elementor/open-variables-manager";
|
|
|
2212
2276
|
var DEFAULT_PANEL_ROUTE = "panel/elements/categories";
|
|
2213
2277
|
function OpenPanelFromEvent() {
|
|
2214
2278
|
const { open } = usePanelActions();
|
|
2215
|
-
const pendingRef = (0,
|
|
2216
|
-
const [readyToOpen, setReadyToOpen] = (0,
|
|
2217
|
-
(0,
|
|
2279
|
+
const pendingRef = (0, import_react15.useRef)(false);
|
|
2280
|
+
const [readyToOpen, setReadyToOpen] = (0, import_react15.useState)(false);
|
|
2281
|
+
(0, import_react15.useEffect)(() => {
|
|
2218
2282
|
if (readyToOpen) {
|
|
2219
2283
|
setReadyToOpen(false);
|
|
2220
2284
|
open();
|
|
2221
2285
|
}
|
|
2222
2286
|
}, [readyToOpen, open]);
|
|
2223
|
-
(0,
|
|
2287
|
+
(0, import_react15.useEffect)(() => {
|
|
2224
2288
|
return (0, import_editor_v1_adapters3.__privateListenTo)((0, import_editor_v1_adapters3.routeOpenEvent)(DEFAULT_PANEL_ROUTE), () => {
|
|
2225
2289
|
if (pendingRef.current) {
|
|
2226
2290
|
pendingRef.current = false;
|
|
@@ -2228,7 +2292,7 @@ function OpenPanelFromEvent() {
|
|
|
2228
2292
|
}
|
|
2229
2293
|
});
|
|
2230
2294
|
}, []);
|
|
2231
|
-
(0,
|
|
2295
|
+
(0, import_react15.useEffect)(() => {
|
|
2232
2296
|
const handler = () => {
|
|
2233
2297
|
pendingRef.current = true;
|
|
2234
2298
|
(0, import_editor_v1_adapters3.__privateOpenRoute)(DEFAULT_PANEL_ROUTE);
|
|
@@ -2240,15 +2304,15 @@ function OpenPanelFromEvent() {
|
|
|
2240
2304
|
}
|
|
2241
2305
|
|
|
2242
2306
|
// src/components/open-panel-from-url.tsx
|
|
2243
|
-
var
|
|
2307
|
+
var import_react16 = require("react");
|
|
2244
2308
|
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
2245
2309
|
var ACTIVE_PANEL_PARAM = "active-panel";
|
|
2246
2310
|
var PANEL_ID = "variables-manager";
|
|
2247
2311
|
var DEFAULT_PANEL_ROUTE2 = "panel/elements";
|
|
2248
2312
|
function OpenPanelFromUrl() {
|
|
2249
2313
|
const { open } = usePanelActions();
|
|
2250
|
-
const hasOpened = (0,
|
|
2251
|
-
(0,
|
|
2314
|
+
const hasOpened = (0, import_react16.useRef)(false);
|
|
2315
|
+
(0, import_react16.useEffect)(() => {
|
|
2252
2316
|
const urlParams = new URLSearchParams(window.location.search);
|
|
2253
2317
|
const activePanel = urlParams.get(ACTIVE_PANEL_PARAM);
|
|
2254
2318
|
if (activePanel !== PANEL_ID) {
|
|
@@ -2273,7 +2337,7 @@ var React33 = __toESM(require("react"));
|
|
|
2273
2337
|
var import_editor_controls13 = require("@elementor/editor-controls");
|
|
2274
2338
|
|
|
2275
2339
|
// src/components/ui/variable/assigned-variable.tsx
|
|
2276
|
-
var
|
|
2340
|
+
var import_react23 = require("react");
|
|
2277
2341
|
var React24 = __toESM(require("react"));
|
|
2278
2342
|
var import_editor_controls8 = require("@elementor/editor-controls");
|
|
2279
2343
|
var import_icons12 = require("@elementor/icons");
|
|
@@ -2297,25 +2361,25 @@ function createUnlinkHandler(variable, propTypeKey, setValue) {
|
|
|
2297
2361
|
|
|
2298
2362
|
// src/components/variable-selection-popover.tsx
|
|
2299
2363
|
var React22 = __toESM(require("react"));
|
|
2300
|
-
var
|
|
2364
|
+
var import_react22 = require("react");
|
|
2301
2365
|
var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
|
|
2302
2366
|
|
|
2303
2367
|
// src/context/variable-selection-popover.context.tsx
|
|
2304
2368
|
var React15 = __toESM(require("react"));
|
|
2305
|
-
var
|
|
2369
|
+
var import_react17 = require("react");
|
|
2306
2370
|
var import_ui15 = require("@elementor/ui");
|
|
2307
|
-
var PopoverContentRefContext = (0,
|
|
2371
|
+
var PopoverContentRefContext = (0, import_react17.createContext)(null);
|
|
2308
2372
|
var PopoverContentRefContextProvider = ({ children }) => {
|
|
2309
|
-
const [anchorRef, setAnchorRef] = (0,
|
|
2373
|
+
const [anchorRef, setAnchorRef] = (0, import_react17.useState)(null);
|
|
2310
2374
|
return /* @__PURE__ */ React15.createElement(PopoverContentRefContext.Provider, { value: anchorRef }, /* @__PURE__ */ React15.createElement(import_ui15.Box, { ref: setAnchorRef }, children));
|
|
2311
2375
|
};
|
|
2312
2376
|
var usePopoverContentRef = () => {
|
|
2313
|
-
return (0,
|
|
2377
|
+
return (0, import_react17.useContext)(PopoverContentRefContext);
|
|
2314
2378
|
};
|
|
2315
2379
|
|
|
2316
2380
|
// src/components/variable-creation.tsx
|
|
2317
2381
|
var React17 = __toESM(require("react"));
|
|
2318
|
-
var
|
|
2382
|
+
var import_react18 = require("react");
|
|
2319
2383
|
var import_editor_controls5 = require("@elementor/editor-controls");
|
|
2320
2384
|
var import_editor_ui6 = require("@elementor/editor-ui");
|
|
2321
2385
|
var import_icons6 = require("@elementor/icons");
|
|
@@ -2376,11 +2440,11 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2376
2440
|
const { setVariableValue: setVariable, path } = useVariableBoundProp();
|
|
2377
2441
|
const { propType } = (0, import_editor_controls5.useBoundProp)();
|
|
2378
2442
|
const initialValue = useInitialValue();
|
|
2379
|
-
const [value, setValue] = (0,
|
|
2380
|
-
const [label, setLabel] = (0,
|
|
2381
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
2382
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
2383
|
-
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);
|
|
2384
2448
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
2385
2449
|
const resetFields = () => {
|
|
2386
2450
|
setValue("");
|
|
@@ -2464,11 +2528,12 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2464
2528
|
},
|
|
2465
2529
|
onErrorChange: (errorMsg) => {
|
|
2466
2530
|
setLabelFieldError({
|
|
2467
|
-
value:
|
|
2531
|
+
value: "",
|
|
2468
2532
|
message: errorMsg
|
|
2469
2533
|
});
|
|
2470
2534
|
},
|
|
2471
|
-
onKeyDown: handleKeyDown
|
|
2535
|
+
onKeyDown: handleKeyDown,
|
|
2536
|
+
focusOnShow: true
|
|
2472
2537
|
}
|
|
2473
2538
|
)
|
|
2474
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(
|
|
@@ -2500,7 +2565,7 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2500
2565
|
|
|
2501
2566
|
// src/components/variable-edit.tsx
|
|
2502
2567
|
var React19 = __toESM(require("react"));
|
|
2503
|
-
var
|
|
2568
|
+
var import_react20 = require("react");
|
|
2504
2569
|
var import_editor_controls6 = require("@elementor/editor-controls");
|
|
2505
2570
|
var import_editor_current_user3 = require("@elementor/editor-current-user");
|
|
2506
2571
|
var import_editor_ui7 = require("@elementor/editor-ui");
|
|
@@ -2510,7 +2575,7 @@ var import_i18n13 = require("@wordpress/i18n");
|
|
|
2510
2575
|
|
|
2511
2576
|
// src/components/ui/edit-confirmation-dialog.tsx
|
|
2512
2577
|
var React18 = __toESM(require("react"));
|
|
2513
|
-
var
|
|
2578
|
+
var import_react19 = require("react");
|
|
2514
2579
|
var import_icons7 = require("@elementor/icons");
|
|
2515
2580
|
var import_ui18 = require("@elementor/ui");
|
|
2516
2581
|
var import_i18n12 = require("@wordpress/i18n");
|
|
@@ -2520,7 +2585,7 @@ var EditConfirmationDialog = ({
|
|
|
2520
2585
|
onConfirm,
|
|
2521
2586
|
onSuppressMessage
|
|
2522
2587
|
}) => {
|
|
2523
|
-
const [dontShowAgain, setDontShowAgain] = (0,
|
|
2588
|
+
const [dontShowAgain, setDontShowAgain] = (0, import_react19.useState)(false);
|
|
2524
2589
|
const handleSave = () => {
|
|
2525
2590
|
if (dontShowAgain) {
|
|
2526
2591
|
onSuppressMessage?.();
|
|
@@ -2554,20 +2619,20 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2554
2619
|
const { setVariableValue: notifyBoundPropChange, variableId } = useVariableBoundProp();
|
|
2555
2620
|
const { propType } = (0, import_editor_controls6.useBoundProp)();
|
|
2556
2621
|
const [isMessageSuppressed, suppressMessage] = (0, import_editor_current_user3.useSuppressedMessage)(EDIT_CONFIRMATION_DIALOG_ID);
|
|
2557
|
-
const [deleteConfirmation, setDeleteConfirmation] = (0,
|
|
2558
|
-
const [editConfirmation, setEditConfirmation] = (0,
|
|
2559
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
2560
|
-
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)("");
|
|
2561
2626
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
2562
2627
|
const variable = useVariable(editId);
|
|
2563
|
-
const [propTypeKey, setPropTypeKey] = (0,
|
|
2628
|
+
const [propTypeKey, setPropTypeKey] = (0, import_react20.useState)(variable?.type ?? propTypeUtil.key);
|
|
2564
2629
|
if (!variable) {
|
|
2565
2630
|
throw new Error(`Global ${variableType} variable not found`);
|
|
2566
2631
|
}
|
|
2567
2632
|
const userPermissions = usePermissions();
|
|
2568
|
-
const [value, setValue] = (0,
|
|
2569
|
-
const [label, setLabel] = (0,
|
|
2570
|
-
(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)(() => {
|
|
2571
2636
|
styleVariablesRepository.update({
|
|
2572
2637
|
[editId]: {
|
|
2573
2638
|
...variable,
|
|
@@ -2690,11 +2755,12 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2690
2755
|
},
|
|
2691
2756
|
onErrorChange: (errorMsg) => {
|
|
2692
2757
|
setLabelFieldError({
|
|
2693
|
-
value:
|
|
2758
|
+
value: "",
|
|
2694
2759
|
message: errorMsg
|
|
2695
2760
|
});
|
|
2696
2761
|
},
|
|
2697
|
-
onKeyDown: handleKeyDown
|
|
2762
|
+
onKeyDown: handleKeyDown,
|
|
2763
|
+
focusOnShow: true
|
|
2698
2764
|
}
|
|
2699
2765
|
)
|
|
2700
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(
|
|
@@ -2731,7 +2797,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2731
2797
|
};
|
|
2732
2798
|
|
|
2733
2799
|
// src/components/variables-selection.tsx
|
|
2734
|
-
var
|
|
2800
|
+
var import_react21 = require("react");
|
|
2735
2801
|
var React21 = __toESM(require("react"));
|
|
2736
2802
|
var import_editor_controls7 = require("@elementor/editor-controls");
|
|
2737
2803
|
var import_editor_ui9 = require("@elementor/editor-ui");
|
|
@@ -2839,7 +2905,7 @@ var getProUpgradeUrl = (variableType) => `https://go.elementor.com/renew-license
|
|
|
2839
2905
|
var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled = false }) => {
|
|
2840
2906
|
const { icon: VariableIcon, startIcon, variableType, propTypeUtil, emptyState } = useVariableType();
|
|
2841
2907
|
const { value: variable, setValue: setVariable, path } = useVariableBoundProp();
|
|
2842
|
-
const [searchValue, setSearchValue] = (0,
|
|
2908
|
+
const [searchValue, setSearchValue] = (0, import_react21.useState)("");
|
|
2843
2909
|
const {
|
|
2844
2910
|
list: variables,
|
|
2845
2911
|
hasMatches: hasSearchResults,
|
|
@@ -2916,7 +2982,7 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled =
|
|
|
2916
2982
|
const handleClearSearch = () => {
|
|
2917
2983
|
setSearchValue("");
|
|
2918
2984
|
};
|
|
2919
|
-
(0,
|
|
2985
|
+
(0, import_react21.useEffect)(() => {
|
|
2920
2986
|
if (disabled) {
|
|
2921
2987
|
(0, import_editor_controls7.trackViewPromotion)({
|
|
2922
2988
|
target_name: "variables_popover",
|
|
@@ -3024,8 +3090,8 @@ var VIEW_LIST = "list";
|
|
|
3024
3090
|
var VIEW_ADD = "add";
|
|
3025
3091
|
var VIEW_EDIT = "edit";
|
|
3026
3092
|
var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
|
|
3027
|
-
const [currentView, setCurrentView] = (0,
|
|
3028
|
-
const [editId, setEditId] = (0,
|
|
3093
|
+
const [currentView, setCurrentView] = (0, import_react22.useState)(VIEW_LIST);
|
|
3094
|
+
const [editId, setEditId] = (0, import_react22.useState)("");
|
|
3029
3095
|
const { open } = usePanelActions();
|
|
3030
3096
|
const onSettingsAvailable = (0, import_editor_v1_adapters5.isExperimentActive)("e_variables_manager") ? () => {
|
|
3031
3097
|
open();
|
|
@@ -3136,8 +3202,8 @@ var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
|
|
|
3136
3202
|
var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
3137
3203
|
const { startIcon, propTypeUtil } = getVariableType(propTypeKey);
|
|
3138
3204
|
const { setValue } = (0, import_editor_controls8.useBoundProp)();
|
|
3139
|
-
const anchorRef = (0,
|
|
3140
|
-
const popupId = (0,
|
|
3205
|
+
const anchorRef = (0, import_react23.useRef)(null);
|
|
3206
|
+
const popupId = (0, import_react23.useId)();
|
|
3141
3207
|
const popupState = (0, import_ui24.usePopupState)({
|
|
3142
3208
|
variant: "popover",
|
|
3143
3209
|
popupId: `elementor-variables-list-${popupId}`
|
|
@@ -3177,14 +3243,14 @@ var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
|
3177
3243
|
|
|
3178
3244
|
// src/components/ui/variable/deleted-variable.tsx
|
|
3179
3245
|
var React28 = __toESM(require("react"));
|
|
3180
|
-
var
|
|
3246
|
+
var import_react25 = require("react");
|
|
3181
3247
|
var import_editor_controls10 = require("@elementor/editor-controls");
|
|
3182
3248
|
var import_ui28 = require("@elementor/ui");
|
|
3183
3249
|
var import_i18n19 = require("@wordpress/i18n");
|
|
3184
3250
|
|
|
3185
3251
|
// src/components/variable-restore.tsx
|
|
3186
3252
|
var React25 = __toESM(require("react"));
|
|
3187
|
-
var
|
|
3253
|
+
var import_react24 = require("react");
|
|
3188
3254
|
var import_editor_controls9 = require("@elementor/editor-controls");
|
|
3189
3255
|
var import_editor_ui11 = require("@elementor/editor-ui");
|
|
3190
3256
|
var import_ui25 = require("@elementor/ui");
|
|
@@ -3198,11 +3264,11 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
3198
3264
|
if (!variable) {
|
|
3199
3265
|
throw new Error(`Global ${variableType} variable not found`);
|
|
3200
3266
|
}
|
|
3201
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
3202
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
3203
|
-
const [label, setLabel] = (0,
|
|
3204
|
-
const [value, setValue] = (0,
|
|
3205
|
-
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);
|
|
3206
3272
|
const { labelFieldError, setLabelFieldError } = useLabelError({
|
|
3207
3273
|
value: variable.label,
|
|
3208
3274
|
message: ERROR_MESSAGES.DUPLICATED_LABEL
|
|
@@ -3275,11 +3341,12 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
3275
3341
|
},
|
|
3276
3342
|
onErrorChange: (errorMsg) => {
|
|
3277
3343
|
setLabelFieldError({
|
|
3278
|
-
value:
|
|
3344
|
+
value: "",
|
|
3279
3345
|
message: errorMsg
|
|
3280
3346
|
});
|
|
3281
3347
|
},
|
|
3282
|
-
onKeyDown: handleKeyDown
|
|
3348
|
+
onKeyDown: handleKeyDown,
|
|
3349
|
+
focusOnShow: true
|
|
3283
3350
|
}
|
|
3284
3351
|
)
|
|
3285
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(
|
|
@@ -3358,11 +3425,11 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
3358
3425
|
const { propTypeUtil } = getVariableType(propTypeKey);
|
|
3359
3426
|
const boundProp = (0, import_editor_controls10.useBoundProp)();
|
|
3360
3427
|
const userPermissions = usePermissions();
|
|
3361
|
-
const [showInfotip, setShowInfotip] = (0,
|
|
3428
|
+
const [showInfotip, setShowInfotip] = (0, import_react25.useState)(false);
|
|
3362
3429
|
const toggleInfotip = () => setShowInfotip((prev) => !prev);
|
|
3363
3430
|
const closeInfotip = () => setShowInfotip(false);
|
|
3364
|
-
const deletedChipAnchorRef = (0,
|
|
3365
|
-
const popupId = (0,
|
|
3431
|
+
const deletedChipAnchorRef = (0, import_react25.useRef)(null);
|
|
3432
|
+
const popupId = (0, import_react25.useId)();
|
|
3366
3433
|
const popupState = (0, import_ui28.usePopupState)({
|
|
3367
3434
|
variant: "popover",
|
|
3368
3435
|
popupId: `elementor-variables-restore-${popupId}`
|
|
@@ -3449,7 +3516,7 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
3449
3516
|
|
|
3450
3517
|
// src/components/ui/variable/mismatch-variable.tsx
|
|
3451
3518
|
var React30 = __toESM(require("react"));
|
|
3452
|
-
var
|
|
3519
|
+
var import_react26 = require("react");
|
|
3453
3520
|
var import_editor_controls11 = require("@elementor/editor-controls");
|
|
3454
3521
|
var import_ui30 = require("@elementor/ui");
|
|
3455
3522
|
var import_i18n21 = require("@wordpress/i18n");
|
|
@@ -3487,13 +3554,13 @@ var MismatchVariableAlert = ({ onClose, onClear, triggerSelect }) => {
|
|
|
3487
3554
|
// src/components/ui/variable/mismatch-variable.tsx
|
|
3488
3555
|
var MismatchVariable = ({ variable }) => {
|
|
3489
3556
|
const { setValue, value } = (0, import_editor_controls11.useBoundProp)();
|
|
3490
|
-
const anchorRef = (0,
|
|
3491
|
-
const popupId = (0,
|
|
3557
|
+
const anchorRef = (0, import_react26.useRef)(null);
|
|
3558
|
+
const popupId = (0, import_react26.useId)();
|
|
3492
3559
|
const popupState = (0, import_ui30.usePopupState)({
|
|
3493
3560
|
variant: "popover",
|
|
3494
3561
|
popupId: `elementor-variables-list-${popupId}`
|
|
3495
3562
|
});
|
|
3496
|
-
const [infotipVisible, setInfotipVisible] = (0,
|
|
3563
|
+
const [infotipVisible, setInfotipVisible] = (0, import_react26.useState)(false);
|
|
3497
3564
|
const toggleInfotip = () => setInfotipVisible((prev) => !prev);
|
|
3498
3565
|
const closeInfotip = () => setInfotipVisible(false);
|
|
3499
3566
|
const triggerSelect = () => {
|
|
@@ -3566,7 +3633,7 @@ var MismatchVariable = ({ variable }) => {
|
|
|
3566
3633
|
|
|
3567
3634
|
// src/components/ui/variable/missing-variable.tsx
|
|
3568
3635
|
var React32 = __toESM(require("react"));
|
|
3569
|
-
var
|
|
3636
|
+
var import_react27 = require("react");
|
|
3570
3637
|
var import_editor_controls12 = require("@elementor/editor-controls");
|
|
3571
3638
|
var import_ui32 = require("@elementor/ui");
|
|
3572
3639
|
var import_i18n23 = require("@wordpress/i18n");
|
|
@@ -3596,7 +3663,7 @@ var MissingVariableAlert = ({ onClose, onClear }) => {
|
|
|
3596
3663
|
// src/components/ui/variable/missing-variable.tsx
|
|
3597
3664
|
var MissingVariable = () => {
|
|
3598
3665
|
const { setValue } = (0, import_editor_controls12.useBoundProp)();
|
|
3599
|
-
const [infotipVisible, setInfotipVisible] = (0,
|
|
3666
|
+
const [infotipVisible, setInfotipVisible] = (0, import_react27.useState)(false);
|
|
3600
3667
|
const toggleInfotip = () => setInfotipVisible((prev) => !prev);
|
|
3601
3668
|
const closeInfotip = () => setInfotipVisible(false);
|
|
3602
3669
|
const clearValue = () => setValue(null);
|
|
@@ -3684,22 +3751,15 @@ var trackOpenVariablePopover = (path, variableType) => {
|
|
|
3684
3751
|
});
|
|
3685
3752
|
};
|
|
3686
3753
|
|
|
3687
|
-
// src/mcp/index.ts
|
|
3688
|
-
var import_editor_mcp3 = require("@elementor/editor-mcp");
|
|
3689
|
-
|
|
3690
3754
|
// src/mcp/manage-variable-tool.ts
|
|
3691
|
-
var import_editor_mcp2 = require("@elementor/editor-mcp");
|
|
3692
3755
|
var import_schema3 = require("@elementor/schema");
|
|
3693
3756
|
|
|
3694
3757
|
// src/mcp/variables-resource.ts
|
|
3695
|
-
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
3696
3758
|
var GLOBAL_VARIABLES_URI = "elementor://global-variables";
|
|
3697
|
-
var initVariablesResource = () => {
|
|
3698
|
-
const canvasMcpEntry = (0, import_editor_mcp.getMCPByDomain)("canvas");
|
|
3699
|
-
const variablesMcpEntry = (0, import_editor_mcp.getMCPByDomain)("variables");
|
|
3759
|
+
var initVariablesResource = (variablesMcpEntry, canvasMcpEntry) => {
|
|
3700
3760
|
[canvasMcpEntry, variablesMcpEntry].forEach((entry) => {
|
|
3701
|
-
const {
|
|
3702
|
-
|
|
3761
|
+
const { resource, sendResourceUpdated } = entry;
|
|
3762
|
+
resource(
|
|
3703
3763
|
"global-variables",
|
|
3704
3764
|
GLOBAL_VARIABLES_URI,
|
|
3705
3765
|
{
|
|
@@ -3718,7 +3778,7 @@ var initVariablesResource = () => {
|
|
|
3718
3778
|
}
|
|
3719
3779
|
);
|
|
3720
3780
|
window.addEventListener("variables:updated", () => {
|
|
3721
|
-
|
|
3781
|
+
sendResourceUpdated({
|
|
3722
3782
|
uri: GLOBAL_VARIABLES_URI
|
|
3723
3783
|
});
|
|
3724
3784
|
});
|
|
@@ -3726,8 +3786,9 @@ var initVariablesResource = () => {
|
|
|
3726
3786
|
};
|
|
3727
3787
|
|
|
3728
3788
|
// src/mcp/manage-variable-tool.ts
|
|
3729
|
-
var initManageVariableTool = () => {
|
|
3730
|
-
|
|
3789
|
+
var initManageVariableTool = (reg) => {
|
|
3790
|
+
const { addTool } = reg;
|
|
3791
|
+
addTool({
|
|
3731
3792
|
name: "manage-global-variable",
|
|
3732
3793
|
schema: {
|
|
3733
3794
|
action: import_schema3.z.enum(["create", "update", "delete"]).describe("Operation to perform"),
|
|
@@ -3797,12 +3858,18 @@ function getServiceActions(svc) {
|
|
|
3797
3858
|
}
|
|
3798
3859
|
|
|
3799
3860
|
// src/mcp/index.ts
|
|
3800
|
-
function initMcp() {
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
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);
|
|
3806
3873
|
}
|
|
3807
3874
|
|
|
3808
3875
|
// src/register-variable-types.tsx
|
|
@@ -3810,18 +3877,17 @@ var React37 = __toESM(require("react"));
|
|
|
3810
3877
|
var import_editor_controls16 = require("@elementor/editor-controls");
|
|
3811
3878
|
var import_editor_props5 = require("@elementor/editor-props");
|
|
3812
3879
|
var import_editor_ui13 = require("@elementor/editor-ui");
|
|
3813
|
-
var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
|
|
3814
3880
|
var import_icons16 = require("@elementor/icons");
|
|
3815
3881
|
var import_i18n26 = require("@wordpress/i18n");
|
|
3816
3882
|
|
|
3817
3883
|
// src/components/fields/color-field.tsx
|
|
3818
3884
|
var React35 = __toESM(require("react"));
|
|
3819
|
-
var
|
|
3885
|
+
var import_react28 = require("react");
|
|
3820
3886
|
var import_ui33 = require("@elementor/ui");
|
|
3821
3887
|
var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
3822
|
-
const [color, setColor] = (0,
|
|
3823
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
3824
|
-
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);
|
|
3825
3891
|
const anchorRef = usePopoverContentRef() ?? defaultRef.current;
|
|
3826
3892
|
const handleChange = (newValue) => {
|
|
3827
3893
|
setColor(newValue);
|
|
@@ -3860,15 +3926,15 @@ var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
|
3860
3926
|
|
|
3861
3927
|
// src/components/fields/font-field.tsx
|
|
3862
3928
|
var React36 = __toESM(require("react"));
|
|
3863
|
-
var
|
|
3929
|
+
var import_react29 = require("react");
|
|
3864
3930
|
var import_editor_controls15 = require("@elementor/editor-controls");
|
|
3865
3931
|
var import_editor_ui12 = require("@elementor/editor-ui");
|
|
3866
3932
|
var import_icons15 = require("@elementor/icons");
|
|
3867
3933
|
var import_ui34 = require("@elementor/ui");
|
|
3868
3934
|
var import_i18n25 = require("@wordpress/i18n");
|
|
3869
3935
|
var FontField = ({ value, onChange, onValidationChange }) => {
|
|
3870
|
-
const [fontFamily, setFontFamily] = (0,
|
|
3871
|
-
const defaultRef = (0,
|
|
3936
|
+
const [fontFamily, setFontFamily] = (0, import_react29.useState)(value);
|
|
3937
|
+
const defaultRef = (0, import_react29.useRef)(null);
|
|
3872
3938
|
const anchorRef = usePopoverContentRef() ?? defaultRef.current;
|
|
3873
3939
|
const fontPopoverState = (0, import_ui34.usePopupState)({ variant: "popover" });
|
|
3874
3940
|
const fontFamilies = (0, import_editor_controls15.useFontFamilies)();
|
|
@@ -3889,7 +3955,7 @@ var FontField = ({ value, onChange, onValidationChange }) => {
|
|
|
3889
3955
|
handleChange(newFontFamily);
|
|
3890
3956
|
fontPopoverState.close();
|
|
3891
3957
|
};
|
|
3892
|
-
const id2 = (0,
|
|
3958
|
+
const id2 = (0, import_react29.useId)();
|
|
3893
3959
|
return /* @__PURE__ */ React36.createElement(React36.Fragment, null, /* @__PURE__ */ React36.createElement(
|
|
3894
3960
|
import_ui34.UnstableTag,
|
|
3895
3961
|
{
|
|
@@ -3952,20 +4018,17 @@ function registerVariableTypes() {
|
|
|
3952
4018
|
defaultValue: "#ffffff",
|
|
3953
4019
|
menuActionsFactory: ({ variable, variableId, handlers }) => {
|
|
3954
4020
|
const actions = [];
|
|
3955
|
-
if (!(0, import_editor_v1_adapters6.isExperimentActive)("e_design_system_sync")) {
|
|
3956
|
-
return [];
|
|
3957
|
-
}
|
|
3958
4021
|
if (variable.sync_to_v3) {
|
|
3959
4022
|
actions.push({
|
|
3960
4023
|
name: (0, import_i18n26.__)("Stop syncing to Global Colors", "elementor"),
|
|
3961
|
-
icon: import_icons16.
|
|
4024
|
+
icon: import_icons16.RefreshOffIcon,
|
|
3962
4025
|
color: "text.primary",
|
|
3963
4026
|
onClick: () => handlers.onStopSync(variableId)
|
|
3964
4027
|
});
|
|
3965
4028
|
} else {
|
|
3966
4029
|
actions.push({
|
|
3967
4030
|
name: (0, import_i18n26.__)("Sync to Global Colors", "elementor"),
|
|
3968
|
-
icon: import_icons16.
|
|
4031
|
+
icon: import_icons16.RefreshIcon,
|
|
3969
4032
|
color: "text.primary",
|
|
3970
4033
|
onClick: () => handlers.onStartSync(variableId)
|
|
3971
4034
|
});
|
|
@@ -4012,8 +4075,8 @@ function registerVariableTypes() {
|
|
|
4012
4075
|
|
|
4013
4076
|
// src/renderers/style-variables-renderer.tsx
|
|
4014
4077
|
var React38 = __toESM(require("react"));
|
|
4015
|
-
var
|
|
4016
|
-
var
|
|
4078
|
+
var import_react30 = require("react");
|
|
4079
|
+
var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
|
|
4017
4080
|
var import_ui35 = require("@elementor/ui");
|
|
4018
4081
|
var VARIABLES_WRAPPER = ":root";
|
|
4019
4082
|
function StyleVariablesRenderer() {
|
|
@@ -4028,11 +4091,11 @@ function StyleVariablesRenderer() {
|
|
|
4028
4091
|
return /* @__PURE__ */ React38.createElement(import_ui35.Portal, { container }, /* @__PURE__ */ React38.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
|
|
4029
4092
|
}
|
|
4030
4093
|
function usePortalContainer() {
|
|
4031
|
-
return (0,
|
|
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);
|
|
4032
4095
|
}
|
|
4033
4096
|
function useStyleVariables() {
|
|
4034
|
-
const [variables, setVariables] = (0,
|
|
4035
|
-
(0,
|
|
4097
|
+
const [variables, setVariables] = (0, import_react30.useState)({});
|
|
4098
|
+
(0, import_react30.useEffect)(() => {
|
|
4036
4099
|
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
4037
4100
|
return () => {
|
|
4038
4101
|
unsubscribe();
|
|
@@ -4124,12 +4187,16 @@ function init() {
|
|
|
4124
4187
|
useProps: usePropVariableAction
|
|
4125
4188
|
});
|
|
4126
4189
|
service.init().then(() => {
|
|
4127
|
-
initMcp();
|
|
4190
|
+
initMcp((0, import_editor_mcp.getMCPByDomain)("variables"), (0, import_editor_mcp.getMCPByDomain)("canvas"));
|
|
4128
4191
|
});
|
|
4129
4192
|
(0, import_editor.injectIntoTop)({
|
|
4130
4193
|
id: "canvas-style-variables-render",
|
|
4131
4194
|
component: StyleVariablesRenderer
|
|
4132
4195
|
});
|
|
4196
|
+
(0, import_editor.injectIntoLogic)({
|
|
4197
|
+
id: "variables-import-listener",
|
|
4198
|
+
component: GlobalStylesImportListener
|
|
4199
|
+
});
|
|
4133
4200
|
(0, import_editor.injectIntoLogic)({
|
|
4134
4201
|
id: "variables-open-panel-from-url",
|
|
4135
4202
|
component: OpenPanelFromUrl
|