@elementor/editor-variables 4.1.0 → 4.2.0-840
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.d.mts +22 -13
- package/dist/index.d.ts +22 -13
- package/dist/index.js +567 -415
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +565 -411
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
- package/src/components/global-styles-import-listener.tsx +3 -5
- package/src/components/variable-selection-popover.tsx +10 -4
- package/src/components/variables-manager/variables-manager-create-menu.tsx +8 -1
- package/src/components/variables-manager/variables-manager-panel.tsx +285 -150
- package/src/components/variables-repeater-item-slot.tsx +20 -0
- package/src/index.ts +4 -0
- package/src/init.ts +12 -9
- package/src/mcp/manage-variable-tool.ts +9 -0
- package/src/mcp/variables-resource.ts +30 -14
- package/src/repeater-injections.ts +22 -0
- package/src/types.ts +2 -11
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ var index_exports = {};
|
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
GLOBAL_VARIABLES_URI: () => GLOBAL_VARIABLES_URI,
|
|
34
34
|
Utils: () => Utils,
|
|
35
|
+
VariablesManagerPanelEmbedded: () => VariablesManagerPanelEmbedded,
|
|
35
36
|
getMenuActionsForVariable: () => getMenuActionsForVariable,
|
|
36
37
|
hasVariable: () => hasVariable,
|
|
37
38
|
init: () => init,
|
|
@@ -42,19 +43,193 @@ __export(index_exports, {
|
|
|
42
43
|
});
|
|
43
44
|
module.exports = __toCommonJS(index_exports);
|
|
44
45
|
|
|
45
|
-
// src/
|
|
46
|
-
var
|
|
47
|
-
var
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
var
|
|
51
|
-
var
|
|
46
|
+
// src/components/variables-manager/variables-manager-panel.tsx
|
|
47
|
+
var React14 = __toESM(require("react"));
|
|
48
|
+
var import_react13 = require("react");
|
|
49
|
+
var import_editor_current_user2 = require("@elementor/editor-current-user");
|
|
50
|
+
var import_editor_panels = require("@elementor/editor-panels");
|
|
51
|
+
var import_editor_ui5 = require("@elementor/editor-ui");
|
|
52
|
+
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
53
|
+
var import_icons5 = require("@elementor/icons");
|
|
54
|
+
var import_ui14 = require("@elementor/ui");
|
|
55
|
+
var import_i18n10 = require("@wordpress/i18n");
|
|
52
56
|
|
|
53
|
-
// src/
|
|
54
|
-
var
|
|
57
|
+
// src/utils/tracking.ts
|
|
58
|
+
var import_events = require("@elementor/events");
|
|
59
|
+
var trackVariableEvent = ({ varType, controlPath, action }) => {
|
|
60
|
+
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
61
|
+
if (!config?.names?.variables?.[action]) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const name = config.names.variables[action];
|
|
65
|
+
dispatchEvent?.(name, {
|
|
66
|
+
location: config?.locations?.variables || "",
|
|
67
|
+
secondaryLocation: config?.secondaryLocations?.variablesPopover || "",
|
|
68
|
+
trigger: config?.triggers?.click || "",
|
|
69
|
+
var_type: varType,
|
|
70
|
+
control_path: controlPath,
|
|
71
|
+
action_type: name
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
var trackVariablesManagerEvent = ({ action, varType, controlPath }) => {
|
|
75
|
+
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
76
|
+
if (!config?.names?.variables?.[action]) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const name = config.names.variables[action];
|
|
80
|
+
const eventData = {
|
|
81
|
+
location: config?.locations?.variablesManager || "",
|
|
82
|
+
trigger: config?.triggers?.click || "",
|
|
83
|
+
action_type: name
|
|
84
|
+
};
|
|
85
|
+
if (varType) {
|
|
86
|
+
eventData.var_type = varType;
|
|
87
|
+
}
|
|
88
|
+
if (controlPath) {
|
|
89
|
+
eventData.style_control_path = controlPath;
|
|
90
|
+
}
|
|
91
|
+
dispatchEvent?.(name, eventData);
|
|
92
|
+
};
|
|
93
|
+
var trackVariableSyncToV3 = ({ variableLabel, action }) => {
|
|
94
|
+
try {
|
|
95
|
+
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
96
|
+
if (!config?.names?.variables?.variableSyncToV3) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const name = config.names.variables.variableSyncToV3;
|
|
100
|
+
const isSync = action === "sync";
|
|
101
|
+
dispatchEvent?.(name, {
|
|
102
|
+
interaction_type: "click",
|
|
103
|
+
target_type: variableLabel,
|
|
104
|
+
target_name: isSync ? "sync_to_v3" : "unsync_to_v3",
|
|
105
|
+
interaction_result: isSync ? "var_is_synced_to_V3" : "var_is_unsynced_from_V3",
|
|
106
|
+
target_location: "widget_panel",
|
|
107
|
+
location_l1: "var_manager",
|
|
108
|
+
interaction_description: isSync ? `user_synced_${variableLabel}_to_v3` : `user_unsync_${variableLabel}_from_v3`
|
|
109
|
+
});
|
|
110
|
+
} catch {
|
|
111
|
+
}
|
|
112
|
+
};
|
|
55
113
|
|
|
56
|
-
// src/
|
|
114
|
+
// src/utils/validations.ts
|
|
115
|
+
var import_icons = require("@elementor/icons");
|
|
57
116
|
var import_i18n = require("@wordpress/i18n");
|
|
117
|
+
var ERROR_MESSAGES = {
|
|
118
|
+
MISSING_VARIABLE_NAME: (0, import_i18n.__)("Give your variable a name.", "elementor"),
|
|
119
|
+
MISSING_VARIABLE_VALUE: (0, import_i18n.__)("Add a value to complete your variable.", "elementor"),
|
|
120
|
+
INVALID_CHARACTERS: (0, import_i18n.__)("Use letters, numbers, dashes (-), or underscores (_) for the name.", "elementor"),
|
|
121
|
+
NO_NON_SPECIAL_CHARACTER: (0, import_i18n.__)("Names have to include at least one non-special character.", "elementor"),
|
|
122
|
+
VARIABLE_LABEL_MAX_LENGTH: (0, import_i18n.__)("Keep names up to 50 characters.", "elementor"),
|
|
123
|
+
DUPLICATED_LABEL: (0, import_i18n.__)("This variable name already exists. Please choose a unique name.", "elementor"),
|
|
124
|
+
UNEXPECTED_ERROR: (0, import_i18n.__)("There was a glitch. Try saving your variable again.", "elementor"),
|
|
125
|
+
BATCH: {
|
|
126
|
+
DUPLICATED_LABELS: (count, name) => (
|
|
127
|
+
// eslint-disable-next-line @wordpress/i18n-translator-comments
|
|
128
|
+
(0, import_i18n.sprintf)((0, import_i18n.__)("We found %1$d duplicated %2$s.", "elementor"), count, name)
|
|
129
|
+
),
|
|
130
|
+
UNEXPECTED_ERROR: (0, import_i18n.__)("There was a glitch.", "elementor"),
|
|
131
|
+
DUPLICATED_LABEL_ACTION: (0, import_i18n.__)("Take me there", "elementor"),
|
|
132
|
+
DUPLICATED_LABEL_ACTION_MESSAGE: (0, import_i18n.__)("Please rename the variables.", "elementor"),
|
|
133
|
+
UNEXPECTED_ERROR_ACTION_MESSAGE: (0, import_i18n.__)("Try saving your variables again.", "elementor")
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
var VARIABLE_LABEL_MAX_LENGTH = 50;
|
|
137
|
+
var mapServerError = (error) => {
|
|
138
|
+
if (error?.response?.data?.code === "duplicated_label") {
|
|
139
|
+
return {
|
|
140
|
+
field: "label",
|
|
141
|
+
message: ERROR_MESSAGES.DUPLICATED_LABEL
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
if (error?.response?.data?.code === "batch_duplicated_label") {
|
|
145
|
+
const errorData = error?.response?.data?.data ?? {};
|
|
146
|
+
const count = Object.keys(errorData).length;
|
|
147
|
+
const name = count === 1 ? "name" : "names";
|
|
148
|
+
const duplicatedIds = Object.keys(errorData);
|
|
149
|
+
return {
|
|
150
|
+
field: "label",
|
|
151
|
+
message: ERROR_MESSAGES.BATCH.DUPLICATED_LABELS(count, name),
|
|
152
|
+
severity: "error",
|
|
153
|
+
IconComponent: import_icons.AlertTriangleFilledIcon,
|
|
154
|
+
action: {
|
|
155
|
+
label: ERROR_MESSAGES.BATCH.DUPLICATED_LABEL_ACTION,
|
|
156
|
+
message: ERROR_MESSAGES.BATCH.DUPLICATED_LABEL_ACTION_MESSAGE,
|
|
157
|
+
data: {
|
|
158
|
+
duplicatedIds
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
if (error?.response?.data?.code === "batch_operation_failed") {
|
|
164
|
+
return {
|
|
165
|
+
field: "label",
|
|
166
|
+
message: ERROR_MESSAGES.BATCH.UNEXPECTED_ERROR,
|
|
167
|
+
severity: "secondary",
|
|
168
|
+
IconComponent: import_icons.InfoCircleFilledIcon,
|
|
169
|
+
action: {
|
|
170
|
+
message: ERROR_MESSAGES.BATCH.UNEXPECTED_ERROR_ACTION_MESSAGE
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
return void 0;
|
|
175
|
+
};
|
|
176
|
+
var validateLabel = (name, variables) => {
|
|
177
|
+
if (!name.trim()) {
|
|
178
|
+
return ERROR_MESSAGES.MISSING_VARIABLE_NAME;
|
|
179
|
+
}
|
|
180
|
+
const allowedChars = /^[a-zA-Z0-9_-]+$/;
|
|
181
|
+
if (!allowedChars.test(name)) {
|
|
182
|
+
return ERROR_MESSAGES.INVALID_CHARACTERS;
|
|
183
|
+
}
|
|
184
|
+
const hasAlphanumeric = /[a-zA-Z0-9]/;
|
|
185
|
+
if (!hasAlphanumeric.test(name)) {
|
|
186
|
+
return ERROR_MESSAGES.NO_NON_SPECIAL_CHARACTER;
|
|
187
|
+
}
|
|
188
|
+
if (VARIABLE_LABEL_MAX_LENGTH < name.length) {
|
|
189
|
+
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
190
|
+
}
|
|
191
|
+
if (Object.values(variables ?? {}).some((variable) => variable.label === name)) {
|
|
192
|
+
return ERROR_MESSAGES.DUPLICATED_LABEL;
|
|
193
|
+
}
|
|
194
|
+
return "";
|
|
195
|
+
};
|
|
196
|
+
var labelHint = (name) => {
|
|
197
|
+
const hintThreshold = VARIABLE_LABEL_MAX_LENGTH * 0.8 - 1;
|
|
198
|
+
if (hintThreshold < name.length) {
|
|
199
|
+
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
200
|
+
}
|
|
201
|
+
return "";
|
|
202
|
+
};
|
|
203
|
+
var validateValue = (value) => {
|
|
204
|
+
if (!value.trim()) {
|
|
205
|
+
return ERROR_MESSAGES.MISSING_VARIABLE_VALUE;
|
|
206
|
+
}
|
|
207
|
+
return "";
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// src/variables-registry/create-variable-type-registry.ts
|
|
211
|
+
var import_editor_canvas3 = require("@elementor/editor-canvas");
|
|
212
|
+
|
|
213
|
+
// src/transformers/inheritance-transformer.tsx
|
|
214
|
+
var React = __toESM(require("react"));
|
|
215
|
+
var import_editor_canvas = require("@elementor/editor-canvas");
|
|
216
|
+
var import_ui2 = require("@elementor/ui");
|
|
217
|
+
var import_i18n3 = require("@wordpress/i18n");
|
|
218
|
+
|
|
219
|
+
// src/components/ui/color-indicator.tsx
|
|
220
|
+
var import_ui = require("@elementor/ui");
|
|
221
|
+
var ColorIndicator = (0, import_ui.styled)(import_ui.UnstableColorIndicator)(({ theme }) => ({
|
|
222
|
+
borderRadius: `${theme.shape.borderRadius / 2}px`,
|
|
223
|
+
marginRight: theme.spacing(0.25)
|
|
224
|
+
}));
|
|
225
|
+
|
|
226
|
+
// src/prop-types/color-variable-prop-type.ts
|
|
227
|
+
var import_editor_props = require("@elementor/editor-props");
|
|
228
|
+
var import_schema = require("@elementor/schema");
|
|
229
|
+
var colorVariablePropTypeUtil = (0, import_editor_props.createPropUtils)("global-color-variable", import_schema.z.string());
|
|
230
|
+
|
|
231
|
+
// src/service.ts
|
|
232
|
+
var import_i18n2 = require("@wordpress/i18n");
|
|
58
233
|
|
|
59
234
|
// src/api.ts
|
|
60
235
|
var import_http_client = require("@elementor/http-client");
|
|
@@ -219,9 +394,9 @@ var Storage = class {
|
|
|
219
394
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
220
395
|
|
|
221
396
|
// src/prop-types/font-variable-prop-type.ts
|
|
222
|
-
var
|
|
223
|
-
var
|
|
224
|
-
var fontVariablePropTypeUtil = (0,
|
|
397
|
+
var import_editor_props2 = require("@elementor/editor-props");
|
|
398
|
+
var import_schema2 = require("@elementor/schema");
|
|
399
|
+
var fontVariablePropTypeUtil = (0, import_editor_props2.createPropUtils)("global-font-variable", import_schema2.z.string());
|
|
225
400
|
|
|
226
401
|
// src/create-style-variables-repository.ts
|
|
227
402
|
var createStyleVariablesRepository = () => {
|
|
@@ -333,7 +508,7 @@ var service = {
|
|
|
333
508
|
return apiClient.create(type, label, value).then((response) => {
|
|
334
509
|
const { success, data: payload } = response.data;
|
|
335
510
|
if (!success) {
|
|
336
|
-
const errorMessage = payload?.message || (0,
|
|
511
|
+
const errorMessage = payload?.message || (0, import_i18n2.__)("Unexpected response from server", "elementor");
|
|
337
512
|
throw new Error(errorMessage);
|
|
338
513
|
}
|
|
339
514
|
return payload;
|
|
@@ -355,7 +530,7 @@ var service = {
|
|
|
355
530
|
return apiClient.update(id2, label, value, type).then((response) => {
|
|
356
531
|
const { success, data: payload } = response.data;
|
|
357
532
|
if (!success) {
|
|
358
|
-
const errorMessage = payload?.message || (0,
|
|
533
|
+
const errorMessage = payload?.message || (0, import_i18n2.__)("Unexpected response from server", "elementor");
|
|
359
534
|
throw new Error(errorMessage);
|
|
360
535
|
}
|
|
361
536
|
return payload;
|
|
@@ -458,225 +633,12 @@ var service = {
|
|
|
458
633
|
}
|
|
459
634
|
};
|
|
460
635
|
var handleWatermark = (operation, newWatermark) => {
|
|
461
|
-
if (storage.watermarkDiff(operation, newWatermark)) {
|
|
462
|
-
setTimeout(() => service.load(), 500);
|
|
463
|
-
}
|
|
464
|
-
storage.watermark(newWatermark);
|
|
465
|
-
};
|
|
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;
|
|
636
|
+
if (storage.watermarkDiff(operation, newWatermark)) {
|
|
637
|
+
setTimeout(() => service.load(), 500);
|
|
655
638
|
}
|
|
656
|
-
|
|
639
|
+
storage.watermark(newWatermark);
|
|
657
640
|
};
|
|
658
641
|
|
|
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
|
-
|
|
680
642
|
// src/transformers/utils/resolve-css-variable.ts
|
|
681
643
|
var resolveCssVariable = (id2, variable) => {
|
|
682
644
|
let name = id2;
|
|
@@ -879,13 +841,13 @@ var NoSearchResults = ({ searchValue, onClear, icon }) => {
|
|
|
879
841
|
};
|
|
880
842
|
|
|
881
843
|
// src/components/variables-manager/hooks/use-auto-edit.ts
|
|
882
|
-
var
|
|
844
|
+
var import_react = require("react");
|
|
883
845
|
var useAutoEdit = () => {
|
|
884
|
-
const [autoEditVariableId, setAutoEditVariableId] = (0,
|
|
885
|
-
const startAutoEdit = (0,
|
|
846
|
+
const [autoEditVariableId, setAutoEditVariableId] = (0, import_react.useState)(void 0);
|
|
847
|
+
const startAutoEdit = (0, import_react.useCallback)((variableId) => {
|
|
886
848
|
setAutoEditVariableId(variableId);
|
|
887
849
|
}, []);
|
|
888
|
-
const handleAutoEditComplete = (0,
|
|
850
|
+
const handleAutoEditComplete = (0, import_react.useCallback)(() => {
|
|
889
851
|
setTimeout(() => {
|
|
890
852
|
setAutoEditVariableId(void 0);
|
|
891
853
|
}, 100);
|
|
@@ -898,10 +860,10 @@ var useAutoEdit = () => {
|
|
|
898
860
|
};
|
|
899
861
|
|
|
900
862
|
// src/components/variables-manager/hooks/use-error-navigation.ts
|
|
901
|
-
var
|
|
863
|
+
var import_react2 = require("react");
|
|
902
864
|
var useErrorNavigation = () => {
|
|
903
|
-
const currentIndexRef = (0,
|
|
904
|
-
const createNavigationCallback = (0,
|
|
865
|
+
const currentIndexRef = (0, import_react2.useRef)(0);
|
|
866
|
+
const createNavigationCallback = (0, import_react2.useCallback)(
|
|
905
867
|
(ids, onNavigate, onComplete) => {
|
|
906
868
|
return () => {
|
|
907
869
|
if (!ids?.length) {
|
|
@@ -923,7 +885,7 @@ var useErrorNavigation = () => {
|
|
|
923
885
|
},
|
|
924
886
|
[]
|
|
925
887
|
);
|
|
926
|
-
const resetNavigation = (0,
|
|
888
|
+
const resetNavigation = (0, import_react2.useCallback)(() => {
|
|
927
889
|
currentIndexRef.current = 0;
|
|
928
890
|
}, []);
|
|
929
891
|
return {
|
|
@@ -933,21 +895,21 @@ var useErrorNavigation = () => {
|
|
|
933
895
|
};
|
|
934
896
|
|
|
935
897
|
// src/components/variables-manager/hooks/use-variables-manager-state.ts
|
|
936
|
-
var
|
|
898
|
+
var import_react5 = require("react");
|
|
937
899
|
|
|
938
900
|
// src/hooks/use-prop-variables.ts
|
|
939
|
-
var
|
|
901
|
+
var import_react4 = require("react");
|
|
940
902
|
var import_editor_controls = require("@elementor/editor-controls");
|
|
941
903
|
|
|
942
904
|
// src/context/variable-type-context.tsx
|
|
943
905
|
var React5 = __toESM(require("react"));
|
|
944
|
-
var
|
|
945
|
-
var VariableTypeContext = (0,
|
|
906
|
+
var import_react3 = require("react");
|
|
907
|
+
var VariableTypeContext = (0, import_react3.createContext)(null);
|
|
946
908
|
function VariableTypeProvider({ children, propTypeKey }) {
|
|
947
909
|
return /* @__PURE__ */ React5.createElement(VariableTypeContext.Provider, { value: propTypeKey }, children);
|
|
948
910
|
}
|
|
949
911
|
function useVariableType() {
|
|
950
|
-
const context = (0,
|
|
912
|
+
const context = (0, import_react3.useContext)(VariableTypeContext);
|
|
951
913
|
if (context === null) {
|
|
952
914
|
throw new Error("useVariableType must be used within a VariableTypeProvider");
|
|
953
915
|
}
|
|
@@ -1033,7 +995,7 @@ var useVariableSelectionFilter = (variables) => {
|
|
|
1033
995
|
return selectionFilter ? selectionFilter(variables, propType) : variables;
|
|
1034
996
|
};
|
|
1035
997
|
var usePropVariables = (propKey) => {
|
|
1036
|
-
return (0,
|
|
998
|
+
return (0, import_react4.useMemo)(() => normalizeVariables(propKey), [propKey]);
|
|
1037
999
|
};
|
|
1038
1000
|
var getMatchingTypes = (propKey) => {
|
|
1039
1001
|
const matchingTypes = [];
|
|
@@ -1091,20 +1053,20 @@ var generateDuplicateLabel = (originalLabel, existingLabels) => {
|
|
|
1091
1053
|
|
|
1092
1054
|
// src/components/variables-manager/hooks/use-variables-manager-state.ts
|
|
1093
1055
|
var useVariablesManagerState = () => {
|
|
1094
|
-
const [variables, setVariables] = (0,
|
|
1095
|
-
const [deletedVariables, setDeletedVariables] = (0,
|
|
1096
|
-
const [isSaveDisabled, setIsSaveDisabled] = (0,
|
|
1097
|
-
const [isDirty, setIsDirty] = (0,
|
|
1098
|
-
const [isSaving, setIsSaving] = (0,
|
|
1099
|
-
const [searchValue, setSearchValue] = (0,
|
|
1100
|
-
const handleOnChange = (0,
|
|
1056
|
+
const [variables, setVariables] = (0, import_react5.useState)(() => getVariables(false));
|
|
1057
|
+
const [deletedVariables, setDeletedVariables] = (0, import_react5.useState)([]);
|
|
1058
|
+
const [isSaveDisabled, setIsSaveDisabled] = (0, import_react5.useState)(false);
|
|
1059
|
+
const [isDirty, setIsDirty] = (0, import_react5.useState)(false);
|
|
1060
|
+
const [isSaving, setIsSaving] = (0, import_react5.useState)(false);
|
|
1061
|
+
const [searchValue, setSearchValue] = (0, import_react5.useState)("");
|
|
1062
|
+
const handleOnChange = (0, import_react5.useCallback)(
|
|
1101
1063
|
(newVariables) => {
|
|
1102
1064
|
setVariables({ ...variables, ...newVariables });
|
|
1103
1065
|
setIsDirty(true);
|
|
1104
1066
|
},
|
|
1105
1067
|
[variables]
|
|
1106
1068
|
);
|
|
1107
|
-
const createVariable2 = (0,
|
|
1069
|
+
const createVariable2 = (0, import_react5.useCallback)((type, defaultName, defaultValue) => {
|
|
1108
1070
|
const newId = generateTempId();
|
|
1109
1071
|
const newVariable = {
|
|
1110
1072
|
id: newId,
|
|
@@ -1116,7 +1078,7 @@ var useVariablesManagerState = () => {
|
|
|
1116
1078
|
setIsDirty(true);
|
|
1117
1079
|
return newId;
|
|
1118
1080
|
}, []);
|
|
1119
|
-
const duplicateVariable = (0,
|
|
1081
|
+
const duplicateVariable = (0, import_react5.useCallback)((sourceId) => {
|
|
1120
1082
|
const newId = generateTempId();
|
|
1121
1083
|
setVariables((prev) => {
|
|
1122
1084
|
const source = prev[sourceId];
|
|
@@ -1136,19 +1098,19 @@ var useVariablesManagerState = () => {
|
|
|
1136
1098
|
setIsDirty(true);
|
|
1137
1099
|
return newId;
|
|
1138
1100
|
}, []);
|
|
1139
|
-
const handleDeleteVariable = (0,
|
|
1101
|
+
const handleDeleteVariable = (0, import_react5.useCallback)((itemId) => {
|
|
1140
1102
|
setDeletedVariables((prev) => [...prev, itemId]);
|
|
1141
1103
|
setVariables((prev) => ({ ...prev, [itemId]: { ...prev[itemId], deleted: true } }));
|
|
1142
1104
|
setIsDirty(true);
|
|
1143
1105
|
}, []);
|
|
1144
|
-
const handleStartSync = (0,
|
|
1106
|
+
const handleStartSync = (0, import_react5.useCallback)((itemId) => {
|
|
1145
1107
|
setVariables((prev) => ({
|
|
1146
1108
|
...prev,
|
|
1147
1109
|
[itemId]: { ...prev[itemId], sync_to_v3: true }
|
|
1148
1110
|
}));
|
|
1149
1111
|
setIsDirty(true);
|
|
1150
1112
|
}, []);
|
|
1151
|
-
const handleStopSync = (0,
|
|
1113
|
+
const handleStopSync = (0, import_react5.useCallback)((itemId) => {
|
|
1152
1114
|
setVariables((prev) => ({
|
|
1153
1115
|
...prev,
|
|
1154
1116
|
[itemId]: { ...prev[itemId], sync_to_v3: false }
|
|
@@ -1158,7 +1120,7 @@ var useVariablesManagerState = () => {
|
|
|
1158
1120
|
const handleSearch = (searchTerm) => {
|
|
1159
1121
|
setSearchValue(searchTerm);
|
|
1160
1122
|
};
|
|
1161
|
-
const handleSave = (0,
|
|
1123
|
+
const handleSave = (0, import_react5.useCallback)(async () => {
|
|
1162
1124
|
const originalVariables = getVariables(false);
|
|
1163
1125
|
setIsSaving(true);
|
|
1164
1126
|
const result = await service.batchSave(originalVariables, variables, deletedVariables);
|
|
@@ -1171,7 +1133,7 @@ var useVariablesManagerState = () => {
|
|
|
1171
1133
|
}
|
|
1172
1134
|
return { success: result.success };
|
|
1173
1135
|
}, [variables, deletedVariables]);
|
|
1174
|
-
const filteredVariables = (0,
|
|
1136
|
+
const filteredVariables = (0, import_react5.useCallback)(() => {
|
|
1175
1137
|
const list = variablesToList(variables).filter((v) => !v.deleted);
|
|
1176
1138
|
const typeFiltered = applySelectionFilters(list, getVariableTypes());
|
|
1177
1139
|
const searchFiltered = filterBySearch(typeFiltered, searchValue);
|
|
@@ -1199,7 +1161,7 @@ var useVariablesManagerState = () => {
|
|
|
1199
1161
|
|
|
1200
1162
|
// src/components/variables-manager/variables-manager-create-menu.tsx
|
|
1201
1163
|
var React7 = __toESM(require("react"));
|
|
1202
|
-
var
|
|
1164
|
+
var import_react7 = require("react");
|
|
1203
1165
|
var import_icons2 = require("@elementor/icons");
|
|
1204
1166
|
var import_ui7 = require("@elementor/ui");
|
|
1205
1167
|
var import_utils2 = require("@elementor/utils");
|
|
@@ -1222,17 +1184,17 @@ var useQuotaPermissions = (variableType) => {
|
|
|
1222
1184
|
|
|
1223
1185
|
// src/components/ui/variable-promotion-chip.tsx
|
|
1224
1186
|
var React6 = __toESM(require("react"));
|
|
1225
|
-
var
|
|
1187
|
+
var import_react6 = require("react");
|
|
1226
1188
|
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
1227
1189
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
1228
1190
|
var import_ui6 = require("@elementor/ui");
|
|
1229
1191
|
var import_utils = require("@elementor/utils");
|
|
1230
1192
|
var import_i18n7 = require("@wordpress/i18n");
|
|
1231
|
-
var VariablePromotionChip = (0,
|
|
1193
|
+
var VariablePromotionChip = (0, import_react6.forwardRef)(
|
|
1232
1194
|
({ variableType, upgradeUrl, trackingData }, ref) => {
|
|
1233
|
-
const [isOpen, setIsOpen] = (0,
|
|
1195
|
+
const [isOpen, setIsOpen] = (0, import_react6.useState)(false);
|
|
1234
1196
|
(0, import_editor_ui2.useCanvasClickHandler)(isOpen, () => setIsOpen(false));
|
|
1235
|
-
const toggle = (0,
|
|
1197
|
+
const toggle = (0, import_react6.useCallback)(() => {
|
|
1236
1198
|
setIsOpen((prev) => {
|
|
1237
1199
|
if (!prev) {
|
|
1238
1200
|
(0, import_editor_controls2.trackViewPromotion)(trackingData);
|
|
@@ -1240,7 +1202,7 @@ var VariablePromotionChip = (0, import_react7.forwardRef)(
|
|
|
1240
1202
|
return !prev;
|
|
1241
1203
|
});
|
|
1242
1204
|
}, [trackingData]);
|
|
1243
|
-
(0,
|
|
1205
|
+
(0, import_react6.useImperativeHandle)(ref, () => ({ toggle }), [toggle]);
|
|
1244
1206
|
const title = (0, import_i18n7.sprintf)(
|
|
1245
1207
|
/* translators: %s: Variable Type. */
|
|
1246
1208
|
(0, import_i18n7.__)("%s variables", "elementor"),
|
|
@@ -1287,10 +1249,15 @@ var TRACKING_DATA = {
|
|
|
1287
1249
|
location_l1: "create variable menu"
|
|
1288
1250
|
};
|
|
1289
1251
|
var SIZE = "tiny";
|
|
1290
|
-
var VariableManagerCreateMenu = ({
|
|
1291
|
-
|
|
1252
|
+
var VariableManagerCreateMenu = ({
|
|
1253
|
+
variables,
|
|
1254
|
+
onCreate,
|
|
1255
|
+
menuState,
|
|
1256
|
+
outlinedTrigger = false
|
|
1257
|
+
}) => {
|
|
1258
|
+
const buttonRef = (0, import_react7.useRef)(null);
|
|
1292
1259
|
const variableTypes = getVariableTypes();
|
|
1293
|
-
const menuOptionConfigs = (0,
|
|
1260
|
+
const menuOptionConfigs = (0, import_react7.useMemo)(
|
|
1294
1261
|
() => Object.entries(variableTypes).filter(([, variable]) => !!variable.defaultValue).map(([key, variable]) => ({
|
|
1295
1262
|
key,
|
|
1296
1263
|
propTypeKey: variable.propTypeUtil.key,
|
|
@@ -1306,6 +1273,7 @@ var VariableManagerCreateMenu = ({ variables, onCreate, menuState }) => {
|
|
|
1306
1273
|
...(0, import_ui7.bindTrigger)(menuState),
|
|
1307
1274
|
ref: buttonRef,
|
|
1308
1275
|
size: SIZE,
|
|
1276
|
+
variant: outlinedTrigger ? "outlined" : void 0,
|
|
1309
1277
|
"aria-label": (0, import_i18n8.__)("Add variable", "elementor")
|
|
1310
1278
|
},
|
|
1311
1279
|
/* @__PURE__ */ React7.createElement(import_icons2.PlusIcon, { fontSize: SIZE })
|
|
@@ -1349,7 +1317,7 @@ var MenuOption = ({
|
|
|
1349
1317
|
onCreate,
|
|
1350
1318
|
onClose
|
|
1351
1319
|
}) => {
|
|
1352
|
-
const promotionRef = (0,
|
|
1320
|
+
const promotionRef = (0, import_react7.useRef)(null);
|
|
1353
1321
|
const userQuotaPermissions = useQuotaPermissions(config.propTypeKey);
|
|
1354
1322
|
const displayName = (0, import_utils2.capitalize)(config.variableType);
|
|
1355
1323
|
const isDisabled = !userQuotaPermissions.canAdd();
|
|
@@ -1363,7 +1331,7 @@ var MenuOption = ({
|
|
|
1363
1331
|
trackVariablesManagerEvent({ action: "add", varType: config.variableType });
|
|
1364
1332
|
onClose();
|
|
1365
1333
|
};
|
|
1366
|
-
return /* @__PURE__ */ React7.createElement(import_ui7.MenuItem, { onClick: handleClick, sx: { gap: 1.5, cursor: "pointer" } }, (0,
|
|
1334
|
+
return /* @__PURE__ */ React7.createElement(import_ui7.MenuItem, { onClick: handleClick, sx: { gap: 1.5, cursor: "pointer" } }, (0, import_react7.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(
|
|
1367
1335
|
VariablePromotionChip,
|
|
1368
1336
|
{
|
|
1369
1337
|
variableType: config.variableType,
|
|
@@ -1391,7 +1359,7 @@ var getDefaultName = (variables, baseName) => {
|
|
|
1391
1359
|
|
|
1392
1360
|
// src/components/variables-manager/variables-manager-table.tsx
|
|
1393
1361
|
var React13 = __toESM(require("react"));
|
|
1394
|
-
var
|
|
1362
|
+
var import_react12 = require("react");
|
|
1395
1363
|
var import_ui13 = require("@elementor/ui");
|
|
1396
1364
|
var import_i18n9 = require("@wordpress/i18n");
|
|
1397
1365
|
|
|
@@ -1421,21 +1389,21 @@ var VariableTableCell = ({
|
|
|
1421
1389
|
|
|
1422
1390
|
// src/components/variables-manager/ui/variable-table-row.tsx
|
|
1423
1391
|
var React12 = __toESM(require("react"));
|
|
1424
|
-
var
|
|
1392
|
+
var import_react11 = require("react");
|
|
1425
1393
|
var import_editor_ui4 = require("@elementor/editor-ui");
|
|
1426
1394
|
var import_icons4 = require("@elementor/icons");
|
|
1427
1395
|
var import_ui12 = require("@elementor/ui");
|
|
1428
1396
|
|
|
1429
1397
|
// src/components/fields/label-field.tsx
|
|
1430
1398
|
var React9 = __toESM(require("react"));
|
|
1431
|
-
var
|
|
1399
|
+
var import_react8 = require("react");
|
|
1432
1400
|
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
1433
1401
|
var import_ui9 = require("@elementor/ui");
|
|
1434
1402
|
function isLabelEqual(a, b) {
|
|
1435
1403
|
return a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
1436
1404
|
}
|
|
1437
1405
|
var useLabelError = (initialError) => {
|
|
1438
|
-
const [error, setError] = (0,
|
|
1406
|
+
const [error, setError] = (0, import_react8.useState)(initialError ?? { value: "", message: "" });
|
|
1439
1407
|
return {
|
|
1440
1408
|
labelFieldError: error,
|
|
1441
1409
|
setLabelFieldError: setError
|
|
@@ -1454,9 +1422,9 @@ var LabelField = ({
|
|
|
1454
1422
|
variables,
|
|
1455
1423
|
onKeyDown
|
|
1456
1424
|
}) => {
|
|
1457
|
-
const [label, setLabel] = (0,
|
|
1458
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
1459
|
-
const fieldRef = (0,
|
|
1425
|
+
const [label, setLabel] = (0, import_react8.useState)(value);
|
|
1426
|
+
const [errorMessage, setErrorMessage] = (0, import_react8.useState)("");
|
|
1427
|
+
const fieldRef = (0, import_react8.useRef)(null);
|
|
1460
1428
|
const handleChange = (newValue) => {
|
|
1461
1429
|
setLabel(newValue);
|
|
1462
1430
|
const errorMsg2 = validateLabel(newValue, variables);
|
|
@@ -1508,7 +1476,7 @@ var LabelField = ({
|
|
|
1508
1476
|
|
|
1509
1477
|
// src/components/variables-manager/variable-editable-cell.tsx
|
|
1510
1478
|
var React10 = __toESM(require("react"));
|
|
1511
|
-
var
|
|
1479
|
+
var import_react9 = require("react");
|
|
1512
1480
|
var import_ui10 = require("@elementor/ui");
|
|
1513
1481
|
var VariableEditableCell = React10.memo(
|
|
1514
1482
|
({
|
|
@@ -1524,22 +1492,22 @@ var VariableEditableCell = React10.memo(
|
|
|
1524
1492
|
fieldType,
|
|
1525
1493
|
disabled = false
|
|
1526
1494
|
}) => {
|
|
1527
|
-
const [value, setValue] = (0,
|
|
1528
|
-
const [isEditing, setIsEditing] = (0,
|
|
1495
|
+
const [value, setValue] = (0, import_react9.useState)(initialValue);
|
|
1496
|
+
const [isEditing, setIsEditing] = (0, import_react9.useState)(false);
|
|
1529
1497
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
1530
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
1531
|
-
const rowRef = (0,
|
|
1532
|
-
const handleSave = (0,
|
|
1498
|
+
const [valueFieldError, setValueFieldError] = (0, import_react9.useState)("");
|
|
1499
|
+
const rowRef = (0, import_react9.useRef)(null);
|
|
1500
|
+
const handleSave = (0, import_react9.useCallback)(() => {
|
|
1533
1501
|
const hasError = fieldType === "label" && labelFieldError?.message || fieldType === "value" && valueFieldError;
|
|
1534
1502
|
if (!hasError) {
|
|
1535
1503
|
onChange(value);
|
|
1536
1504
|
}
|
|
1537
1505
|
setIsEditing(false);
|
|
1538
1506
|
}, [value, onChange, fieldType, labelFieldError, valueFieldError]);
|
|
1539
|
-
(0,
|
|
1507
|
+
(0, import_react9.useEffect)(() => {
|
|
1540
1508
|
onRowRef?.(rowRef?.current);
|
|
1541
1509
|
}, [onRowRef]);
|
|
1542
|
-
(0,
|
|
1510
|
+
(0, import_react9.useEffect)(() => {
|
|
1543
1511
|
if (autoEdit && !isEditing && !disabled) {
|
|
1544
1512
|
setIsEditing(true);
|
|
1545
1513
|
onAutoEditComplete?.();
|
|
@@ -1565,10 +1533,10 @@ var VariableEditableCell = React10.memo(
|
|
|
1565
1533
|
setIsEditing(true);
|
|
1566
1534
|
}
|
|
1567
1535
|
};
|
|
1568
|
-
const handleChange = (0,
|
|
1536
|
+
const handleChange = (0, import_react9.useCallback)((newValue) => {
|
|
1569
1537
|
setValue(newValue);
|
|
1570
1538
|
}, []);
|
|
1571
|
-
const handleValidationChange = (0,
|
|
1539
|
+
const handleValidationChange = (0, import_react9.useCallback)(
|
|
1572
1540
|
(errorMsg) => {
|
|
1573
1541
|
if (fieldType === "label") {
|
|
1574
1542
|
setLabelFieldError({
|
|
@@ -1632,7 +1600,7 @@ var VariableEditableCell = React10.memo(
|
|
|
1632
1600
|
|
|
1633
1601
|
// src/components/variables-manager/ui/variable-edit-menu.tsx
|
|
1634
1602
|
var React11 = __toESM(require("react"));
|
|
1635
|
-
var
|
|
1603
|
+
var import_react10 = require("react");
|
|
1636
1604
|
var import_icons3 = require("@elementor/icons");
|
|
1637
1605
|
var import_ui11 = require("@elementor/ui");
|
|
1638
1606
|
var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
|
|
@@ -1689,7 +1657,7 @@ var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
|
|
|
1689
1657
|
gap: 1
|
|
1690
1658
|
}
|
|
1691
1659
|
},
|
|
1692
|
-
action.icon && (0,
|
|
1660
|
+
action.icon && (0, import_react10.createElement)(action.icon, {
|
|
1693
1661
|
fontSize: "inherit"
|
|
1694
1662
|
}),
|
|
1695
1663
|
" ",
|
|
@@ -1720,7 +1688,7 @@ var VariableRow = (props) => {
|
|
|
1720
1688
|
setTriggerRef,
|
|
1721
1689
|
isSorting
|
|
1722
1690
|
} = props;
|
|
1723
|
-
const promotionRef = (0,
|
|
1691
|
+
const promotionRef = (0, import_react11.useRef)(null);
|
|
1724
1692
|
const isDisabled = !useQuotaPermissions(row.type).canEdit();
|
|
1725
1693
|
const showIndicationBefore = showDropIndication && dropPosition === "before";
|
|
1726
1694
|
const showIndicationAfter = showDropIndication && dropPosition === "after";
|
|
@@ -1778,7 +1746,7 @@ var VariableRow = (props) => {
|
|
|
1778
1746
|
});
|
|
1779
1747
|
}
|
|
1780
1748
|
},
|
|
1781
|
-
prefixElement: (0,
|
|
1749
|
+
prefixElement: (0, import_react11.createElement)(row.icon, {
|
|
1782
1750
|
fontSize: "inherit",
|
|
1783
1751
|
color: isDisabled ? "disabled" : "inherit"
|
|
1784
1752
|
}),
|
|
@@ -1878,9 +1846,9 @@ var VariablesManagerTable = ({
|
|
|
1878
1846
|
onAutoEditComplete,
|
|
1879
1847
|
onFieldError
|
|
1880
1848
|
}) => {
|
|
1881
|
-
const tableContainerRef = (0,
|
|
1882
|
-
const variableRowRefs = (0,
|
|
1883
|
-
(0,
|
|
1849
|
+
const tableContainerRef = (0, import_react12.useRef)(null);
|
|
1850
|
+
const variableRowRefs = (0, import_react12.useRef)(/* @__PURE__ */ new Map());
|
|
1851
|
+
(0, import_react12.useEffect)(() => {
|
|
1884
1852
|
if (autoEditVariableId && tableContainerRef.current) {
|
|
1885
1853
|
const rowElement = variableRowRefs.current.get(autoEditVariableId);
|
|
1886
1854
|
if (rowElement) {
|
|
@@ -1986,8 +1954,33 @@ var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
|
|
|
1986
1954
|
},
|
|
1987
1955
|
isOpenPreviousElement: true
|
|
1988
1956
|
});
|
|
1957
|
+
function VariablesManagerPanelEmbedded({
|
|
1958
|
+
onRequestClose,
|
|
1959
|
+
onExposeCloseAttempt
|
|
1960
|
+
}) {
|
|
1961
|
+
return /* @__PURE__ */ React14.createElement(
|
|
1962
|
+
VariablesManagerPanelRoot,
|
|
1963
|
+
{
|
|
1964
|
+
embedded: true,
|
|
1965
|
+
onRequestClose,
|
|
1966
|
+
onExposeCloseAttempt
|
|
1967
|
+
}
|
|
1968
|
+
);
|
|
1969
|
+
}
|
|
1989
1970
|
function VariablesManagerPanel() {
|
|
1990
|
-
|
|
1971
|
+
return /* @__PURE__ */ React14.createElement(VariablesManagerPanelRoot, null);
|
|
1972
|
+
}
|
|
1973
|
+
function VariablesManagerPanelRoot({
|
|
1974
|
+
embedded = false,
|
|
1975
|
+
onRequestClose,
|
|
1976
|
+
onExposeCloseAttempt
|
|
1977
|
+
} = {}) {
|
|
1978
|
+
const { close: closeStandalonePanel } = usePanelActions();
|
|
1979
|
+
const closePanel = (0, import_react13.useMemo)(
|
|
1980
|
+
() => embedded ? onRequestClose ?? (async () => {
|
|
1981
|
+
}) : closeStandalonePanel,
|
|
1982
|
+
[embedded, onRequestClose, closeStandalonePanel]
|
|
1983
|
+
);
|
|
1991
1984
|
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = (0, import_editor_ui5.useDialog)();
|
|
1992
1985
|
const [isStopSyncSuppressed] = (0, import_editor_current_user2.useSuppressedMessage)(STOP_SYNC_MESSAGE_KEY);
|
|
1993
1986
|
const createMenuState = (0, import_ui14.usePopupState)({
|
|
@@ -2012,18 +2005,25 @@ function VariablesManagerPanel() {
|
|
|
2012
2005
|
} = useVariablesManagerState();
|
|
2013
2006
|
const { autoEditVariableId, startAutoEdit, handleAutoEditComplete } = useAutoEdit();
|
|
2014
2007
|
const { createNavigationCallback, resetNavigation } = useErrorNavigation();
|
|
2015
|
-
const [deleteConfirmation, setDeleteConfirmation] = (0,
|
|
2016
|
-
const [stopSyncConfirmation, setStopSyncConfirmation] = (0,
|
|
2017
|
-
const [serverError, setServerError] = (0,
|
|
2008
|
+
const [deleteConfirmation, setDeleteConfirmation] = (0, import_react13.useState)(null);
|
|
2009
|
+
const [stopSyncConfirmation, setStopSyncConfirmation] = (0, import_react13.useState)(null);
|
|
2010
|
+
const [serverError, setServerError] = (0, import_react13.useState)(null);
|
|
2018
2011
|
usePreventUnload(isDirty);
|
|
2019
|
-
const handleClosePanel = () => {
|
|
2012
|
+
const handleClosePanel = (0, import_react13.useCallback)(() => {
|
|
2020
2013
|
if (isDirty) {
|
|
2021
2014
|
openSaveChangesDialog();
|
|
2022
2015
|
return;
|
|
2023
2016
|
}
|
|
2024
|
-
closePanel();
|
|
2025
|
-
};
|
|
2026
|
-
|
|
2017
|
+
void closePanel();
|
|
2018
|
+
}, [isDirty, openSaveChangesDialog, closePanel]);
|
|
2019
|
+
(0, import_react13.useEffect)(() => {
|
|
2020
|
+
if (!embedded || !onExposeCloseAttempt) {
|
|
2021
|
+
return;
|
|
2022
|
+
}
|
|
2023
|
+
onExposeCloseAttempt(() => handleClosePanel());
|
|
2024
|
+
return () => onExposeCloseAttempt(null);
|
|
2025
|
+
}, [embedded, onExposeCloseAttempt, handleClosePanel]);
|
|
2026
|
+
const handleCreateVariable = (0, import_react13.useCallback)(
|
|
2027
2027
|
(type, defaultName, defaultValue) => {
|
|
2028
2028
|
const newId = createVariable2(type, defaultName, defaultValue);
|
|
2029
2029
|
if (newId) {
|
|
@@ -2057,14 +2057,14 @@ function VariablesManagerPanel() {
|
|
|
2057
2057
|
setIsSaving(false);
|
|
2058
2058
|
}
|
|
2059
2059
|
};
|
|
2060
|
-
const handleDeleteVariableWithConfirmation = (0,
|
|
2060
|
+
const handleDeleteVariableWithConfirmation = (0, import_react13.useCallback)(
|
|
2061
2061
|
(itemId) => {
|
|
2062
2062
|
handleDeleteVariable(itemId);
|
|
2063
2063
|
setDeleteConfirmation(null);
|
|
2064
2064
|
},
|
|
2065
2065
|
[handleDeleteVariable]
|
|
2066
2066
|
);
|
|
2067
|
-
const commitStopSync = (0,
|
|
2067
|
+
const commitStopSync = (0, import_react13.useCallback)(
|
|
2068
2068
|
(itemId) => {
|
|
2069
2069
|
stopSyncFromState(itemId);
|
|
2070
2070
|
const variable = variables[itemId];
|
|
@@ -2074,7 +2074,7 @@ function VariablesManagerPanel() {
|
|
|
2074
2074
|
},
|
|
2075
2075
|
[stopSyncFromState, variables]
|
|
2076
2076
|
);
|
|
2077
|
-
const handleStartSync = (0,
|
|
2077
|
+
const handleStartSync = (0, import_react13.useCallback)(
|
|
2078
2078
|
(itemId) => {
|
|
2079
2079
|
startSyncFromState(itemId);
|
|
2080
2080
|
const variable = variables[itemId];
|
|
@@ -2084,7 +2084,7 @@ function VariablesManagerPanel() {
|
|
|
2084
2084
|
},
|
|
2085
2085
|
[startSyncFromState, variables]
|
|
2086
2086
|
);
|
|
2087
|
-
const handleStopSync = (0,
|
|
2087
|
+
const handleStopSync = (0, import_react13.useCallback)(
|
|
2088
2088
|
(itemId) => {
|
|
2089
2089
|
if (!isStopSyncSuppressed) {
|
|
2090
2090
|
setStopSyncConfirmation(itemId);
|
|
@@ -2094,7 +2094,7 @@ function VariablesManagerPanel() {
|
|
|
2094
2094
|
},
|
|
2095
2095
|
[isStopSyncSuppressed, commitStopSync]
|
|
2096
2096
|
);
|
|
2097
|
-
const buildMenuActions = (0,
|
|
2097
|
+
const buildMenuActions = (0, import_react13.useCallback)(
|
|
2098
2098
|
(variableId) => {
|
|
2099
2099
|
const variable = variables[variableId];
|
|
2100
2100
|
if (!variable) {
|
|
@@ -2140,82 +2140,57 @@ function VariablesManagerPanel() {
|
|
|
2140
2140
|
[variables, handleStartSync, handleStopSync, duplicateVariable, startAutoEdit]
|
|
2141
2141
|
);
|
|
2142
2142
|
const hasVariables = Object.keys(variables).length > 0;
|
|
2143
|
-
|
|
2144
|
-
|
|
2143
|
+
const variablesSearchFieldSx = embedded ? {
|
|
2144
|
+
flex: 1,
|
|
2145
|
+
minWidth: 0,
|
|
2146
|
+
px: 0,
|
|
2147
|
+
py: 0,
|
|
2148
|
+
display: "flex",
|
|
2149
|
+
alignItems: "center",
|
|
2150
|
+
alignSelf: "stretch"
|
|
2151
|
+
} : {
|
|
2152
|
+
display: "flex",
|
|
2153
|
+
flex: 1
|
|
2154
|
+
};
|
|
2155
|
+
const searchField = /* @__PURE__ */ React14.createElement(
|
|
2156
|
+
import_editor_ui5.SearchField,
|
|
2145
2157
|
{
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
variables,
|
|
2155
|
-
menuState: createMenuState
|
|
2156
|
-
}
|
|
2157
|
-
), /* @__PURE__ */ React14.createElement(
|
|
2158
|
-
import_ui14.CloseButton,
|
|
2159
|
-
{
|
|
2160
|
-
"aria-label": "Close",
|
|
2161
|
-
slotProps: { icon: { fontSize: SIZE } },
|
|
2162
|
-
onClick: () => {
|
|
2163
|
-
handleClosePanel();
|
|
2164
|
-
}
|
|
2165
|
-
}
|
|
2166
|
-
))), /* @__PURE__ */ React14.createElement(import_ui14.Stack, { width: "100%", direction: "row", gap: 1 }, /* @__PURE__ */ React14.createElement(
|
|
2167
|
-
import_editor_ui5.SearchField,
|
|
2168
|
-
{
|
|
2169
|
-
sx: {
|
|
2170
|
-
display: "flex",
|
|
2171
|
-
flex: 1
|
|
2172
|
-
},
|
|
2173
|
-
placeholder: (0, import_i18n10.__)("Search", "elementor"),
|
|
2174
|
-
value: searchValue,
|
|
2175
|
-
onSearch: handleSearch
|
|
2176
|
-
}
|
|
2177
|
-
)), /* @__PURE__ */ React14.createElement(import_ui14.Divider, { sx: { width: "100%" } }))
|
|
2178
|
-
), /* @__PURE__ */ React14.createElement(
|
|
2179
|
-
import_editor_panels.PanelBody,
|
|
2158
|
+
placeholder: (0, import_i18n10.__)("Search", "elementor"),
|
|
2159
|
+
value: searchValue,
|
|
2160
|
+
onSearch: handleSearch,
|
|
2161
|
+
sx: variablesSearchFieldSx
|
|
2162
|
+
}
|
|
2163
|
+
);
|
|
2164
|
+
const bodyInner = /* @__PURE__ */ React14.createElement(React14.Fragment, null, hasVariables && /* @__PURE__ */ React14.createElement(
|
|
2165
|
+
VariablesManagerTable,
|
|
2180
2166
|
{
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
{
|
|
2209
|
-
title: (0, import_i18n10.__)("Create your first variable", "elementor"),
|
|
2210
|
-
message: (0, import_i18n10.__)(
|
|
2211
|
-
"Variables are saved attributes that you can apply anywhere on your site.",
|
|
2212
|
-
"elementor"
|
|
2213
|
-
),
|
|
2214
|
-
icon: /* @__PURE__ */ React14.createElement(import_icons5.ColorFilterIcon, { fontSize: "large" }),
|
|
2215
|
-
onAdd: createMenuState.open
|
|
2216
|
-
}
|
|
2217
|
-
)
|
|
2218
|
-
), /* @__PURE__ */ React14.createElement(import_editor_panels.PanelFooter, null, /* @__PURE__ */ React14.createElement(
|
|
2167
|
+
menuActions: buildMenuActions,
|
|
2168
|
+
variables,
|
|
2169
|
+
onChange: handleOnChange,
|
|
2170
|
+
autoEditVariableId,
|
|
2171
|
+
onAutoEditComplete: handleAutoEditComplete,
|
|
2172
|
+
onFieldError: setIsSaveDisabled
|
|
2173
|
+
}
|
|
2174
|
+
), !hasVariables && searchValue && /* @__PURE__ */ React14.createElement(
|
|
2175
|
+
NoSearchResults,
|
|
2176
|
+
{
|
|
2177
|
+
searchValue,
|
|
2178
|
+
onClear: () => handleSearch(""),
|
|
2179
|
+
icon: /* @__PURE__ */ React14.createElement(import_icons5.ColorFilterIcon, { fontSize: "large" })
|
|
2180
|
+
}
|
|
2181
|
+
), !hasVariables && !searchValue && /* @__PURE__ */ React14.createElement(
|
|
2182
|
+
EmptyState,
|
|
2183
|
+
{
|
|
2184
|
+
title: (0, import_i18n10.__)("Create your first variable", "elementor"),
|
|
2185
|
+
message: (0, import_i18n10.__)(
|
|
2186
|
+
"Variables are saved attributes that you can apply anywhere on your site.",
|
|
2187
|
+
"elementor"
|
|
2188
|
+
),
|
|
2189
|
+
icon: /* @__PURE__ */ React14.createElement(import_icons5.ColorFilterIcon, { fontSize: "large" }),
|
|
2190
|
+
onAdd: createMenuState.open
|
|
2191
|
+
}
|
|
2192
|
+
));
|
|
2193
|
+
const saveFooter = /* @__PURE__ */ React14.createElement(import_editor_panels.PanelFooter, null, /* @__PURE__ */ React14.createElement(
|
|
2219
2194
|
import_ui14.Infotip,
|
|
2220
2195
|
{
|
|
2221
2196
|
placement: "right",
|
|
@@ -2259,7 +2234,8 @@ function VariablesManagerPanel() {
|
|
|
2259
2234
|
},
|
|
2260
2235
|
(0, import_i18n10.__)("Save changes", "elementor")
|
|
2261
2236
|
)
|
|
2262
|
-
))
|
|
2237
|
+
));
|
|
2238
|
+
const dialogs = /* @__PURE__ */ React14.createElement(React14.Fragment, null, deleteConfirmation && /* @__PURE__ */ React14.createElement(
|
|
2263
2239
|
DeleteConfirmationDialog,
|
|
2264
2240
|
{
|
|
2265
2241
|
open: true,
|
|
@@ -2285,7 +2261,7 @@ function VariablesManagerPanel() {
|
|
|
2285
2261
|
label: (0, import_i18n10.__)("Discard", "elementor"),
|
|
2286
2262
|
action: () => {
|
|
2287
2263
|
closeSaveChangesDialog();
|
|
2288
|
-
closePanel();
|
|
2264
|
+
void closePanel();
|
|
2289
2265
|
}
|
|
2290
2266
|
},
|
|
2291
2267
|
confirm: {
|
|
@@ -2294,16 +2270,104 @@ function VariablesManagerPanel() {
|
|
|
2294
2270
|
const result = await handleSaveClick();
|
|
2295
2271
|
closeSaveChangesDialog();
|
|
2296
2272
|
if (result?.success) {
|
|
2297
|
-
closePanel();
|
|
2273
|
+
void closePanel();
|
|
2298
2274
|
}
|
|
2299
2275
|
}
|
|
2300
2276
|
}
|
|
2301
2277
|
}
|
|
2302
2278
|
}
|
|
2303
2279
|
)));
|
|
2280
|
+
const panelChrome = embedded ? /* @__PURE__ */ React14.createElement(
|
|
2281
|
+
import_ui14.Stack,
|
|
2282
|
+
{
|
|
2283
|
+
direction: "column",
|
|
2284
|
+
sx: {
|
|
2285
|
+
height: "100%",
|
|
2286
|
+
width: "100%",
|
|
2287
|
+
flex: 1,
|
|
2288
|
+
minHeight: 0,
|
|
2289
|
+
overflow: "hidden"
|
|
2290
|
+
}
|
|
2291
|
+
},
|
|
2292
|
+
/* @__PURE__ */ React14.createElement(
|
|
2293
|
+
import_ui14.Stack,
|
|
2294
|
+
{
|
|
2295
|
+
direction: "row",
|
|
2296
|
+
alignItems: "center",
|
|
2297
|
+
spacing: 1,
|
|
2298
|
+
width: "100%",
|
|
2299
|
+
sx: {
|
|
2300
|
+
flexShrink: 0,
|
|
2301
|
+
px: 2,
|
|
2302
|
+
pb: 1
|
|
2303
|
+
}
|
|
2304
|
+
},
|
|
2305
|
+
searchField,
|
|
2306
|
+
/* @__PURE__ */ React14.createElement(import_ui14.Box, { sx: { display: "flex", flexShrink: 0, alignItems: "center" } }, /* @__PURE__ */ React14.createElement(
|
|
2307
|
+
VariableManagerCreateMenu,
|
|
2308
|
+
{
|
|
2309
|
+
outlinedTrigger: true,
|
|
2310
|
+
onCreate: handleCreateVariable,
|
|
2311
|
+
variables,
|
|
2312
|
+
menuState: createMenuState
|
|
2313
|
+
}
|
|
2314
|
+
))
|
|
2315
|
+
),
|
|
2316
|
+
/* @__PURE__ */ React14.createElement(import_ui14.Divider, { sx: { width: "100%" } }),
|
|
2317
|
+
/* @__PURE__ */ React14.createElement(
|
|
2318
|
+
import_editor_panels.PanelBody,
|
|
2319
|
+
{
|
|
2320
|
+
sx: {
|
|
2321
|
+
display: "flex",
|
|
2322
|
+
flexDirection: "column",
|
|
2323
|
+
flex: 1,
|
|
2324
|
+
minHeight: 0,
|
|
2325
|
+
overflow: "hidden"
|
|
2326
|
+
}
|
|
2327
|
+
},
|
|
2328
|
+
bodyInner
|
|
2329
|
+
),
|
|
2330
|
+
saveFooter
|
|
2331
|
+
) : /* @__PURE__ */ React14.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React14.createElement(
|
|
2332
|
+
import_editor_panels.PanelHeader,
|
|
2333
|
+
{
|
|
2334
|
+
sx: {
|
|
2335
|
+
height: "unset"
|
|
2336
|
+
}
|
|
2337
|
+
},
|
|
2338
|
+
/* @__PURE__ */ React14.createElement(import_ui14.Stack, { width: "100%", direction: "column", alignItems: "center" }, /* @__PURE__ */ React14.createElement(import_ui14.Stack, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React14.createElement(import_ui14.Stack, { width: "100%", direction: "row", gap: 1 }, /* @__PURE__ */ React14.createElement(import_editor_panels.PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React14.createElement(import_icons5.ColorFilterIcon, { fontSize: "inherit" }), (0, import_i18n10.__)("Variables Manager", "elementor"))), /* @__PURE__ */ React14.createElement(import_ui14.Stack, { direction: "row", gap: 0.5, alignItems: "center" }, /* @__PURE__ */ React14.createElement(
|
|
2339
|
+
VariableManagerCreateMenu,
|
|
2340
|
+
{
|
|
2341
|
+
onCreate: handleCreateVariable,
|
|
2342
|
+
variables,
|
|
2343
|
+
menuState: createMenuState
|
|
2344
|
+
}
|
|
2345
|
+
), /* @__PURE__ */ React14.createElement(
|
|
2346
|
+
import_ui14.CloseButton,
|
|
2347
|
+
{
|
|
2348
|
+
"aria-label": "Close",
|
|
2349
|
+
slotProps: { icon: { fontSize: SIZE } },
|
|
2350
|
+
onClick: () => {
|
|
2351
|
+
handleClosePanel();
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2354
|
+
))), /* @__PURE__ */ React14.createElement(import_ui14.Stack, { width: "100%", direction: "row", gap: 1 }, searchField), /* @__PURE__ */ React14.createElement(import_ui14.Divider, { sx: { width: "100%" } }))
|
|
2355
|
+
), /* @__PURE__ */ React14.createElement(
|
|
2356
|
+
import_editor_panels.PanelBody,
|
|
2357
|
+
{
|
|
2358
|
+
sx: {
|
|
2359
|
+
display: "flex",
|
|
2360
|
+
flexDirection: "column",
|
|
2361
|
+
height: "100%"
|
|
2362
|
+
}
|
|
2363
|
+
},
|
|
2364
|
+
bodyInner
|
|
2365
|
+
), saveFooter);
|
|
2366
|
+
const core = /* @__PURE__ */ React14.createElement(React14.Fragment, null, panelChrome, dialogs);
|
|
2367
|
+
return embedded ? core : /* @__PURE__ */ React14.createElement(import_editor_ui5.ThemeProvider, null, core);
|
|
2304
2368
|
}
|
|
2305
2369
|
var usePreventUnload = (isDirty) => {
|
|
2306
|
-
(0,
|
|
2370
|
+
(0, import_react13.useEffect)(() => {
|
|
2307
2371
|
const handleBeforeUnload = (event) => {
|
|
2308
2372
|
if (isDirty) {
|
|
2309
2373
|
event.preventDefault();
|
|
@@ -2334,7 +2398,41 @@ var StopSyncConfirmationDialog = ({ open, onClose, onConfirm }) => {
|
|
|
2334
2398
|
));
|
|
2335
2399
|
};
|
|
2336
2400
|
|
|
2401
|
+
// src/init.ts
|
|
2402
|
+
var import_editor = require("@elementor/editor");
|
|
2403
|
+
var import_editor_controls18 = require("@elementor/editor-controls");
|
|
2404
|
+
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
2405
|
+
var import_editor_panels2 = require("@elementor/editor-panels");
|
|
2406
|
+
var import_editor_props10 = require("@elementor/editor-props");
|
|
2407
|
+
var import_editor_v1_adapters8 = require("@elementor/editor-v1-adapters");
|
|
2408
|
+
var import_menus = require("@elementor/menus");
|
|
2409
|
+
|
|
2410
|
+
// src/components/global-styles-import-listener.tsx
|
|
2411
|
+
var import_react14 = require("react");
|
|
2412
|
+
var import_editor_canvas4 = require("@elementor/editor-canvas");
|
|
2413
|
+
function GlobalStylesImportListener() {
|
|
2414
|
+
(0, import_react14.useEffect)(() => {
|
|
2415
|
+
const handleGlobalStylesImported = (event) => {
|
|
2416
|
+
const importedVars = event.detail?.global_variables;
|
|
2417
|
+
if (!importedVars) {
|
|
2418
|
+
return;
|
|
2419
|
+
}
|
|
2420
|
+
if (importedVars.data && typeof importedVars.data === "object") {
|
|
2421
|
+
styleVariablesRepository.update(importedVars.data);
|
|
2422
|
+
}
|
|
2423
|
+
service.load();
|
|
2424
|
+
};
|
|
2425
|
+
window.addEventListener(import_editor_canvas4.GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported);
|
|
2426
|
+
return () => {
|
|
2427
|
+
window.removeEventListener(import_editor_canvas4.GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported);
|
|
2428
|
+
};
|
|
2429
|
+
}, []);
|
|
2430
|
+
return null;
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2337
2433
|
// src/components/open-panel-from-event.tsx
|
|
2434
|
+
var import_react15 = require("react");
|
|
2435
|
+
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
2338
2436
|
var EVENT_NAME = "elementor/open-variables-manager";
|
|
2339
2437
|
var DEFAULT_PANEL_ROUTE = "panel/elements/categories";
|
|
2340
2438
|
function OpenPanelFromEvent() {
|
|
@@ -3155,9 +3253,15 @@ var VIEW_EDIT = "edit";
|
|
|
3155
3253
|
var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
|
|
3156
3254
|
const [currentView, setCurrentView] = (0, import_react22.useState)(VIEW_LIST);
|
|
3157
3255
|
const [editId, setEditId] = (0, import_react22.useState)("");
|
|
3158
|
-
const { open } = usePanelActions();
|
|
3256
|
+
const { open: openStandaloneVariablesPanel } = usePanelActions();
|
|
3159
3257
|
const onSettingsAvailable = (0, import_editor_v1_adapters5.isExperimentActive)("e_variables_manager") ? () => {
|
|
3160
|
-
|
|
3258
|
+
if ((0, import_editor_v1_adapters5.isExperimentActive)("e_editor_design_system_panel")) {
|
|
3259
|
+
window.dispatchEvent(
|
|
3260
|
+
new CustomEvent("elementor/toggle-design-system", { detail: { tab: "variables" } })
|
|
3261
|
+
);
|
|
3262
|
+
} else {
|
|
3263
|
+
openStandaloneVariablesPanel();
|
|
3264
|
+
}
|
|
3161
3265
|
} : void 0;
|
|
3162
3266
|
return /* @__PURE__ */ React22.createElement(VariableTypeProvider, { propTypeKey }, /* @__PURE__ */ React22.createElement(PopoverContentRefContextProvider, null, RenderView({
|
|
3163
3267
|
propTypeKey,
|
|
@@ -3172,7 +3276,7 @@ var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable })
|
|
|
3172
3276
|
};
|
|
3173
3277
|
function RenderView(props) {
|
|
3174
3278
|
const userPermissions = usePermissions();
|
|
3175
|
-
const
|
|
3279
|
+
const userQuotaPermissions = useQuotaPermissions(props.propTypeKey);
|
|
3176
3280
|
const handlers = {
|
|
3177
3281
|
onClose: () => {
|
|
3178
3282
|
props.closePopover();
|
|
@@ -3213,7 +3317,7 @@ function RenderView(props) {
|
|
|
3213
3317
|
onAdd: handlers.onAdd,
|
|
3214
3318
|
onEdit: handlers.onEdit,
|
|
3215
3319
|
onSettings: handlers.onSettings,
|
|
3216
|
-
disabled: !
|
|
3320
|
+
disabled: !userQuotaPermissions.canAdd()
|
|
3217
3321
|
}
|
|
3218
3322
|
);
|
|
3219
3323
|
}
|
|
@@ -3818,33 +3922,42 @@ var trackOpenVariablePopover = (path, variableType) => {
|
|
|
3818
3922
|
var import_schema3 = require("@elementor/schema");
|
|
3819
3923
|
|
|
3820
3924
|
// src/mcp/variables-resource.ts
|
|
3925
|
+
var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
|
|
3821
3926
|
var GLOBAL_VARIABLES_URI = "elementor://global-variables";
|
|
3927
|
+
var buildGlobalVariablesPayload = async () => {
|
|
3928
|
+
const merged = {};
|
|
3929
|
+
Object.entries(service.variables()).forEach(([id2, variable]) => {
|
|
3930
|
+
if (!variable.deleted) {
|
|
3931
|
+
merged[id2] = { ...variable, version: "v4" };
|
|
3932
|
+
}
|
|
3933
|
+
});
|
|
3934
|
+
return merged;
|
|
3935
|
+
};
|
|
3822
3936
|
var initVariablesResource = (variablesMcpEntry, canvasMcpEntry) => {
|
|
3823
3937
|
[canvasMcpEntry, variablesMcpEntry].forEach((entry) => {
|
|
3824
3938
|
const { resource, sendResourceUpdated } = entry;
|
|
3939
|
+
const notifyGlobalVariablesUpdated = () => {
|
|
3940
|
+
sendResourceUpdated({
|
|
3941
|
+
uri: GLOBAL_VARIABLES_URI
|
|
3942
|
+
});
|
|
3943
|
+
};
|
|
3825
3944
|
resource(
|
|
3826
3945
|
"global-variables",
|
|
3827
3946
|
GLOBAL_VARIABLES_URI,
|
|
3828
3947
|
{
|
|
3829
|
-
description: "
|
|
3948
|
+
description: "Global variables available (v4)"
|
|
3830
3949
|
},
|
|
3831
3950
|
async () => {
|
|
3832
|
-
const variables =
|
|
3833
|
-
Object.entries(service.variables()).forEach(([id2, variable]) => {
|
|
3834
|
-
if (!variable.deleted) {
|
|
3835
|
-
variables[id2] = variable;
|
|
3836
|
-
}
|
|
3837
|
-
});
|
|
3951
|
+
const variables = await buildGlobalVariablesPayload();
|
|
3838
3952
|
return {
|
|
3839
|
-
contents: [
|
|
3953
|
+
contents: [
|
|
3954
|
+
{ uri: GLOBAL_VARIABLES_URI, mimeType: "application/json", text: JSON.stringify(variables) }
|
|
3955
|
+
]
|
|
3840
3956
|
};
|
|
3841
3957
|
}
|
|
3842
3958
|
);
|
|
3843
|
-
window.addEventListener("variables:updated",
|
|
3844
|
-
|
|
3845
|
-
uri: GLOBAL_VARIABLES_URI
|
|
3846
|
-
});
|
|
3847
|
-
});
|
|
3959
|
+
window.addEventListener("variables:updated", notifyGlobalVariablesUpdated);
|
|
3960
|
+
(0, import_editor_v1_adapters6.__privateListenTo)((0, import_editor_v1_adapters6.commandEndEvent)("document/save/update"), notifyGlobalVariablesUpdated);
|
|
3848
3961
|
});
|
|
3849
3962
|
};
|
|
3850
3963
|
|
|
@@ -3903,12 +4016,20 @@ function getServiceActions(svc) {
|
|
|
3903
4016
|
if (!type || !label || !value) {
|
|
3904
4017
|
throw new Error("Create requires type, label, and value");
|
|
3905
4018
|
}
|
|
4019
|
+
const labelError = validateLabel(label);
|
|
4020
|
+
if (labelError) {
|
|
4021
|
+
throw new Error(labelError);
|
|
4022
|
+
}
|
|
3906
4023
|
return svc.create({ type, label, value });
|
|
3907
4024
|
},
|
|
3908
4025
|
update({ id: id2, label, value }) {
|
|
3909
4026
|
if (!id2 || !label || !value) {
|
|
3910
4027
|
throw new Error("Update requires id, label, and value");
|
|
3911
4028
|
}
|
|
4029
|
+
const labelError = validateLabel(label);
|
|
4030
|
+
if (labelError) {
|
|
4031
|
+
throw new Error(labelError);
|
|
4032
|
+
}
|
|
3912
4033
|
return svc.update(id2, { label, value });
|
|
3913
4034
|
},
|
|
3914
4035
|
delete({ id: id2 }) {
|
|
@@ -4063,8 +4184,8 @@ var import_schema4 = require("@elementor/schema");
|
|
|
4063
4184
|
var sizeVariablePropTypeUtil = (0, import_editor_props4.createPropUtils)("global-size-variable", import_schema4.z.string());
|
|
4064
4185
|
|
|
4065
4186
|
// src/transformers/empty-transformer.tsx
|
|
4066
|
-
var
|
|
4067
|
-
var EmptyTransformer = (0,
|
|
4187
|
+
var import_editor_canvas5 = require("@elementor/editor-canvas");
|
|
4188
|
+
var EmptyTransformer = (0, import_editor_canvas5.createTransformer)((_value) => {
|
|
4068
4189
|
return null;
|
|
4069
4190
|
});
|
|
4070
4191
|
|
|
@@ -4139,7 +4260,7 @@ function registerVariableTypes() {
|
|
|
4139
4260
|
// src/renderers/style-variables-renderer.tsx
|
|
4140
4261
|
var React38 = __toESM(require("react"));
|
|
4141
4262
|
var import_react30 = require("react");
|
|
4142
|
-
var
|
|
4263
|
+
var import_editor_v1_adapters7 = require("@elementor/editor-v1-adapters");
|
|
4143
4264
|
var import_ui35 = require("@elementor/ui");
|
|
4144
4265
|
var VARIABLES_WRAPPER = ":root";
|
|
4145
4266
|
function StyleVariablesRenderer() {
|
|
@@ -4154,7 +4275,7 @@ function StyleVariablesRenderer() {
|
|
|
4154
4275
|
return /* @__PURE__ */ React38.createElement(import_ui35.Portal, { container }, /* @__PURE__ */ React38.createElement("style", { "data-e-style-id": "e-variables", key: wrappedCss }, wrappedCss));
|
|
4155
4276
|
}
|
|
4156
4277
|
function usePortalContainer() {
|
|
4157
|
-
return (0,
|
|
4278
|
+
return (0, import_editor_v1_adapters7.__privateUseListenTo)((0, import_editor_v1_adapters7.commandEndEvent)("editor/documents/attach-preview"), () => (0, import_editor_v1_adapters7.getCanvasIframeDocument)()?.head);
|
|
4158
4279
|
}
|
|
4159
4280
|
function useStyleVariables() {
|
|
4160
4281
|
const [variables, setVariables] = (0, import_react30.useState)({});
|
|
@@ -4272,6 +4393,20 @@ var BoxShadowRepeaterLabel = ({ value }) => {
|
|
|
4272
4393
|
const positionLabel = position?.value || "outset";
|
|
4273
4394
|
return /* @__PURE__ */ React39.createElement(import_ui36.Box, { component: "span", style: { textTransform: "capitalize" } }, positionLabel, ": ", labels.join(" "));
|
|
4274
4395
|
};
|
|
4396
|
+
var TransformRepeaterLabel = ({ value }) => {
|
|
4397
|
+
const labels = [];
|
|
4398
|
+
if (import_editor_props8.moveTransformPropTypeUtil.isValid(value)) {
|
|
4399
|
+
labels.push((0, import_i18n27.__)("Move:", "elementor"));
|
|
4400
|
+
const { x, y, z: z6 } = import_editor_props8.moveTransformPropTypeUtil.extract(value) || {};
|
|
4401
|
+
for (const val of [x, y, z6]) {
|
|
4402
|
+
const rendered = sizeValue(val);
|
|
4403
|
+
if (rendered) {
|
|
4404
|
+
labels.push(rendered);
|
|
4405
|
+
}
|
|
4406
|
+
}
|
|
4407
|
+
}
|
|
4408
|
+
return /* @__PURE__ */ React39.createElement(import_ui36.Box, { component: "span" }, labels.join(" "));
|
|
4409
|
+
};
|
|
4275
4410
|
var TransitionsSizeVariableLabel = ({ value: prop }) => {
|
|
4276
4411
|
let label = "";
|
|
4277
4412
|
const variableId = prop?.value?.size?.value || "";
|
|
@@ -4291,6 +4426,7 @@ function registerRepeaterInjections() {
|
|
|
4291
4426
|
backgroundOverlayRepeaterInjections();
|
|
4292
4427
|
boxShadowRepeaterInjections();
|
|
4293
4428
|
transitionsRepeaterInjections();
|
|
4429
|
+
transformRepeaterInjections();
|
|
4294
4430
|
filterRepeaterInjections();
|
|
4295
4431
|
}
|
|
4296
4432
|
function backgroundOverlayRepeaterInjections() {
|
|
@@ -4327,6 +4463,19 @@ function boxShadowRepeaterInjections() {
|
|
|
4327
4463
|
}
|
|
4328
4464
|
});
|
|
4329
4465
|
}
|
|
4466
|
+
function transformRepeaterInjections() {
|
|
4467
|
+
(0, import_editor_controls17.injectIntoRepeaterItemLabel)({
|
|
4468
|
+
id: "transform-size-variables-label",
|
|
4469
|
+
component: TransformRepeaterLabel,
|
|
4470
|
+
condition: ({ value }) => {
|
|
4471
|
+
if (import_editor_props9.moveTransformPropTypeUtil.isValid(value)) {
|
|
4472
|
+
const { x: xAxis, y: yAxis, z: zAxis } = import_editor_props9.moveTransformPropTypeUtil.extract(value) || {};
|
|
4473
|
+
return hasAssignedSizeVariable(xAxis) || hasAssignedSizeVariable(yAxis) || hasAssignedSizeVariable(zAxis);
|
|
4474
|
+
}
|
|
4475
|
+
return false;
|
|
4476
|
+
}
|
|
4477
|
+
});
|
|
4478
|
+
}
|
|
4330
4479
|
function transitionsRepeaterInjections() {
|
|
4331
4480
|
(0, import_editor_controls17.injectIntoRepeaterItemLabel)({
|
|
4332
4481
|
id: "transition-size-variables-label",
|
|
@@ -4424,15 +4573,17 @@ function init() {
|
|
|
4424
4573
|
id: "variables-import-listener",
|
|
4425
4574
|
component: GlobalStylesImportListener
|
|
4426
4575
|
});
|
|
4427
|
-
(0,
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4576
|
+
if (!(0, import_editor_v1_adapters8.isExperimentActive)("e_editor_design_system_panel")) {
|
|
4577
|
+
(0, import_editor.injectIntoLogic)({
|
|
4578
|
+
id: "variables-open-panel-from-url",
|
|
4579
|
+
component: OpenPanelFromUrl
|
|
4580
|
+
});
|
|
4581
|
+
(0, import_editor.injectIntoLogic)({
|
|
4582
|
+
id: "variables-open-panel-from-event",
|
|
4583
|
+
component: OpenPanelFromEvent
|
|
4584
|
+
});
|
|
4585
|
+
(0, import_editor_panels2.__registerPanel)(panel);
|
|
4586
|
+
}
|
|
4436
4587
|
}
|
|
4437
4588
|
function hasVariableAssigned(value) {
|
|
4438
4589
|
if ((0, import_editor_props10.isTransformable)(value)) {
|
|
@@ -4463,6 +4614,7 @@ var Utils = {
|
|
|
4463
4614
|
0 && (module.exports = {
|
|
4464
4615
|
GLOBAL_VARIABLES_URI,
|
|
4465
4616
|
Utils,
|
|
4617
|
+
VariablesManagerPanelEmbedded,
|
|
4466
4618
|
getMenuActionsForVariable,
|
|
4467
4619
|
hasVariable,
|
|
4468
4620
|
init,
|