@elementor/editor-variables 4.1.0-825 → 4.1.0-826
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 +19 -3
- package/dist/index.d.ts +19 -3
- package/dist/index.js +533 -424
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +500 -391
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/variable-selection-popover.tsx +8 -2
- 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/index.ts +4 -0
- package/src/init.ts +12 -9
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,20 +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
|
+
};
|
|
113
|
+
|
|
114
|
+
// src/utils/validations.ts
|
|
115
|
+
var import_icons = require("@elementor/icons");
|
|
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"));
|
|
55
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());
|
|
56
230
|
|
|
57
231
|
// src/service.ts
|
|
58
|
-
var
|
|
232
|
+
var import_i18n2 = require("@wordpress/i18n");
|
|
59
233
|
|
|
60
234
|
// src/api.ts
|
|
61
235
|
var import_http_client = require("@elementor/http-client");
|
|
@@ -220,9 +394,9 @@ var Storage = class {
|
|
|
220
394
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
221
395
|
|
|
222
396
|
// src/prop-types/font-variable-prop-type.ts
|
|
223
|
-
var
|
|
224
|
-
var
|
|
225
|
-
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());
|
|
226
400
|
|
|
227
401
|
// src/create-style-variables-repository.ts
|
|
228
402
|
var createStyleVariablesRepository = () => {
|
|
@@ -334,7 +508,7 @@ var service = {
|
|
|
334
508
|
return apiClient.create(type, label, value).then((response) => {
|
|
335
509
|
const { success, data: payload } = response.data;
|
|
336
510
|
if (!success) {
|
|
337
|
-
const errorMessage = payload?.message || (0,
|
|
511
|
+
const errorMessage = payload?.message || (0, import_i18n2.__)("Unexpected response from server", "elementor");
|
|
338
512
|
throw new Error(errorMessage);
|
|
339
513
|
}
|
|
340
514
|
return payload;
|
|
@@ -356,7 +530,7 @@ var service = {
|
|
|
356
530
|
return apiClient.update(id2, label, value, type).then((response) => {
|
|
357
531
|
const { success, data: payload } = response.data;
|
|
358
532
|
if (!success) {
|
|
359
|
-
const errorMessage = payload?.message || (0,
|
|
533
|
+
const errorMessage = payload?.message || (0, import_i18n2.__)("Unexpected response from server", "elementor");
|
|
360
534
|
throw new Error(errorMessage);
|
|
361
535
|
}
|
|
362
536
|
return payload;
|
|
@@ -431,250 +605,40 @@ var service = {
|
|
|
431
605
|
if (!success) {
|
|
432
606
|
throw new Error("Unexpected response from server");
|
|
433
607
|
}
|
|
434
|
-
return payload;
|
|
435
|
-
}).then((data) => {
|
|
436
|
-
const { results, watermark } = data;
|
|
437
|
-
handleWatermark(OP_RW, watermark);
|
|
438
|
-
if (results) {
|
|
439
|
-
results.forEach((result) => {
|
|
440
|
-
const variableId = result.id;
|
|
441
|
-
if (result.variable) {
|
|
442
|
-
if (result.type === "create") {
|
|
443
|
-
storage.add(variableId, result.variable);
|
|
444
|
-
} else {
|
|
445
|
-
storage.update(variableId, result.variable);
|
|
446
|
-
}
|
|
447
|
-
styleVariablesRepository.update({
|
|
448
|
-
[variableId]: result.variable
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
});
|
|
452
|
-
}
|
|
453
|
-
return {
|
|
454
|
-
success: true,
|
|
455
|
-
watermark,
|
|
456
|
-
operations: operations.length
|
|
457
|
-
};
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
var handleWatermark = (operation, newWatermark) => {
|
|
462
|
-
if (storage.watermarkDiff(operation, newWatermark)) {
|
|
463
|
-
setTimeout(() => service.load(), 500);
|
|
464
|
-
}
|
|
465
|
-
storage.watermark(newWatermark);
|
|
466
|
-
};
|
|
467
|
-
|
|
468
|
-
// src/components/global-styles-import-listener.tsx
|
|
469
|
-
function GlobalStylesImportListener() {
|
|
470
|
-
(0, import_react.useEffect)(() => {
|
|
471
|
-
const handleGlobalStylesImported = (event) => {
|
|
472
|
-
const importedVars = event.detail?.global_variables;
|
|
473
|
-
if (!importedVars) {
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
|
-
if (importedVars.data && typeof importedVars.data === "object") {
|
|
477
|
-
styleVariablesRepository.update(importedVars.data);
|
|
478
|
-
}
|
|
479
|
-
service.load();
|
|
480
|
-
};
|
|
481
|
-
window.addEventListener(import_editor_canvas.GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported);
|
|
482
|
-
return () => {
|
|
483
|
-
window.removeEventListener(import_editor_canvas.GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported);
|
|
484
|
-
};
|
|
485
|
-
}, []);
|
|
486
|
-
return null;
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
// src/components/open-panel-from-event.tsx
|
|
490
|
-
var import_react15 = require("react");
|
|
491
|
-
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
492
|
-
|
|
493
|
-
// src/components/variables-manager/variables-manager-panel.tsx
|
|
494
|
-
var React14 = __toESM(require("react"));
|
|
495
|
-
var import_react14 = require("react");
|
|
496
|
-
var import_editor_current_user2 = require("@elementor/editor-current-user");
|
|
497
|
-
var import_editor_panels = require("@elementor/editor-panels");
|
|
498
|
-
var import_editor_ui5 = require("@elementor/editor-ui");
|
|
499
|
-
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
500
|
-
var import_icons5 = require("@elementor/icons");
|
|
501
|
-
var import_ui14 = require("@elementor/ui");
|
|
502
|
-
var import_i18n10 = require("@wordpress/i18n");
|
|
503
|
-
|
|
504
|
-
// src/utils/tracking.ts
|
|
505
|
-
var import_events = require("@elementor/events");
|
|
506
|
-
var trackVariableEvent = ({ varType, controlPath, action }) => {
|
|
507
|
-
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
508
|
-
if (!config?.names?.variables?.[action]) {
|
|
509
|
-
return;
|
|
510
|
-
}
|
|
511
|
-
const name = config.names.variables[action];
|
|
512
|
-
dispatchEvent?.(name, {
|
|
513
|
-
location: config?.locations?.variables || "",
|
|
514
|
-
secondaryLocation: config?.secondaryLocations?.variablesPopover || "",
|
|
515
|
-
trigger: config?.triggers?.click || "",
|
|
516
|
-
var_type: varType,
|
|
517
|
-
control_path: controlPath,
|
|
518
|
-
action_type: name
|
|
519
|
-
});
|
|
520
|
-
};
|
|
521
|
-
var trackVariablesManagerEvent = ({ action, varType, controlPath }) => {
|
|
522
|
-
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
523
|
-
if (!config?.names?.variables?.[action]) {
|
|
524
|
-
return;
|
|
525
|
-
}
|
|
526
|
-
const name = config.names.variables[action];
|
|
527
|
-
const eventData = {
|
|
528
|
-
location: config?.locations?.variablesManager || "",
|
|
529
|
-
trigger: config?.triggers?.click || "",
|
|
530
|
-
action_type: name
|
|
531
|
-
};
|
|
532
|
-
if (varType) {
|
|
533
|
-
eventData.var_type = varType;
|
|
534
|
-
}
|
|
535
|
-
if (controlPath) {
|
|
536
|
-
eventData.style_control_path = controlPath;
|
|
537
|
-
}
|
|
538
|
-
dispatchEvent?.(name, eventData);
|
|
539
|
-
};
|
|
540
|
-
var trackVariableSyncToV3 = ({ variableLabel, action }) => {
|
|
541
|
-
try {
|
|
542
|
-
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
543
|
-
if (!config?.names?.variables?.variableSyncToV3) {
|
|
544
|
-
return;
|
|
545
|
-
}
|
|
546
|
-
const name = config.names.variables.variableSyncToV3;
|
|
547
|
-
const isSync = action === "sync";
|
|
548
|
-
dispatchEvent?.(name, {
|
|
549
|
-
interaction_type: "click",
|
|
550
|
-
target_type: variableLabel,
|
|
551
|
-
target_name: isSync ? "sync_to_v3" : "unsync_to_v3",
|
|
552
|
-
interaction_result: isSync ? "var_is_synced_to_V3" : "var_is_unsynced_from_V3",
|
|
553
|
-
target_location: "widget_panel",
|
|
554
|
-
location_l1: "var_manager",
|
|
555
|
-
interaction_description: isSync ? `user_synced_${variableLabel}_to_v3` : `user_unsync_${variableLabel}_from_v3`
|
|
556
|
-
});
|
|
557
|
-
} catch {
|
|
558
|
-
}
|
|
559
|
-
};
|
|
560
|
-
|
|
561
|
-
// src/utils/validations.ts
|
|
562
|
-
var import_icons = require("@elementor/icons");
|
|
563
|
-
var import_i18n2 = require("@wordpress/i18n");
|
|
564
|
-
var ERROR_MESSAGES = {
|
|
565
|
-
MISSING_VARIABLE_NAME: (0, import_i18n2.__)("Give your variable a name.", "elementor"),
|
|
566
|
-
MISSING_VARIABLE_VALUE: (0, import_i18n2.__)("Add a value to complete your variable.", "elementor"),
|
|
567
|
-
INVALID_CHARACTERS: (0, import_i18n2.__)("Use letters, numbers, dashes (-), or underscores (_) for the name.", "elementor"),
|
|
568
|
-
NO_NON_SPECIAL_CHARACTER: (0, import_i18n2.__)("Names have to include at least one non-special character.", "elementor"),
|
|
569
|
-
VARIABLE_LABEL_MAX_LENGTH: (0, import_i18n2.__)("Keep names up to 50 characters.", "elementor"),
|
|
570
|
-
DUPLICATED_LABEL: (0, import_i18n2.__)("This variable name already exists. Please choose a unique name.", "elementor"),
|
|
571
|
-
UNEXPECTED_ERROR: (0, import_i18n2.__)("There was a glitch. Try saving your variable again.", "elementor"),
|
|
572
|
-
BATCH: {
|
|
573
|
-
DUPLICATED_LABELS: (count, name) => (
|
|
574
|
-
// eslint-disable-next-line @wordpress/i18n-translator-comments
|
|
575
|
-
(0, import_i18n2.sprintf)((0, import_i18n2.__)("We found %1$d duplicated %2$s.", "elementor"), count, name)
|
|
576
|
-
),
|
|
577
|
-
UNEXPECTED_ERROR: (0, import_i18n2.__)("There was a glitch.", "elementor"),
|
|
578
|
-
DUPLICATED_LABEL_ACTION: (0, import_i18n2.__)("Take me there", "elementor"),
|
|
579
|
-
DUPLICATED_LABEL_ACTION_MESSAGE: (0, import_i18n2.__)("Please rename the variables.", "elementor"),
|
|
580
|
-
UNEXPECTED_ERROR_ACTION_MESSAGE: (0, import_i18n2.__)("Try saving your variables again.", "elementor")
|
|
581
|
-
}
|
|
582
|
-
};
|
|
583
|
-
var VARIABLE_LABEL_MAX_LENGTH = 50;
|
|
584
|
-
var mapServerError = (error) => {
|
|
585
|
-
if (error?.response?.data?.code === "duplicated_label") {
|
|
586
|
-
return {
|
|
587
|
-
field: "label",
|
|
588
|
-
message: ERROR_MESSAGES.DUPLICATED_LABEL
|
|
589
|
-
};
|
|
590
|
-
}
|
|
591
|
-
if (error?.response?.data?.code === "batch_duplicated_label") {
|
|
592
|
-
const errorData = error?.response?.data?.data ?? {};
|
|
593
|
-
const count = Object.keys(errorData).length;
|
|
594
|
-
const name = count === 1 ? "name" : "names";
|
|
595
|
-
const duplicatedIds = Object.keys(errorData);
|
|
596
|
-
return {
|
|
597
|
-
field: "label",
|
|
598
|
-
message: ERROR_MESSAGES.BATCH.DUPLICATED_LABELS(count, name),
|
|
599
|
-
severity: "error",
|
|
600
|
-
IconComponent: import_icons.AlertTriangleFilledIcon,
|
|
601
|
-
action: {
|
|
602
|
-
label: ERROR_MESSAGES.BATCH.DUPLICATED_LABEL_ACTION,
|
|
603
|
-
message: ERROR_MESSAGES.BATCH.DUPLICATED_LABEL_ACTION_MESSAGE,
|
|
604
|
-
data: {
|
|
605
|
-
duplicatedIds
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
};
|
|
609
|
-
}
|
|
610
|
-
if (error?.response?.data?.code === "batch_operation_failed") {
|
|
611
|
-
return {
|
|
612
|
-
field: "label",
|
|
613
|
-
message: ERROR_MESSAGES.BATCH.UNEXPECTED_ERROR,
|
|
614
|
-
severity: "secondary",
|
|
615
|
-
IconComponent: import_icons.InfoCircleFilledIcon,
|
|
616
|
-
action: {
|
|
617
|
-
message: ERROR_MESSAGES.BATCH.UNEXPECTED_ERROR_ACTION_MESSAGE
|
|
618
|
-
}
|
|
619
|
-
};
|
|
620
|
-
}
|
|
621
|
-
return void 0;
|
|
622
|
-
};
|
|
623
|
-
var validateLabel = (name, variables) => {
|
|
624
|
-
if (!name.trim()) {
|
|
625
|
-
return ERROR_MESSAGES.MISSING_VARIABLE_NAME;
|
|
626
|
-
}
|
|
627
|
-
const allowedChars = /^[a-zA-Z0-9_-]+$/;
|
|
628
|
-
if (!allowedChars.test(name)) {
|
|
629
|
-
return ERROR_MESSAGES.INVALID_CHARACTERS;
|
|
630
|
-
}
|
|
631
|
-
const hasAlphanumeric = /[a-zA-Z0-9]/;
|
|
632
|
-
if (!hasAlphanumeric.test(name)) {
|
|
633
|
-
return ERROR_MESSAGES.NO_NON_SPECIAL_CHARACTER;
|
|
634
|
-
}
|
|
635
|
-
if (VARIABLE_LABEL_MAX_LENGTH < name.length) {
|
|
636
|
-
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
637
|
-
}
|
|
638
|
-
if (Object.values(variables ?? {}).some((variable) => variable.label === name)) {
|
|
639
|
-
return ERROR_MESSAGES.DUPLICATED_LABEL;
|
|
640
|
-
}
|
|
641
|
-
return "";
|
|
642
|
-
};
|
|
643
|
-
var labelHint = (name) => {
|
|
644
|
-
const hintThreshold = VARIABLE_LABEL_MAX_LENGTH * 0.8 - 1;
|
|
645
|
-
if (hintThreshold < name.length) {
|
|
646
|
-
return ERROR_MESSAGES.VARIABLE_LABEL_MAX_LENGTH;
|
|
608
|
+
return payload;
|
|
609
|
+
}).then((data) => {
|
|
610
|
+
const { results, watermark } = data;
|
|
611
|
+
handleWatermark(OP_RW, watermark);
|
|
612
|
+
if (results) {
|
|
613
|
+
results.forEach((result) => {
|
|
614
|
+
const variableId = result.id;
|
|
615
|
+
if (result.variable) {
|
|
616
|
+
if (result.type === "create") {
|
|
617
|
+
storage.add(variableId, result.variable);
|
|
618
|
+
} else {
|
|
619
|
+
storage.update(variableId, result.variable);
|
|
620
|
+
}
|
|
621
|
+
styleVariablesRepository.update({
|
|
622
|
+
[variableId]: result.variable
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
return {
|
|
628
|
+
success: true,
|
|
629
|
+
watermark,
|
|
630
|
+
operations: operations.length
|
|
631
|
+
};
|
|
632
|
+
});
|
|
647
633
|
}
|
|
648
|
-
return "";
|
|
649
634
|
};
|
|
650
|
-
var
|
|
651
|
-
if (
|
|
652
|
-
|
|
635
|
+
var handleWatermark = (operation, newWatermark) => {
|
|
636
|
+
if (storage.watermarkDiff(operation, newWatermark)) {
|
|
637
|
+
setTimeout(() => service.load(), 500);
|
|
653
638
|
}
|
|
654
|
-
|
|
639
|
+
storage.watermark(newWatermark);
|
|
655
640
|
};
|
|
656
641
|
|
|
657
|
-
// src/variables-registry/create-variable-type-registry.ts
|
|
658
|
-
var import_editor_canvas4 = require("@elementor/editor-canvas");
|
|
659
|
-
|
|
660
|
-
// src/transformers/inheritance-transformer.tsx
|
|
661
|
-
var React = __toESM(require("react"));
|
|
662
|
-
var import_editor_canvas2 = require("@elementor/editor-canvas");
|
|
663
|
-
var import_ui2 = require("@elementor/ui");
|
|
664
|
-
var import_i18n3 = require("@wordpress/i18n");
|
|
665
|
-
|
|
666
|
-
// src/components/ui/color-indicator.tsx
|
|
667
|
-
var import_ui = require("@elementor/ui");
|
|
668
|
-
var ColorIndicator = (0, import_ui.styled)(import_ui.UnstableColorIndicator)(({ theme }) => ({
|
|
669
|
-
borderRadius: `${theme.shape.borderRadius / 2}px`,
|
|
670
|
-
marginRight: theme.spacing(0.25)
|
|
671
|
-
}));
|
|
672
|
-
|
|
673
|
-
// src/prop-types/color-variable-prop-type.ts
|
|
674
|
-
var import_editor_props2 = require("@elementor/editor-props");
|
|
675
|
-
var import_schema2 = require("@elementor/schema");
|
|
676
|
-
var colorVariablePropTypeUtil = (0, import_editor_props2.createPropUtils)("global-color-variable", import_schema2.z.string());
|
|
677
|
-
|
|
678
642
|
// src/transformers/utils/resolve-css-variable.ts
|
|
679
643
|
var resolveCssVariable = (id2, variable) => {
|
|
680
644
|
let name = id2;
|
|
@@ -696,7 +660,7 @@ var resolveCssVariable = (id2, variable) => {
|
|
|
696
660
|
};
|
|
697
661
|
|
|
698
662
|
// src/transformers/inheritance-transformer.tsx
|
|
699
|
-
var inheritanceTransformer = (0,
|
|
663
|
+
var inheritanceTransformer = (0, import_editor_canvas.createTransformer)((id2) => {
|
|
700
664
|
const variables = service.variables();
|
|
701
665
|
const variable = variables[id2];
|
|
702
666
|
if (!variable) {
|
|
@@ -708,8 +672,8 @@ var inheritanceTransformer = (0, import_editor_canvas2.createTransformer)((id2)
|
|
|
708
672
|
});
|
|
709
673
|
|
|
710
674
|
// src/transformers/variable-transformer.ts
|
|
711
|
-
var
|
|
712
|
-
var variableTransformer = (0,
|
|
675
|
+
var import_editor_canvas2 = require("@elementor/editor-canvas");
|
|
676
|
+
var variableTransformer = (0, import_editor_canvas2.createTransformer)((idOrLabel) => {
|
|
713
677
|
const variables = service.variables();
|
|
714
678
|
const targetVariable = variables[idOrLabel] || service.findVariableByLabel(idOrLabel);
|
|
715
679
|
if (!targetVariable) {
|
|
@@ -769,10 +733,10 @@ function createVariableTypeRegistry() {
|
|
|
769
733
|
registerInheritanceTransformer(propTypeUtil.key);
|
|
770
734
|
};
|
|
771
735
|
const registerTransformer = (key, transformer) => {
|
|
772
|
-
|
|
736
|
+
import_editor_canvas3.styleTransformersRegistry.register(key, transformer ?? variableTransformer);
|
|
773
737
|
};
|
|
774
738
|
const registerInheritanceTransformer = (key) => {
|
|
775
|
-
|
|
739
|
+
import_editor_canvas3.stylesInheritanceTransformersRegistry.register(key, inheritanceTransformer);
|
|
776
740
|
};
|
|
777
741
|
const getVariableType2 = (key) => {
|
|
778
742
|
return variableTypes[key];
|
|
@@ -877,13 +841,13 @@ var NoSearchResults = ({ searchValue, onClear, icon }) => {
|
|
|
877
841
|
};
|
|
878
842
|
|
|
879
843
|
// src/components/variables-manager/hooks/use-auto-edit.ts
|
|
880
|
-
var
|
|
844
|
+
var import_react = require("react");
|
|
881
845
|
var useAutoEdit = () => {
|
|
882
|
-
const [autoEditVariableId, setAutoEditVariableId] = (0,
|
|
883
|
-
const startAutoEdit = (0,
|
|
846
|
+
const [autoEditVariableId, setAutoEditVariableId] = (0, import_react.useState)(void 0);
|
|
847
|
+
const startAutoEdit = (0, import_react.useCallback)((variableId) => {
|
|
884
848
|
setAutoEditVariableId(variableId);
|
|
885
849
|
}, []);
|
|
886
|
-
const handleAutoEditComplete = (0,
|
|
850
|
+
const handleAutoEditComplete = (0, import_react.useCallback)(() => {
|
|
887
851
|
setTimeout(() => {
|
|
888
852
|
setAutoEditVariableId(void 0);
|
|
889
853
|
}, 100);
|
|
@@ -896,10 +860,10 @@ var useAutoEdit = () => {
|
|
|
896
860
|
};
|
|
897
861
|
|
|
898
862
|
// src/components/variables-manager/hooks/use-error-navigation.ts
|
|
899
|
-
var
|
|
863
|
+
var import_react2 = require("react");
|
|
900
864
|
var useErrorNavigation = () => {
|
|
901
|
-
const currentIndexRef = (0,
|
|
902
|
-
const createNavigationCallback = (0,
|
|
865
|
+
const currentIndexRef = (0, import_react2.useRef)(0);
|
|
866
|
+
const createNavigationCallback = (0, import_react2.useCallback)(
|
|
903
867
|
(ids, onNavigate, onComplete) => {
|
|
904
868
|
return () => {
|
|
905
869
|
if (!ids?.length) {
|
|
@@ -921,7 +885,7 @@ var useErrorNavigation = () => {
|
|
|
921
885
|
},
|
|
922
886
|
[]
|
|
923
887
|
);
|
|
924
|
-
const resetNavigation = (0,
|
|
888
|
+
const resetNavigation = (0, import_react2.useCallback)(() => {
|
|
925
889
|
currentIndexRef.current = 0;
|
|
926
890
|
}, []);
|
|
927
891
|
return {
|
|
@@ -931,21 +895,21 @@ var useErrorNavigation = () => {
|
|
|
931
895
|
};
|
|
932
896
|
|
|
933
897
|
// src/components/variables-manager/hooks/use-variables-manager-state.ts
|
|
934
|
-
var
|
|
898
|
+
var import_react5 = require("react");
|
|
935
899
|
|
|
936
900
|
// src/hooks/use-prop-variables.ts
|
|
937
|
-
var
|
|
901
|
+
var import_react4 = require("react");
|
|
938
902
|
var import_editor_controls = require("@elementor/editor-controls");
|
|
939
903
|
|
|
940
904
|
// src/context/variable-type-context.tsx
|
|
941
905
|
var React5 = __toESM(require("react"));
|
|
942
|
-
var
|
|
943
|
-
var VariableTypeContext = (0,
|
|
906
|
+
var import_react3 = require("react");
|
|
907
|
+
var VariableTypeContext = (0, import_react3.createContext)(null);
|
|
944
908
|
function VariableTypeProvider({ children, propTypeKey }) {
|
|
945
909
|
return /* @__PURE__ */ React5.createElement(VariableTypeContext.Provider, { value: propTypeKey }, children);
|
|
946
910
|
}
|
|
947
911
|
function useVariableType() {
|
|
948
|
-
const context = (0,
|
|
912
|
+
const context = (0, import_react3.useContext)(VariableTypeContext);
|
|
949
913
|
if (context === null) {
|
|
950
914
|
throw new Error("useVariableType must be used within a VariableTypeProvider");
|
|
951
915
|
}
|
|
@@ -1031,7 +995,7 @@ var useVariableSelectionFilter = (variables) => {
|
|
|
1031
995
|
return selectionFilter ? selectionFilter(variables, propType) : variables;
|
|
1032
996
|
};
|
|
1033
997
|
var usePropVariables = (propKey) => {
|
|
1034
|
-
return (0,
|
|
998
|
+
return (0, import_react4.useMemo)(() => normalizeVariables(propKey), [propKey]);
|
|
1035
999
|
};
|
|
1036
1000
|
var getMatchingTypes = (propKey) => {
|
|
1037
1001
|
const matchingTypes = [];
|
|
@@ -1089,20 +1053,20 @@ var generateDuplicateLabel = (originalLabel, existingLabels) => {
|
|
|
1089
1053
|
|
|
1090
1054
|
// src/components/variables-manager/hooks/use-variables-manager-state.ts
|
|
1091
1055
|
var useVariablesManagerState = () => {
|
|
1092
|
-
const [variables, setVariables] = (0,
|
|
1093
|
-
const [deletedVariables, setDeletedVariables] = (0,
|
|
1094
|
-
const [isSaveDisabled, setIsSaveDisabled] = (0,
|
|
1095
|
-
const [isDirty, setIsDirty] = (0,
|
|
1096
|
-
const [isSaving, setIsSaving] = (0,
|
|
1097
|
-
const [searchValue, setSearchValue] = (0,
|
|
1098
|
-
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)(
|
|
1099
1063
|
(newVariables) => {
|
|
1100
1064
|
setVariables({ ...variables, ...newVariables });
|
|
1101
1065
|
setIsDirty(true);
|
|
1102
1066
|
},
|
|
1103
1067
|
[variables]
|
|
1104
1068
|
);
|
|
1105
|
-
const createVariable2 = (0,
|
|
1069
|
+
const createVariable2 = (0, import_react5.useCallback)((type, defaultName, defaultValue) => {
|
|
1106
1070
|
const newId = generateTempId();
|
|
1107
1071
|
const newVariable = {
|
|
1108
1072
|
id: newId,
|
|
@@ -1114,7 +1078,7 @@ var useVariablesManagerState = () => {
|
|
|
1114
1078
|
setIsDirty(true);
|
|
1115
1079
|
return newId;
|
|
1116
1080
|
}, []);
|
|
1117
|
-
const duplicateVariable = (0,
|
|
1081
|
+
const duplicateVariable = (0, import_react5.useCallback)((sourceId) => {
|
|
1118
1082
|
const newId = generateTempId();
|
|
1119
1083
|
setVariables((prev) => {
|
|
1120
1084
|
const source = prev[sourceId];
|
|
@@ -1134,19 +1098,19 @@ var useVariablesManagerState = () => {
|
|
|
1134
1098
|
setIsDirty(true);
|
|
1135
1099
|
return newId;
|
|
1136
1100
|
}, []);
|
|
1137
|
-
const handleDeleteVariable = (0,
|
|
1101
|
+
const handleDeleteVariable = (0, import_react5.useCallback)((itemId) => {
|
|
1138
1102
|
setDeletedVariables((prev) => [...prev, itemId]);
|
|
1139
1103
|
setVariables((prev) => ({ ...prev, [itemId]: { ...prev[itemId], deleted: true } }));
|
|
1140
1104
|
setIsDirty(true);
|
|
1141
1105
|
}, []);
|
|
1142
|
-
const handleStartSync = (0,
|
|
1106
|
+
const handleStartSync = (0, import_react5.useCallback)((itemId) => {
|
|
1143
1107
|
setVariables((prev) => ({
|
|
1144
1108
|
...prev,
|
|
1145
1109
|
[itemId]: { ...prev[itemId], sync_to_v3: true }
|
|
1146
1110
|
}));
|
|
1147
1111
|
setIsDirty(true);
|
|
1148
1112
|
}, []);
|
|
1149
|
-
const handleStopSync = (0,
|
|
1113
|
+
const handleStopSync = (0, import_react5.useCallback)((itemId) => {
|
|
1150
1114
|
setVariables((prev) => ({
|
|
1151
1115
|
...prev,
|
|
1152
1116
|
[itemId]: { ...prev[itemId], sync_to_v3: false }
|
|
@@ -1156,7 +1120,7 @@ var useVariablesManagerState = () => {
|
|
|
1156
1120
|
const handleSearch = (searchTerm) => {
|
|
1157
1121
|
setSearchValue(searchTerm);
|
|
1158
1122
|
};
|
|
1159
|
-
const handleSave = (0,
|
|
1123
|
+
const handleSave = (0, import_react5.useCallback)(async () => {
|
|
1160
1124
|
const originalVariables = getVariables(false);
|
|
1161
1125
|
setIsSaving(true);
|
|
1162
1126
|
const result = await service.batchSave(originalVariables, variables, deletedVariables);
|
|
@@ -1169,7 +1133,7 @@ var useVariablesManagerState = () => {
|
|
|
1169
1133
|
}
|
|
1170
1134
|
return { success: result.success };
|
|
1171
1135
|
}, [variables, deletedVariables]);
|
|
1172
|
-
const filteredVariables = (0,
|
|
1136
|
+
const filteredVariables = (0, import_react5.useCallback)(() => {
|
|
1173
1137
|
const list = variablesToList(variables).filter((v) => !v.deleted);
|
|
1174
1138
|
const typeFiltered = applySelectionFilters(list, getVariableTypes());
|
|
1175
1139
|
const searchFiltered = filterBySearch(typeFiltered, searchValue);
|
|
@@ -1197,7 +1161,7 @@ var useVariablesManagerState = () => {
|
|
|
1197
1161
|
|
|
1198
1162
|
// src/components/variables-manager/variables-manager-create-menu.tsx
|
|
1199
1163
|
var React7 = __toESM(require("react"));
|
|
1200
|
-
var
|
|
1164
|
+
var import_react7 = require("react");
|
|
1201
1165
|
var import_icons2 = require("@elementor/icons");
|
|
1202
1166
|
var import_ui7 = require("@elementor/ui");
|
|
1203
1167
|
var import_utils2 = require("@elementor/utils");
|
|
@@ -1220,17 +1184,17 @@ var useQuotaPermissions = (variableType) => {
|
|
|
1220
1184
|
|
|
1221
1185
|
// src/components/ui/variable-promotion-chip.tsx
|
|
1222
1186
|
var React6 = __toESM(require("react"));
|
|
1223
|
-
var
|
|
1187
|
+
var import_react6 = require("react");
|
|
1224
1188
|
var import_editor_controls2 = require("@elementor/editor-controls");
|
|
1225
1189
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
1226
1190
|
var import_ui6 = require("@elementor/ui");
|
|
1227
1191
|
var import_utils = require("@elementor/utils");
|
|
1228
1192
|
var import_i18n7 = require("@wordpress/i18n");
|
|
1229
|
-
var VariablePromotionChip = (0,
|
|
1193
|
+
var VariablePromotionChip = (0, import_react6.forwardRef)(
|
|
1230
1194
|
({ variableType, upgradeUrl, trackingData }, ref) => {
|
|
1231
|
-
const [isOpen, setIsOpen] = (0,
|
|
1195
|
+
const [isOpen, setIsOpen] = (0, import_react6.useState)(false);
|
|
1232
1196
|
(0, import_editor_ui2.useCanvasClickHandler)(isOpen, () => setIsOpen(false));
|
|
1233
|
-
const toggle = (0,
|
|
1197
|
+
const toggle = (0, import_react6.useCallback)(() => {
|
|
1234
1198
|
setIsOpen((prev) => {
|
|
1235
1199
|
if (!prev) {
|
|
1236
1200
|
(0, import_editor_controls2.trackViewPromotion)(trackingData);
|
|
@@ -1238,7 +1202,7 @@ var VariablePromotionChip = (0, import_react7.forwardRef)(
|
|
|
1238
1202
|
return !prev;
|
|
1239
1203
|
});
|
|
1240
1204
|
}, [trackingData]);
|
|
1241
|
-
(0,
|
|
1205
|
+
(0, import_react6.useImperativeHandle)(ref, () => ({ toggle }), [toggle]);
|
|
1242
1206
|
const title = (0, import_i18n7.sprintf)(
|
|
1243
1207
|
/* translators: %s: Variable Type. */
|
|
1244
1208
|
(0, import_i18n7.__)("%s variables", "elementor"),
|
|
@@ -1285,10 +1249,15 @@ var TRACKING_DATA = {
|
|
|
1285
1249
|
location_l1: "create variable menu"
|
|
1286
1250
|
};
|
|
1287
1251
|
var SIZE = "tiny";
|
|
1288
|
-
var VariableManagerCreateMenu = ({
|
|
1289
|
-
|
|
1252
|
+
var VariableManagerCreateMenu = ({
|
|
1253
|
+
variables,
|
|
1254
|
+
onCreate,
|
|
1255
|
+
menuState,
|
|
1256
|
+
outlinedTrigger = false
|
|
1257
|
+
}) => {
|
|
1258
|
+
const buttonRef = (0, import_react7.useRef)(null);
|
|
1290
1259
|
const variableTypes = getVariableTypes();
|
|
1291
|
-
const menuOptionConfigs = (0,
|
|
1260
|
+
const menuOptionConfigs = (0, import_react7.useMemo)(
|
|
1292
1261
|
() => Object.entries(variableTypes).filter(([, variable]) => !!variable.defaultValue).map(([key, variable]) => ({
|
|
1293
1262
|
key,
|
|
1294
1263
|
propTypeKey: variable.propTypeUtil.key,
|
|
@@ -1304,6 +1273,7 @@ var VariableManagerCreateMenu = ({ variables, onCreate, menuState }) => {
|
|
|
1304
1273
|
...(0, import_ui7.bindTrigger)(menuState),
|
|
1305
1274
|
ref: buttonRef,
|
|
1306
1275
|
size: SIZE,
|
|
1276
|
+
variant: outlinedTrigger ? "outlined" : void 0,
|
|
1307
1277
|
"aria-label": (0, import_i18n8.__)("Add variable", "elementor")
|
|
1308
1278
|
},
|
|
1309
1279
|
/* @__PURE__ */ React7.createElement(import_icons2.PlusIcon, { fontSize: SIZE })
|
|
@@ -1347,7 +1317,7 @@ var MenuOption = ({
|
|
|
1347
1317
|
onCreate,
|
|
1348
1318
|
onClose
|
|
1349
1319
|
}) => {
|
|
1350
|
-
const promotionRef = (0,
|
|
1320
|
+
const promotionRef = (0, import_react7.useRef)(null);
|
|
1351
1321
|
const userQuotaPermissions = useQuotaPermissions(config.propTypeKey);
|
|
1352
1322
|
const displayName = (0, import_utils2.capitalize)(config.variableType);
|
|
1353
1323
|
const isDisabled = !userQuotaPermissions.canAdd();
|
|
@@ -1361,7 +1331,7 @@ var MenuOption = ({
|
|
|
1361
1331
|
trackVariablesManagerEvent({ action: "add", varType: config.variableType });
|
|
1362
1332
|
onClose();
|
|
1363
1333
|
};
|
|
1364
|
-
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(
|
|
1365
1335
|
VariablePromotionChip,
|
|
1366
1336
|
{
|
|
1367
1337
|
variableType: config.variableType,
|
|
@@ -1389,7 +1359,7 @@ var getDefaultName = (variables, baseName) => {
|
|
|
1389
1359
|
|
|
1390
1360
|
// src/components/variables-manager/variables-manager-table.tsx
|
|
1391
1361
|
var React13 = __toESM(require("react"));
|
|
1392
|
-
var
|
|
1362
|
+
var import_react12 = require("react");
|
|
1393
1363
|
var import_ui13 = require("@elementor/ui");
|
|
1394
1364
|
var import_i18n9 = require("@wordpress/i18n");
|
|
1395
1365
|
|
|
@@ -1419,21 +1389,21 @@ var VariableTableCell = ({
|
|
|
1419
1389
|
|
|
1420
1390
|
// src/components/variables-manager/ui/variable-table-row.tsx
|
|
1421
1391
|
var React12 = __toESM(require("react"));
|
|
1422
|
-
var
|
|
1392
|
+
var import_react11 = require("react");
|
|
1423
1393
|
var import_editor_ui4 = require("@elementor/editor-ui");
|
|
1424
1394
|
var import_icons4 = require("@elementor/icons");
|
|
1425
1395
|
var import_ui12 = require("@elementor/ui");
|
|
1426
1396
|
|
|
1427
1397
|
// src/components/fields/label-field.tsx
|
|
1428
1398
|
var React9 = __toESM(require("react"));
|
|
1429
|
-
var
|
|
1399
|
+
var import_react8 = require("react");
|
|
1430
1400
|
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
1431
1401
|
var import_ui9 = require("@elementor/ui");
|
|
1432
1402
|
function isLabelEqual(a, b) {
|
|
1433
1403
|
return a.trim().toLowerCase() === b.trim().toLowerCase();
|
|
1434
1404
|
}
|
|
1435
1405
|
var useLabelError = (initialError) => {
|
|
1436
|
-
const [error, setError] = (0,
|
|
1406
|
+
const [error, setError] = (0, import_react8.useState)(initialError ?? { value: "", message: "" });
|
|
1437
1407
|
return {
|
|
1438
1408
|
labelFieldError: error,
|
|
1439
1409
|
setLabelFieldError: setError
|
|
@@ -1452,9 +1422,9 @@ var LabelField = ({
|
|
|
1452
1422
|
variables,
|
|
1453
1423
|
onKeyDown
|
|
1454
1424
|
}) => {
|
|
1455
|
-
const [label, setLabel] = (0,
|
|
1456
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
1457
|
-
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);
|
|
1458
1428
|
const handleChange = (newValue) => {
|
|
1459
1429
|
setLabel(newValue);
|
|
1460
1430
|
const errorMsg2 = validateLabel(newValue, variables);
|
|
@@ -1506,7 +1476,7 @@ var LabelField = ({
|
|
|
1506
1476
|
|
|
1507
1477
|
// src/components/variables-manager/variable-editable-cell.tsx
|
|
1508
1478
|
var React10 = __toESM(require("react"));
|
|
1509
|
-
var
|
|
1479
|
+
var import_react9 = require("react");
|
|
1510
1480
|
var import_ui10 = require("@elementor/ui");
|
|
1511
1481
|
var VariableEditableCell = React10.memo(
|
|
1512
1482
|
({
|
|
@@ -1522,22 +1492,22 @@ var VariableEditableCell = React10.memo(
|
|
|
1522
1492
|
fieldType,
|
|
1523
1493
|
disabled = false
|
|
1524
1494
|
}) => {
|
|
1525
|
-
const [value, setValue] = (0,
|
|
1526
|
-
const [isEditing, setIsEditing] = (0,
|
|
1495
|
+
const [value, setValue] = (0, import_react9.useState)(initialValue);
|
|
1496
|
+
const [isEditing, setIsEditing] = (0, import_react9.useState)(false);
|
|
1527
1497
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
1528
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
1529
|
-
const rowRef = (0,
|
|
1530
|
-
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)(() => {
|
|
1531
1501
|
const hasError = fieldType === "label" && labelFieldError?.message || fieldType === "value" && valueFieldError;
|
|
1532
1502
|
if (!hasError) {
|
|
1533
1503
|
onChange(value);
|
|
1534
1504
|
}
|
|
1535
1505
|
setIsEditing(false);
|
|
1536
1506
|
}, [value, onChange, fieldType, labelFieldError, valueFieldError]);
|
|
1537
|
-
(0,
|
|
1507
|
+
(0, import_react9.useEffect)(() => {
|
|
1538
1508
|
onRowRef?.(rowRef?.current);
|
|
1539
1509
|
}, [onRowRef]);
|
|
1540
|
-
(0,
|
|
1510
|
+
(0, import_react9.useEffect)(() => {
|
|
1541
1511
|
if (autoEdit && !isEditing && !disabled) {
|
|
1542
1512
|
setIsEditing(true);
|
|
1543
1513
|
onAutoEditComplete?.();
|
|
@@ -1563,10 +1533,10 @@ var VariableEditableCell = React10.memo(
|
|
|
1563
1533
|
setIsEditing(true);
|
|
1564
1534
|
}
|
|
1565
1535
|
};
|
|
1566
|
-
const handleChange = (0,
|
|
1536
|
+
const handleChange = (0, import_react9.useCallback)((newValue) => {
|
|
1567
1537
|
setValue(newValue);
|
|
1568
1538
|
}, []);
|
|
1569
|
-
const handleValidationChange = (0,
|
|
1539
|
+
const handleValidationChange = (0, import_react9.useCallback)(
|
|
1570
1540
|
(errorMsg) => {
|
|
1571
1541
|
if (fieldType === "label") {
|
|
1572
1542
|
setLabelFieldError({
|
|
@@ -1630,7 +1600,7 @@ var VariableEditableCell = React10.memo(
|
|
|
1630
1600
|
|
|
1631
1601
|
// src/components/variables-manager/ui/variable-edit-menu.tsx
|
|
1632
1602
|
var React11 = __toESM(require("react"));
|
|
1633
|
-
var
|
|
1603
|
+
var import_react10 = require("react");
|
|
1634
1604
|
var import_icons3 = require("@elementor/icons");
|
|
1635
1605
|
var import_ui11 = require("@elementor/ui");
|
|
1636
1606
|
var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
|
|
@@ -1687,7 +1657,7 @@ var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
|
|
|
1687
1657
|
gap: 1
|
|
1688
1658
|
}
|
|
1689
1659
|
},
|
|
1690
|
-
action.icon && (0,
|
|
1660
|
+
action.icon && (0, import_react10.createElement)(action.icon, {
|
|
1691
1661
|
fontSize: "inherit"
|
|
1692
1662
|
}),
|
|
1693
1663
|
" ",
|
|
@@ -1718,7 +1688,7 @@ var VariableRow = (props) => {
|
|
|
1718
1688
|
setTriggerRef,
|
|
1719
1689
|
isSorting
|
|
1720
1690
|
} = props;
|
|
1721
|
-
const promotionRef = (0,
|
|
1691
|
+
const promotionRef = (0, import_react11.useRef)(null);
|
|
1722
1692
|
const isDisabled = !useQuotaPermissions(row.type).canEdit();
|
|
1723
1693
|
const showIndicationBefore = showDropIndication && dropPosition === "before";
|
|
1724
1694
|
const showIndicationAfter = showDropIndication && dropPosition === "after";
|
|
@@ -1776,7 +1746,7 @@ var VariableRow = (props) => {
|
|
|
1776
1746
|
});
|
|
1777
1747
|
}
|
|
1778
1748
|
},
|
|
1779
|
-
prefixElement: (0,
|
|
1749
|
+
prefixElement: (0, import_react11.createElement)(row.icon, {
|
|
1780
1750
|
fontSize: "inherit",
|
|
1781
1751
|
color: isDisabled ? "disabled" : "inherit"
|
|
1782
1752
|
}),
|
|
@@ -1876,9 +1846,9 @@ var VariablesManagerTable = ({
|
|
|
1876
1846
|
onAutoEditComplete,
|
|
1877
1847
|
onFieldError
|
|
1878
1848
|
}) => {
|
|
1879
|
-
const tableContainerRef = (0,
|
|
1880
|
-
const variableRowRefs = (0,
|
|
1881
|
-
(0,
|
|
1849
|
+
const tableContainerRef = (0, import_react12.useRef)(null);
|
|
1850
|
+
const variableRowRefs = (0, import_react12.useRef)(/* @__PURE__ */ new Map());
|
|
1851
|
+
(0, import_react12.useEffect)(() => {
|
|
1882
1852
|
if (autoEditVariableId && tableContainerRef.current) {
|
|
1883
1853
|
const rowElement = variableRowRefs.current.get(autoEditVariableId);
|
|
1884
1854
|
if (rowElement) {
|
|
@@ -1984,8 +1954,33 @@ var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
|
|
|
1984
1954
|
},
|
|
1985
1955
|
isOpenPreviousElement: true
|
|
1986
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
|
+
}
|
|
1987
1970
|
function VariablesManagerPanel() {
|
|
1988
|
-
|
|
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
|
+
);
|
|
1989
1984
|
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = (0, import_editor_ui5.useDialog)();
|
|
1990
1985
|
const [isStopSyncSuppressed] = (0, import_editor_current_user2.useSuppressedMessage)(STOP_SYNC_MESSAGE_KEY);
|
|
1991
1986
|
const createMenuState = (0, import_ui14.usePopupState)({
|
|
@@ -2010,18 +2005,25 @@ function VariablesManagerPanel() {
|
|
|
2010
2005
|
} = useVariablesManagerState();
|
|
2011
2006
|
const { autoEditVariableId, startAutoEdit, handleAutoEditComplete } = useAutoEdit();
|
|
2012
2007
|
const { createNavigationCallback, resetNavigation } = useErrorNavigation();
|
|
2013
|
-
const [deleteConfirmation, setDeleteConfirmation] = (0,
|
|
2014
|
-
const [stopSyncConfirmation, setStopSyncConfirmation] = (0,
|
|
2015
|
-
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);
|
|
2016
2011
|
usePreventUnload(isDirty);
|
|
2017
|
-
const handleClosePanel = () => {
|
|
2012
|
+
const handleClosePanel = (0, import_react13.useCallback)(() => {
|
|
2018
2013
|
if (isDirty) {
|
|
2019
2014
|
openSaveChangesDialog();
|
|
2020
2015
|
return;
|
|
2021
2016
|
}
|
|
2022
|
-
closePanel();
|
|
2023
|
-
};
|
|
2024
|
-
|
|
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)(
|
|
2025
2027
|
(type, defaultName, defaultValue) => {
|
|
2026
2028
|
const newId = createVariable2(type, defaultName, defaultValue);
|
|
2027
2029
|
if (newId) {
|
|
@@ -2055,14 +2057,14 @@ function VariablesManagerPanel() {
|
|
|
2055
2057
|
setIsSaving(false);
|
|
2056
2058
|
}
|
|
2057
2059
|
};
|
|
2058
|
-
const handleDeleteVariableWithConfirmation = (0,
|
|
2060
|
+
const handleDeleteVariableWithConfirmation = (0, import_react13.useCallback)(
|
|
2059
2061
|
(itemId) => {
|
|
2060
2062
|
handleDeleteVariable(itemId);
|
|
2061
2063
|
setDeleteConfirmation(null);
|
|
2062
2064
|
},
|
|
2063
2065
|
[handleDeleteVariable]
|
|
2064
2066
|
);
|
|
2065
|
-
const commitStopSync = (0,
|
|
2067
|
+
const commitStopSync = (0, import_react13.useCallback)(
|
|
2066
2068
|
(itemId) => {
|
|
2067
2069
|
stopSyncFromState(itemId);
|
|
2068
2070
|
const variable = variables[itemId];
|
|
@@ -2072,7 +2074,7 @@ function VariablesManagerPanel() {
|
|
|
2072
2074
|
},
|
|
2073
2075
|
[stopSyncFromState, variables]
|
|
2074
2076
|
);
|
|
2075
|
-
const handleStartSync = (0,
|
|
2077
|
+
const handleStartSync = (0, import_react13.useCallback)(
|
|
2076
2078
|
(itemId) => {
|
|
2077
2079
|
startSyncFromState(itemId);
|
|
2078
2080
|
const variable = variables[itemId];
|
|
@@ -2082,7 +2084,7 @@ function VariablesManagerPanel() {
|
|
|
2082
2084
|
},
|
|
2083
2085
|
[startSyncFromState, variables]
|
|
2084
2086
|
);
|
|
2085
|
-
const handleStopSync = (0,
|
|
2087
|
+
const handleStopSync = (0, import_react13.useCallback)(
|
|
2086
2088
|
(itemId) => {
|
|
2087
2089
|
if (!isStopSyncSuppressed) {
|
|
2088
2090
|
setStopSyncConfirmation(itemId);
|
|
@@ -2092,7 +2094,7 @@ function VariablesManagerPanel() {
|
|
|
2092
2094
|
},
|
|
2093
2095
|
[isStopSyncSuppressed, commitStopSync]
|
|
2094
2096
|
);
|
|
2095
|
-
const buildMenuActions = (0,
|
|
2097
|
+
const buildMenuActions = (0, import_react13.useCallback)(
|
|
2096
2098
|
(variableId) => {
|
|
2097
2099
|
const variable = variables[variableId];
|
|
2098
2100
|
if (!variable) {
|
|
@@ -2138,82 +2140,57 @@ function VariablesManagerPanel() {
|
|
|
2138
2140
|
[variables, handleStartSync, handleStopSync, duplicateVariable, startAutoEdit]
|
|
2139
2141
|
);
|
|
2140
2142
|
const hasVariables = Object.keys(variables).length > 0;
|
|
2141
|
-
|
|
2142
|
-
|
|
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,
|
|
2143
2157
|
{
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
variables,
|
|
2153
|
-
menuState: createMenuState
|
|
2154
|
-
}
|
|
2155
|
-
), /* @__PURE__ */ React14.createElement(
|
|
2156
|
-
import_ui14.CloseButton,
|
|
2157
|
-
{
|
|
2158
|
-
"aria-label": "Close",
|
|
2159
|
-
slotProps: { icon: { fontSize: SIZE } },
|
|
2160
|
-
onClick: () => {
|
|
2161
|
-
handleClosePanel();
|
|
2162
|
-
}
|
|
2163
|
-
}
|
|
2164
|
-
))), /* @__PURE__ */ React14.createElement(import_ui14.Stack, { width: "100%", direction: "row", gap: 1 }, /* @__PURE__ */ React14.createElement(
|
|
2165
|
-
import_editor_ui5.SearchField,
|
|
2166
|
-
{
|
|
2167
|
-
sx: {
|
|
2168
|
-
display: "flex",
|
|
2169
|
-
flex: 1
|
|
2170
|
-
},
|
|
2171
|
-
placeholder: (0, import_i18n10.__)("Search", "elementor"),
|
|
2172
|
-
value: searchValue,
|
|
2173
|
-
onSearch: handleSearch
|
|
2174
|
-
}
|
|
2175
|
-
)), /* @__PURE__ */ React14.createElement(import_ui14.Divider, { sx: { width: "100%" } }))
|
|
2176
|
-
), /* @__PURE__ */ React14.createElement(
|
|
2177
|
-
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,
|
|
2178
2166
|
{
|
|
2179
|
-
|
|
2180
|
-
|
|
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
|
-
title: (0, import_i18n10.__)("Create your first variable", "elementor"),
|
|
2208
|
-
message: (0, import_i18n10.__)(
|
|
2209
|
-
"Variables are saved attributes that you can apply anywhere on your site.",
|
|
2210
|
-
"elementor"
|
|
2211
|
-
),
|
|
2212
|
-
icon: /* @__PURE__ */ React14.createElement(import_icons5.ColorFilterIcon, { fontSize: "large" }),
|
|
2213
|
-
onAdd: createMenuState.open
|
|
2214
|
-
}
|
|
2215
|
-
)
|
|
2216
|
-
), /* @__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(
|
|
2217
2194
|
import_ui14.Infotip,
|
|
2218
2195
|
{
|
|
2219
2196
|
placement: "right",
|
|
@@ -2257,7 +2234,8 @@ function VariablesManagerPanel() {
|
|
|
2257
2234
|
},
|
|
2258
2235
|
(0, import_i18n10.__)("Save changes", "elementor")
|
|
2259
2236
|
)
|
|
2260
|
-
))
|
|
2237
|
+
));
|
|
2238
|
+
const dialogs = /* @__PURE__ */ React14.createElement(React14.Fragment, null, deleteConfirmation && /* @__PURE__ */ React14.createElement(
|
|
2261
2239
|
DeleteConfirmationDialog,
|
|
2262
2240
|
{
|
|
2263
2241
|
open: true,
|
|
@@ -2283,7 +2261,7 @@ function VariablesManagerPanel() {
|
|
|
2283
2261
|
label: (0, import_i18n10.__)("Discard", "elementor"),
|
|
2284
2262
|
action: () => {
|
|
2285
2263
|
closeSaveChangesDialog();
|
|
2286
|
-
closePanel();
|
|
2264
|
+
void closePanel();
|
|
2287
2265
|
}
|
|
2288
2266
|
},
|
|
2289
2267
|
confirm: {
|
|
@@ -2292,16 +2270,104 @@ function VariablesManagerPanel() {
|
|
|
2292
2270
|
const result = await handleSaveClick();
|
|
2293
2271
|
closeSaveChangesDialog();
|
|
2294
2272
|
if (result?.success) {
|
|
2295
|
-
closePanel();
|
|
2273
|
+
void closePanel();
|
|
2296
2274
|
}
|
|
2297
2275
|
}
|
|
2298
2276
|
}
|
|
2299
2277
|
}
|
|
2300
2278
|
}
|
|
2301
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);
|
|
2302
2368
|
}
|
|
2303
2369
|
var usePreventUnload = (isDirty) => {
|
|
2304
|
-
(0,
|
|
2370
|
+
(0, import_react13.useEffect)(() => {
|
|
2305
2371
|
const handleBeforeUnload = (event) => {
|
|
2306
2372
|
if (isDirty) {
|
|
2307
2373
|
event.preventDefault();
|
|
@@ -2332,7 +2398,41 @@ var StopSyncConfirmationDialog = ({ open, onClose, onConfirm }) => {
|
|
|
2332
2398
|
));
|
|
2333
2399
|
};
|
|
2334
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
|
+
|
|
2335
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");
|
|
2336
2436
|
var EVENT_NAME = "elementor/open-variables-manager";
|
|
2337
2437
|
var DEFAULT_PANEL_ROUTE = "panel/elements/categories";
|
|
2338
2438
|
function OpenPanelFromEvent() {
|
|
@@ -3153,9 +3253,15 @@ var VIEW_EDIT = "edit";
|
|
|
3153
3253
|
var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
|
|
3154
3254
|
const [currentView, setCurrentView] = (0, import_react22.useState)(VIEW_LIST);
|
|
3155
3255
|
const [editId, setEditId] = (0, import_react22.useState)("");
|
|
3156
|
-
const { open } = usePanelActions();
|
|
3256
|
+
const { open: openStandaloneVariablesPanel } = usePanelActions();
|
|
3157
3257
|
const onSettingsAvailable = (0, import_editor_v1_adapters5.isExperimentActive)("e_variables_manager") ? () => {
|
|
3158
|
-
|
|
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
|
+
}
|
|
3159
3265
|
} : void 0;
|
|
3160
3266
|
return /* @__PURE__ */ React22.createElement(VariableTypeProvider, { propTypeKey }, /* @__PURE__ */ React22.createElement(PopoverContentRefContextProvider, null, RenderView({
|
|
3161
3267
|
propTypeKey,
|
|
@@ -4467,15 +4573,17 @@ function init() {
|
|
|
4467
4573
|
id: "variables-import-listener",
|
|
4468
4574
|
component: GlobalStylesImportListener
|
|
4469
4575
|
});
|
|
4470
|
-
(0,
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
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
|
+
}
|
|
4479
4587
|
}
|
|
4480
4588
|
function hasVariableAssigned(value) {
|
|
4481
4589
|
if ((0, import_editor_props10.isTransformable)(value)) {
|
|
@@ -4506,6 +4614,7 @@ var Utils = {
|
|
|
4506
4614
|
0 && (module.exports = {
|
|
4507
4615
|
GLOBAL_VARIABLES_URI,
|
|
4508
4616
|
Utils,
|
|
4617
|
+
VariablesManagerPanelEmbedded,
|
|
4509
4618
|
getMenuActionsForVariable,
|
|
4510
4619
|
hasVariable,
|
|
4511
4620
|
init,
|