@elementor/editor-variables 4.2.0-945 → 4.2.0-beta1
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 +27 -11
- package/dist/index.d.ts +27 -11
- package/dist/index.js +243 -151
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +147 -55
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/mcp-variable-connect-listener.tsx +31 -0
- package/src/components/variable-creation.tsx +9 -13
- package/src/components/variable-edit.tsx +2 -2
- package/src/hooks/use-prop-variables.ts +6 -5
- package/src/init.ts +6 -0
- package/src/mcp/manage-variable-tool.ts +2 -2
- package/src/service.ts +32 -2
- package/src/utils/extract-variables-from-style-value.ts +55 -0
- package/src/utils/tracking.ts +46 -30
package/dist/index.js
CHANGED
|
@@ -56,20 +56,31 @@ var import_i18n10 = require("@wordpress/i18n");
|
|
|
56
56
|
|
|
57
57
|
// src/utils/tracking.ts
|
|
58
58
|
var import_events = require("@elementor/events");
|
|
59
|
-
var trackVariableEvent = ({ varType, controlPath, action }) => {
|
|
59
|
+
var trackVariableEvent = ({ varType, controlPath, action, executedBy }) => {
|
|
60
60
|
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
61
61
|
if (!config?.names?.variables?.[action]) {
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
const name = config.names.variables[action];
|
|
65
|
-
|
|
66
|
-
location: config?.locations?.variables || "",
|
|
67
|
-
secondaryLocation: config?.secondaryLocations?.variablesPopover || "",
|
|
68
|
-
trigger: config?.triggers?.click || "",
|
|
65
|
+
let eventData = {
|
|
69
66
|
var_type: varType,
|
|
70
|
-
control_path: controlPath,
|
|
71
67
|
action_type: name
|
|
72
|
-
}
|
|
68
|
+
};
|
|
69
|
+
if (executedBy) {
|
|
70
|
+
eventData.executed_by = executedBy;
|
|
71
|
+
}
|
|
72
|
+
const defaultLocationInfo = {
|
|
73
|
+
location: config?.locations?.variables || "",
|
|
74
|
+
secondaryLocation: config?.secondaryLocations?.variablesPopover || "",
|
|
75
|
+
trigger: config?.triggers?.click || ""
|
|
76
|
+
};
|
|
77
|
+
if (!executedBy || executedBy !== "mcp_tool") {
|
|
78
|
+
eventData = { ...defaultLocationInfo, ...eventData };
|
|
79
|
+
}
|
|
80
|
+
if (controlPath) {
|
|
81
|
+
eventData.control_path = controlPath;
|
|
82
|
+
}
|
|
83
|
+
dispatchEvent?.(name, eventData);
|
|
73
84
|
};
|
|
74
85
|
var trackVariablesManagerEvent = ({ action, source, varType, controlPath }) => {
|
|
75
86
|
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
@@ -94,24 +105,21 @@ var trackVariablesManagerEvent = ({ action, source, varType, controlPath }) => {
|
|
|
94
105
|
dispatchEvent?.(name, eventData);
|
|
95
106
|
};
|
|
96
107
|
var trackVariableSyncToV3 = ({ variableLabel, action }) => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const name = config.names.variables.variableSyncToV3;
|
|
103
|
-
const isSync = action === "sync";
|
|
104
|
-
dispatchEvent?.(name, {
|
|
105
|
-
interaction_type: "click",
|
|
106
|
-
target_type: variableLabel,
|
|
107
|
-
target_name: isSync ? "sync_to_v3" : "unsync_to_v3",
|
|
108
|
-
interaction_result: isSync ? "var_is_synced_to_V3" : "var_is_unsynced_from_V3",
|
|
109
|
-
target_location: "widget_panel",
|
|
110
|
-
location_l1: "var_manager",
|
|
111
|
-
interaction_description: isSync ? `user_synced_${variableLabel}_to_v3` : `user_unsync_${variableLabel}_from_v3`
|
|
112
|
-
});
|
|
113
|
-
} catch {
|
|
108
|
+
const { dispatchEvent, config } = (0, import_events.getMixpanel)();
|
|
109
|
+
if (!config?.names?.variables?.variableSyncToV3) {
|
|
110
|
+
return;
|
|
114
111
|
}
|
|
112
|
+
const name = config.names.variables.variableSyncToV3;
|
|
113
|
+
const isSync = action === "sync";
|
|
114
|
+
dispatchEvent?.(name, {
|
|
115
|
+
interaction_type: "click",
|
|
116
|
+
target_type: variableLabel,
|
|
117
|
+
target_name: isSync ? "sync_to_v3" : "unsync_to_v3",
|
|
118
|
+
interaction_result: isSync ? "var_is_synced_to_V3" : "var_is_unsynced_from_V3",
|
|
119
|
+
target_location: "widget_panel",
|
|
120
|
+
location_l1: "var_manager",
|
|
121
|
+
interaction_description: isSync ? `user_synced_${variableLabel}_to_v3` : `user_unsync_${variableLabel}_from_v3`
|
|
122
|
+
});
|
|
115
123
|
};
|
|
116
124
|
|
|
117
125
|
// src/utils/validations.ts
|
|
@@ -508,7 +516,7 @@ var service = {
|
|
|
508
516
|
return variables;
|
|
509
517
|
});
|
|
510
518
|
},
|
|
511
|
-
create: ({ type, label, value }) => {
|
|
519
|
+
create: ({ type, label, value }, options = {}) => {
|
|
512
520
|
return apiClient.create(type, label, value).then((response) => {
|
|
513
521
|
const { success, data: payload } = response.data;
|
|
514
522
|
if (!success) {
|
|
@@ -524,13 +532,18 @@ var service = {
|
|
|
524
532
|
styleVariablesRepository.update({
|
|
525
533
|
[variableId]: createdVariable
|
|
526
534
|
});
|
|
535
|
+
trackVariableEvent({
|
|
536
|
+
varType: type,
|
|
537
|
+
action: "save",
|
|
538
|
+
...options.eventData
|
|
539
|
+
});
|
|
527
540
|
return {
|
|
528
541
|
id: variableId,
|
|
529
542
|
variable: createdVariable
|
|
530
543
|
};
|
|
531
544
|
});
|
|
532
545
|
},
|
|
533
|
-
update: (id, { label, value, type }) => {
|
|
546
|
+
update: (id, { label, value, type }, options = {}) => {
|
|
534
547
|
return apiClient.update(id, label, value, type).then((response) => {
|
|
535
548
|
const { success, data: payload } = response.data;
|
|
536
549
|
if (!success) {
|
|
@@ -546,6 +559,11 @@ var service = {
|
|
|
546
559
|
styleVariablesRepository.update({
|
|
547
560
|
[variableId]: updatedVariable
|
|
548
561
|
});
|
|
562
|
+
trackVariableEvent({
|
|
563
|
+
varType: updatedVariable.type,
|
|
564
|
+
action: "update",
|
|
565
|
+
...options.eventData
|
|
566
|
+
});
|
|
549
567
|
return {
|
|
550
568
|
id: variableId,
|
|
551
569
|
variable: updatedVariable
|
|
@@ -1022,11 +1040,11 @@ var normalizeVariables = (propKey) => {
|
|
|
1022
1040
|
return variablesToList(variables).filter((variable) => matchingTypes.includes(variable.type)).map(toNormalizedVariable);
|
|
1023
1041
|
};
|
|
1024
1042
|
var extractId = ({ id }) => id;
|
|
1025
|
-
var createVariable = (newVariable) => {
|
|
1026
|
-
return service.create(newVariable).then(extractId);
|
|
1043
|
+
var createVariable = (newVariable, options) => {
|
|
1044
|
+
return service.create(newVariable, options).then(extractId);
|
|
1027
1045
|
};
|
|
1028
|
-
var updateVariable = (updateId, { value, label, type }) => {
|
|
1029
|
-
return service.update(updateId, { value, label, type }).then(extractId);
|
|
1046
|
+
var updateVariable = (updateId, { value, label, type }, options) => {
|
|
1047
|
+
return service.update(updateId, { value, label, type }, options).then(extractId);
|
|
1030
1048
|
};
|
|
1031
1049
|
var deleteVariable = (deleteId) => {
|
|
1032
1050
|
return service.delete(deleteId).then(extractId);
|
|
@@ -2353,8 +2371,8 @@ var StopSyncConfirmationDialog = ({ open, onClose, onConfirm }) => {
|
|
|
2353
2371
|
// src/init.ts
|
|
2354
2372
|
var import_editor = require("@elementor/editor");
|
|
2355
2373
|
var import_editor_controls18 = require("@elementor/editor-controls");
|
|
2356
|
-
var
|
|
2357
|
-
var
|
|
2374
|
+
var import_editor_mcp3 = require("@elementor/editor-mcp");
|
|
2375
|
+
var import_editor_props11 = require("@elementor/editor-props");
|
|
2358
2376
|
var import_menus = require("@elementor/menus");
|
|
2359
2377
|
|
|
2360
2378
|
// src/components/global-styles-import-listener.tsx
|
|
@@ -2373,12 +2391,84 @@ function GlobalStylesImportListener() {
|
|
|
2373
2391
|
return null;
|
|
2374
2392
|
}
|
|
2375
2393
|
|
|
2394
|
+
// src/components/mcp-variable-connect-listener.tsx
|
|
2395
|
+
var import_react15 = require("react");
|
|
2396
|
+
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
2397
|
+
|
|
2398
|
+
// src/utils/extract-variables-from-style-value.ts
|
|
2399
|
+
var import_editor_props3 = require("@elementor/editor-props");
|
|
2400
|
+
var VARIABLE_TYPE_KEYS = [
|
|
2401
|
+
"global-color-variable",
|
|
2402
|
+
"global-font-variable",
|
|
2403
|
+
"global-size-variable",
|
|
2404
|
+
"global-custom-size-variable"
|
|
2405
|
+
];
|
|
2406
|
+
function tryExtractVariable(value) {
|
|
2407
|
+
for (const key of VARIABLE_TYPE_KEYS) {
|
|
2408
|
+
const propUtil = (0, import_editor_props3.getPropSchemaFromCache)(key);
|
|
2409
|
+
if (propUtil?.isValid(value)) {
|
|
2410
|
+
return {
|
|
2411
|
+
type: key,
|
|
2412
|
+
variableId: propUtil.extract(value)
|
|
2413
|
+
};
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
return null;
|
|
2417
|
+
}
|
|
2418
|
+
function traverse(value, path, result) {
|
|
2419
|
+
const extracted = tryExtractVariable(value);
|
|
2420
|
+
if (extracted) {
|
|
2421
|
+
result.push({
|
|
2422
|
+
...extracted,
|
|
2423
|
+
controlPath: path.join(".")
|
|
2424
|
+
});
|
|
2425
|
+
return;
|
|
2426
|
+
}
|
|
2427
|
+
if ((0, import_editor_props3.isTransformable)(value)) {
|
|
2428
|
+
traverse(value.value, path, result);
|
|
2429
|
+
return;
|
|
2430
|
+
}
|
|
2431
|
+
if (value && typeof value === "object") {
|
|
2432
|
+
for (const [key, val] of Object.entries(value)) {
|
|
2433
|
+
traverse(val, [...path, key], result);
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
function extractVariablesFromStyleValue(styleValue) {
|
|
2438
|
+
const result = [];
|
|
2439
|
+
traverse(styleValue, [], result);
|
|
2440
|
+
return result;
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
// src/components/mcp-variable-connect-listener.tsx
|
|
2444
|
+
function McpVariableConnectListener() {
|
|
2445
|
+
(0, import_react15.useEffect)(() => {
|
|
2446
|
+
const handleMcpStylesApplied = (event) => {
|
|
2447
|
+
const { styleValue } = event.detail;
|
|
2448
|
+
const variables = extractVariablesFromStyleValue(styleValue);
|
|
2449
|
+
variables.forEach(({ type, controlPath }) => {
|
|
2450
|
+
trackVariableEvent({
|
|
2451
|
+
varType: type,
|
|
2452
|
+
controlPath,
|
|
2453
|
+
action: "connect",
|
|
2454
|
+
executedBy: "mcp_tool"
|
|
2455
|
+
});
|
|
2456
|
+
});
|
|
2457
|
+
};
|
|
2458
|
+
window.addEventListener(import_editor_mcp.MCP_STYLES_APPLIED_EVENT, handleMcpStylesApplied);
|
|
2459
|
+
return () => {
|
|
2460
|
+
window.removeEventListener(import_editor_mcp.MCP_STYLES_APPLIED_EVENT, handleMcpStylesApplied);
|
|
2461
|
+
};
|
|
2462
|
+
}, []);
|
|
2463
|
+
return null;
|
|
2464
|
+
}
|
|
2465
|
+
|
|
2376
2466
|
// src/controls/variable-control.tsx
|
|
2377
2467
|
var React33 = __toESM(require("react"));
|
|
2378
2468
|
var import_editor_controls13 = require("@elementor/editor-controls");
|
|
2379
2469
|
|
|
2380
2470
|
// src/components/ui/variable/assigned-variable.tsx
|
|
2381
|
-
var
|
|
2471
|
+
var import_react22 = require("react");
|
|
2382
2472
|
var React24 = __toESM(require("react"));
|
|
2383
2473
|
var import_editor_controls8 = require("@elementor/editor-controls");
|
|
2384
2474
|
var import_icons12 = require("@elementor/icons");
|
|
@@ -2402,25 +2492,25 @@ function createUnlinkHandler(variable, propTypeKey, setValue) {
|
|
|
2402
2492
|
|
|
2403
2493
|
// src/components/variable-selection-popover.tsx
|
|
2404
2494
|
var React22 = __toESM(require("react"));
|
|
2405
|
-
var
|
|
2495
|
+
var import_react21 = require("react");
|
|
2406
2496
|
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
2407
2497
|
|
|
2408
2498
|
// src/context/variable-selection-popover.context.tsx
|
|
2409
2499
|
var React15 = __toESM(require("react"));
|
|
2410
|
-
var
|
|
2500
|
+
var import_react16 = require("react");
|
|
2411
2501
|
var import_ui15 = require("@elementor/ui");
|
|
2412
|
-
var PopoverContentRefContext = (0,
|
|
2502
|
+
var PopoverContentRefContext = (0, import_react16.createContext)(null);
|
|
2413
2503
|
var PopoverContentRefContextProvider = ({ children }) => {
|
|
2414
|
-
const [anchorRef, setAnchorRef] = (0,
|
|
2504
|
+
const [anchorRef, setAnchorRef] = (0, import_react16.useState)(null);
|
|
2415
2505
|
return /* @__PURE__ */ React15.createElement(PopoverContentRefContext.Provider, { value: anchorRef }, /* @__PURE__ */ React15.createElement(import_ui15.Box, { ref: setAnchorRef }, children));
|
|
2416
2506
|
};
|
|
2417
2507
|
var usePopoverContentRef = () => {
|
|
2418
|
-
return (0,
|
|
2508
|
+
return (0, import_react16.useContext)(PopoverContentRefContext);
|
|
2419
2509
|
};
|
|
2420
2510
|
|
|
2421
2511
|
// src/components/variable-creation.tsx
|
|
2422
2512
|
var React17 = __toESM(require("react"));
|
|
2423
|
-
var
|
|
2513
|
+
var import_react17 = require("react");
|
|
2424
2514
|
var import_editor_controls5 = require("@elementor/editor-controls");
|
|
2425
2515
|
var import_editor_ui6 = require("@elementor/editor-ui");
|
|
2426
2516
|
var import_icons6 = require("@elementor/icons");
|
|
@@ -2441,7 +2531,7 @@ var useInitialValue = () => {
|
|
|
2441
2531
|
|
|
2442
2532
|
// src/hooks/use-variable-bound-prop.ts
|
|
2443
2533
|
var import_editor_controls4 = require("@elementor/editor-controls");
|
|
2444
|
-
var
|
|
2534
|
+
var import_editor_props4 = require("@elementor/editor-props");
|
|
2445
2535
|
var useVariableBoundProp = () => {
|
|
2446
2536
|
const { propTypeUtil } = useVariableType();
|
|
2447
2537
|
const boundProp = (0, import_editor_controls4.useBoundProp)(propTypeUtil);
|
|
@@ -2461,7 +2551,7 @@ var resolveBoundPropAndSetValue = (value, boundProp) => {
|
|
|
2461
2551
|
return boundProp.setValue(value);
|
|
2462
2552
|
};
|
|
2463
2553
|
var unwrapValue = (input) => {
|
|
2464
|
-
if ((0,
|
|
2554
|
+
if ((0, import_editor_props4.isTransformable)(input)) {
|
|
2465
2555
|
return input.value;
|
|
2466
2556
|
}
|
|
2467
2557
|
return input;
|
|
@@ -2477,15 +2567,15 @@ var FormField = ({ id, label, errorMsg, noticeMsg, children }) => {
|
|
|
2477
2567
|
// src/components/variable-creation.tsx
|
|
2478
2568
|
var SIZE2 = "tiny";
|
|
2479
2569
|
var VariableCreation = ({ onGoBack, onClose }) => {
|
|
2480
|
-
const { icon: VariableIcon, valueField: ValueField,
|
|
2570
|
+
const { icon: VariableIcon, valueField: ValueField, propTypeUtil } = useVariableType();
|
|
2481
2571
|
const { setVariableValue: setVariable, path } = useVariableBoundProp();
|
|
2482
2572
|
const { propType } = (0, import_editor_controls5.useBoundProp)();
|
|
2483
2573
|
const initialValue = useInitialValue();
|
|
2484
|
-
const [value, setValue] = (0,
|
|
2485
|
-
const [label, setLabel] = (0,
|
|
2486
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
2487
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
2488
|
-
const [propTypeKey, setPropTypeKey] = (0,
|
|
2574
|
+
const [value, setValue] = (0, import_react17.useState)(initialValue);
|
|
2575
|
+
const [label, setLabel] = (0, import_react17.useState)("");
|
|
2576
|
+
const [errorMessage, setErrorMessage] = (0, import_react17.useState)("");
|
|
2577
|
+
const [valueFieldError, setValueFieldError] = (0, import_react17.useState)("");
|
|
2578
|
+
const [propTypeKey, setPropTypeKey] = (0, import_react17.useState)(propTypeUtil.key);
|
|
2489
2579
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
2490
2580
|
const resetFields = () => {
|
|
2491
2581
|
setValue("");
|
|
@@ -2498,11 +2588,14 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2498
2588
|
onClose();
|
|
2499
2589
|
};
|
|
2500
2590
|
const handleCreateAndTrack = () => {
|
|
2501
|
-
createVariable(
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2591
|
+
createVariable(
|
|
2592
|
+
{
|
|
2593
|
+
value,
|
|
2594
|
+
label,
|
|
2595
|
+
type: propTypeKey
|
|
2596
|
+
},
|
|
2597
|
+
{ eventData: { controlPath: path.join(".") } }
|
|
2598
|
+
).then((key) => {
|
|
2506
2599
|
setVariable(key);
|
|
2507
2600
|
closePopover();
|
|
2508
2601
|
}).catch((error) => {
|
|
@@ -2517,11 +2610,6 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2517
2610
|
}
|
|
2518
2611
|
setErrorMessage(ERROR_MESSAGES.UNEXPECTED_ERROR);
|
|
2519
2612
|
});
|
|
2520
|
-
trackVariableEvent({
|
|
2521
|
-
varType: variableType,
|
|
2522
|
-
controlPath: path.join("."),
|
|
2523
|
-
action: "save"
|
|
2524
|
-
});
|
|
2525
2613
|
};
|
|
2526
2614
|
const hasEmptyFields = () => {
|
|
2527
2615
|
if ("" === label.trim()) {
|
|
@@ -2606,7 +2694,7 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2606
2694
|
|
|
2607
2695
|
// src/components/variable-edit.tsx
|
|
2608
2696
|
var React19 = __toESM(require("react"));
|
|
2609
|
-
var
|
|
2697
|
+
var import_react19 = require("react");
|
|
2610
2698
|
var import_editor_controls6 = require("@elementor/editor-controls");
|
|
2611
2699
|
var import_editor_current_user3 = require("@elementor/editor-current-user");
|
|
2612
2700
|
var import_editor_ui7 = require("@elementor/editor-ui");
|
|
@@ -2616,7 +2704,7 @@ var import_i18n13 = require("@wordpress/i18n");
|
|
|
2616
2704
|
|
|
2617
2705
|
// src/components/ui/edit-confirmation-dialog.tsx
|
|
2618
2706
|
var React18 = __toESM(require("react"));
|
|
2619
|
-
var
|
|
2707
|
+
var import_react18 = require("react");
|
|
2620
2708
|
var import_icons7 = require("@elementor/icons");
|
|
2621
2709
|
var import_ui18 = require("@elementor/ui");
|
|
2622
2710
|
var import_i18n12 = require("@wordpress/i18n");
|
|
@@ -2626,7 +2714,7 @@ var EditConfirmationDialog = ({
|
|
|
2626
2714
|
onConfirm,
|
|
2627
2715
|
onSuppressMessage
|
|
2628
2716
|
}) => {
|
|
2629
|
-
const [dontShowAgain, setDontShowAgain] = (0,
|
|
2717
|
+
const [dontShowAgain, setDontShowAgain] = (0, import_react18.useState)(false);
|
|
2630
2718
|
const handleSave = () => {
|
|
2631
2719
|
if (dontShowAgain) {
|
|
2632
2720
|
onSuppressMessage?.();
|
|
@@ -2657,23 +2745,23 @@ var SIZE3 = "tiny";
|
|
|
2657
2745
|
var DELETE_LABEL = (0, import_i18n13.__)("Delete variable", "elementor");
|
|
2658
2746
|
var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
2659
2747
|
const { icon: VariableIcon, valueField: ValueField, variableType, propTypeUtil } = useVariableType();
|
|
2660
|
-
const { setVariableValue: notifyBoundPropChange, variableId } = useVariableBoundProp();
|
|
2748
|
+
const { setVariableValue: notifyBoundPropChange, variableId, path } = useVariableBoundProp();
|
|
2661
2749
|
const { propType } = (0, import_editor_controls6.useBoundProp)();
|
|
2662
2750
|
const [isMessageSuppressed, suppressMessage] = (0, import_editor_current_user3.useSuppressedMessage)(EDIT_CONFIRMATION_DIALOG_ID);
|
|
2663
|
-
const [deleteConfirmation, setDeleteConfirmation] = (0,
|
|
2664
|
-
const [editConfirmation, setEditConfirmation] = (0,
|
|
2665
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
2666
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
2751
|
+
const [deleteConfirmation, setDeleteConfirmation] = (0, import_react19.useState)(false);
|
|
2752
|
+
const [editConfirmation, setEditConfirmation] = (0, import_react19.useState)(false);
|
|
2753
|
+
const [errorMessage, setErrorMessage] = (0, import_react19.useState)("");
|
|
2754
|
+
const [valueFieldError, setValueFieldError] = (0, import_react19.useState)("");
|
|
2667
2755
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
2668
2756
|
const variable = useVariable(editId);
|
|
2669
|
-
const [propTypeKey, setPropTypeKey] = (0,
|
|
2757
|
+
const [propTypeKey, setPropTypeKey] = (0, import_react19.useState)(variable?.type ?? propTypeUtil.key);
|
|
2670
2758
|
if (!variable) {
|
|
2671
2759
|
throw new Error(`Global ${variableType} variable not found`);
|
|
2672
2760
|
}
|
|
2673
2761
|
const userPermissions = usePermissions();
|
|
2674
|
-
const [value, setValue] = (0,
|
|
2675
|
-
const [label, setLabel] = (0,
|
|
2676
|
-
(0,
|
|
2762
|
+
const [value, setValue] = (0, import_react19.useState)(() => variable.value);
|
|
2763
|
+
const [label, setLabel] = (0, import_react19.useState)(() => variable.label);
|
|
2764
|
+
(0, import_react19.useEffect)(() => {
|
|
2677
2765
|
styleVariablesRepository.update({
|
|
2678
2766
|
[editId]: {
|
|
2679
2767
|
...variable,
|
|
@@ -2696,7 +2784,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2696
2784
|
const handleSaveVariable = () => {
|
|
2697
2785
|
const typeChanged = propTypeKey !== variable.type;
|
|
2698
2786
|
const updatePayload = typeChanged ? { value, label, type: propTypeKey } : { value, label };
|
|
2699
|
-
updateVariable(editId, updatePayload).then(() => {
|
|
2787
|
+
updateVariable(editId, updatePayload, { eventData: { controlPath: path.join(".") } }).then(() => {
|
|
2700
2788
|
maybeTriggerBoundPropChange();
|
|
2701
2789
|
onSubmit?.();
|
|
2702
2790
|
}).catch((error) => {
|
|
@@ -2838,7 +2926,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2838
2926
|
};
|
|
2839
2927
|
|
|
2840
2928
|
// src/components/variables-selection.tsx
|
|
2841
|
-
var
|
|
2929
|
+
var import_react20 = require("react");
|
|
2842
2930
|
var React21 = __toESM(require("react"));
|
|
2843
2931
|
var import_editor_controls7 = require("@elementor/editor-controls");
|
|
2844
2932
|
var import_editor_ui9 = require("@elementor/editor-ui");
|
|
@@ -2946,7 +3034,7 @@ var getProUpgradeUrl = (variableType) => `https://go.elementor.com/renew-license
|
|
|
2946
3034
|
var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled = false }) => {
|
|
2947
3035
|
const { icon: VariableIcon, startIcon, variableType, propTypeUtil, emptyState } = useVariableType();
|
|
2948
3036
|
const { value: variable, setValue: setVariable, path } = useVariableBoundProp();
|
|
2949
|
-
const [searchValue, setSearchValue] = (0,
|
|
3037
|
+
const [searchValue, setSearchValue] = (0, import_react20.useState)("");
|
|
2950
3038
|
const {
|
|
2951
3039
|
list: variables,
|
|
2952
3040
|
hasMatches: hasSearchResults,
|
|
@@ -3024,7 +3112,7 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled =
|
|
|
3024
3112
|
const handleClearSearch = () => {
|
|
3025
3113
|
setSearchValue("");
|
|
3026
3114
|
};
|
|
3027
|
-
(0,
|
|
3115
|
+
(0, import_react20.useEffect)(() => {
|
|
3028
3116
|
if (disabled) {
|
|
3029
3117
|
(0, import_editor_controls7.trackViewPromotion)({
|
|
3030
3118
|
target_name: "variables_popover",
|
|
@@ -3132,8 +3220,8 @@ var VIEW_LIST = "list";
|
|
|
3132
3220
|
var VIEW_ADD = "add";
|
|
3133
3221
|
var VIEW_EDIT = "edit";
|
|
3134
3222
|
var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
|
|
3135
|
-
const [currentView, setCurrentView] = (0,
|
|
3136
|
-
const [editId, setEditId] = (0,
|
|
3223
|
+
const [currentView, setCurrentView] = (0, import_react21.useState)(VIEW_LIST);
|
|
3224
|
+
const [editId, setEditId] = (0, import_react21.useState)("");
|
|
3137
3225
|
const onSettingsAvailable = (0, import_editor_v1_adapters2.isExperimentActive)("e_variables_manager") ? () => {
|
|
3138
3226
|
window.dispatchEvent(
|
|
3139
3227
|
new CustomEvent("elementor/toggle-design-system", { detail: { tab: "variables" } })
|
|
@@ -3245,8 +3333,8 @@ var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
|
|
|
3245
3333
|
var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
3246
3334
|
const { startIcon, propTypeUtil } = getVariableType(propTypeKey);
|
|
3247
3335
|
const { setValue } = (0, import_editor_controls8.useBoundProp)();
|
|
3248
|
-
const anchorRef = (0,
|
|
3249
|
-
const popupId = (0,
|
|
3336
|
+
const anchorRef = (0, import_react22.useRef)(null);
|
|
3337
|
+
const popupId = (0, import_react22.useId)();
|
|
3250
3338
|
const popupState = (0, import_ui24.usePopupState)({
|
|
3251
3339
|
variant: "popover",
|
|
3252
3340
|
popupId: `elementor-variables-list-${popupId}`
|
|
@@ -3286,14 +3374,14 @@ var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
|
3286
3374
|
|
|
3287
3375
|
// src/components/ui/variable/deleted-variable.tsx
|
|
3288
3376
|
var React28 = __toESM(require("react"));
|
|
3289
|
-
var
|
|
3377
|
+
var import_react24 = require("react");
|
|
3290
3378
|
var import_editor_controls10 = require("@elementor/editor-controls");
|
|
3291
3379
|
var import_ui28 = require("@elementor/ui");
|
|
3292
3380
|
var import_i18n19 = require("@wordpress/i18n");
|
|
3293
3381
|
|
|
3294
3382
|
// src/components/variable-restore.tsx
|
|
3295
3383
|
var React25 = __toESM(require("react"));
|
|
3296
|
-
var
|
|
3384
|
+
var import_react23 = require("react");
|
|
3297
3385
|
var import_editor_controls9 = require("@elementor/editor-controls");
|
|
3298
3386
|
var import_editor_ui11 = require("@elementor/editor-ui");
|
|
3299
3387
|
var import_ui25 = require("@elementor/ui");
|
|
@@ -3307,11 +3395,11 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
3307
3395
|
if (!variable) {
|
|
3308
3396
|
throw new Error(`Global ${variableType} variable not found`);
|
|
3309
3397
|
}
|
|
3310
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
3311
|
-
const [valueFieldError, setValueFieldError] = (0,
|
|
3312
|
-
const [label, setLabel] = (0,
|
|
3313
|
-
const [value, setValue] = (0,
|
|
3314
|
-
const [propTypeKey, setPropTypeKey] = (0,
|
|
3398
|
+
const [errorMessage, setErrorMessage] = (0, import_react23.useState)("");
|
|
3399
|
+
const [valueFieldError, setValueFieldError] = (0, import_react23.useState)("");
|
|
3400
|
+
const [label, setLabel] = (0, import_react23.useState)(variable.label);
|
|
3401
|
+
const [value, setValue] = (0, import_react23.useState)(variable.value);
|
|
3402
|
+
const [propTypeKey, setPropTypeKey] = (0, import_react23.useState)(variable?.type ?? propTypeUtil.key);
|
|
3315
3403
|
const { labelFieldError, setLabelFieldError } = useLabelError({
|
|
3316
3404
|
value: variable.label,
|
|
3317
3405
|
message: ERROR_MESSAGES.DUPLICATED_LABEL
|
|
@@ -3468,11 +3556,11 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
3468
3556
|
const { propTypeUtil } = getVariableType(propTypeKey);
|
|
3469
3557
|
const boundProp = (0, import_editor_controls10.useBoundProp)();
|
|
3470
3558
|
const userPermissions = usePermissions();
|
|
3471
|
-
const [showInfotip, setShowInfotip] = (0,
|
|
3559
|
+
const [showInfotip, setShowInfotip] = (0, import_react24.useState)(false);
|
|
3472
3560
|
const toggleInfotip = () => setShowInfotip((prev) => !prev);
|
|
3473
3561
|
const closeInfotip = () => setShowInfotip(false);
|
|
3474
|
-
const deletedChipAnchorRef = (0,
|
|
3475
|
-
const popupId = (0,
|
|
3562
|
+
const deletedChipAnchorRef = (0, import_react24.useRef)(null);
|
|
3563
|
+
const popupId = (0, import_react24.useId)();
|
|
3476
3564
|
const popupState = (0, import_ui28.usePopupState)({
|
|
3477
3565
|
variant: "popover",
|
|
3478
3566
|
popupId: `elementor-variables-restore-${popupId}`
|
|
@@ -3559,7 +3647,7 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
3559
3647
|
|
|
3560
3648
|
// src/components/ui/variable/mismatch-variable.tsx
|
|
3561
3649
|
var React30 = __toESM(require("react"));
|
|
3562
|
-
var
|
|
3650
|
+
var import_react25 = require("react");
|
|
3563
3651
|
var import_editor_controls11 = require("@elementor/editor-controls");
|
|
3564
3652
|
var import_ui30 = require("@elementor/ui");
|
|
3565
3653
|
var import_i18n21 = require("@wordpress/i18n");
|
|
@@ -3597,13 +3685,13 @@ var MismatchVariableAlert = ({ onClose, onClear, triggerSelect }) => {
|
|
|
3597
3685
|
// src/components/ui/variable/mismatch-variable.tsx
|
|
3598
3686
|
var MismatchVariable = ({ variable }) => {
|
|
3599
3687
|
const { setValue, value } = (0, import_editor_controls11.useBoundProp)();
|
|
3600
|
-
const anchorRef = (0,
|
|
3601
|
-
const popupId = (0,
|
|
3688
|
+
const anchorRef = (0, import_react25.useRef)(null);
|
|
3689
|
+
const popupId = (0, import_react25.useId)();
|
|
3602
3690
|
const popupState = (0, import_ui30.usePopupState)({
|
|
3603
3691
|
variant: "popover",
|
|
3604
3692
|
popupId: `elementor-variables-list-${popupId}`
|
|
3605
3693
|
});
|
|
3606
|
-
const [infotipVisible, setInfotipVisible] = (0,
|
|
3694
|
+
const [infotipVisible, setInfotipVisible] = (0, import_react25.useState)(false);
|
|
3607
3695
|
const toggleInfotip = () => setInfotipVisible((prev) => !prev);
|
|
3608
3696
|
const closeInfotip = () => setInfotipVisible(false);
|
|
3609
3697
|
const triggerSelect = () => {
|
|
@@ -3676,7 +3764,7 @@ var MismatchVariable = ({ variable }) => {
|
|
|
3676
3764
|
|
|
3677
3765
|
// src/components/ui/variable/missing-variable.tsx
|
|
3678
3766
|
var React32 = __toESM(require("react"));
|
|
3679
|
-
var
|
|
3767
|
+
var import_react26 = require("react");
|
|
3680
3768
|
var import_editor_controls12 = require("@elementor/editor-controls");
|
|
3681
3769
|
var import_ui32 = require("@elementor/ui");
|
|
3682
3770
|
var import_i18n23 = require("@wordpress/i18n");
|
|
@@ -3706,7 +3794,7 @@ var MissingVariableAlert = ({ onClose, onClear }) => {
|
|
|
3706
3794
|
// src/components/ui/variable/missing-variable.tsx
|
|
3707
3795
|
var MissingVariable = () => {
|
|
3708
3796
|
const { setValue } = (0, import_editor_controls12.useBoundProp)();
|
|
3709
|
-
const [infotipVisible, setInfotipVisible] = (0,
|
|
3797
|
+
const [infotipVisible, setInfotipVisible] = (0, import_react26.useState)(false);
|
|
3710
3798
|
const toggleInfotip = () => setInfotipVisible((prev) => !prev);
|
|
3711
3799
|
const closeInfotip = () => setInfotipVisible(false);
|
|
3712
3800
|
const clearValue = () => setValue(null);
|
|
@@ -3804,11 +3892,11 @@ var getFontConfigs = () => {
|
|
|
3804
3892
|
};
|
|
3805
3893
|
|
|
3806
3894
|
// src/mcp/variable-tool-prompt.ts
|
|
3807
|
-
var
|
|
3895
|
+
var import_editor_mcp2 = require("@elementor/editor-mcp");
|
|
3808
3896
|
var import_utils3 = require("@elementor/utils");
|
|
3809
3897
|
var MANAGE_VARIABLES_GUIDE_URI = "elementor://variables/tools/manage-global-variable-guide";
|
|
3810
3898
|
var generateVariablesPrompt = () => {
|
|
3811
|
-
const prompt = (0,
|
|
3899
|
+
const prompt = (0, import_editor_mcp2.toolPrompts)("manage-global-variable");
|
|
3812
3900
|
const proIsActive = (0, import_utils3.isProActive)();
|
|
3813
3901
|
const sizeVariableSection = proIsActive ? `- **global-size-variable** \u2014 A simple CSS length with a unit (Elementor Pro). Use this for fixed spacing, font sizes, or layout values. Example: \`16px\`, \`1.5rem\`, \`2em\`, \`10vh\`
|
|
3814
3902
|
- **global-custom-size-variable** \u2014 Any CSS size expression that goes beyond a simple number + unit (Elementor Pro). Use this when the value is a CSS function, a keyword, or a combination of units that \`global-size-variable\` cannot represent. Example: \`auto\`, \`clamp(1rem, 2vw, 2rem)\`, \`calc(100% - 32px)\`, \`min(50vw, 600px)\`, \`300ms\`, \`2ch\`. When in doubt: if the value contains a function call or a keyword, use \`global-custom-size-variable\`.` : `- ~~global-size-variable~~ \u2014 requires Elementor Pro (not available on this site)
|
|
@@ -4016,7 +4104,7 @@ function getServiceActions(svc) {
|
|
|
4016
4104
|
if (valueError) {
|
|
4017
4105
|
throw new Error(valueError);
|
|
4018
4106
|
}
|
|
4019
|
-
return svc.create({ type, label, value });
|
|
4107
|
+
return svc.create({ type, label, value }, { eventData: { executedBy: "mcp_tool" } });
|
|
4020
4108
|
},
|
|
4021
4109
|
update({ id, label, value }) {
|
|
4022
4110
|
if (!id || !label || !value) {
|
|
@@ -4033,7 +4121,7 @@ function getServiceActions(svc) {
|
|
|
4033
4121
|
throw new Error(valueError);
|
|
4034
4122
|
}
|
|
4035
4123
|
}
|
|
4036
|
-
return svc.update(id, { label, value });
|
|
4124
|
+
return svc.update(id, { label, value }, { eventData: { executedBy: "mcp_tool" } });
|
|
4037
4125
|
},
|
|
4038
4126
|
delete({ id }) {
|
|
4039
4127
|
if (!id) {
|
|
@@ -4059,19 +4147,19 @@ function initMcp(reg, canvasMcpEntry) {
|
|
|
4059
4147
|
// src/register-variable-types.tsx
|
|
4060
4148
|
var React37 = __toESM(require("react"));
|
|
4061
4149
|
var import_editor_controls16 = require("@elementor/editor-controls");
|
|
4062
|
-
var
|
|
4150
|
+
var import_editor_props6 = require("@elementor/editor-props");
|
|
4063
4151
|
var import_editor_ui13 = require("@elementor/editor-ui");
|
|
4064
4152
|
var import_icons16 = require("@elementor/icons");
|
|
4065
4153
|
var import_i18n26 = require("@wordpress/i18n");
|
|
4066
4154
|
|
|
4067
4155
|
// src/components/fields/color-field.tsx
|
|
4068
4156
|
var React35 = __toESM(require("react"));
|
|
4069
|
-
var
|
|
4157
|
+
var import_react27 = require("react");
|
|
4070
4158
|
var import_ui33 = require("@elementor/ui");
|
|
4071
4159
|
var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
4072
|
-
const [color, setColor] = (0,
|
|
4073
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
4074
|
-
const defaultRef = (0,
|
|
4160
|
+
const [color, setColor] = (0, import_react27.useState)(value);
|
|
4161
|
+
const [errorMessage, setErrorMessage] = (0, import_react27.useState)("");
|
|
4162
|
+
const defaultRef = (0, import_react27.useRef)(null);
|
|
4075
4163
|
const anchorRef = usePopoverContentRef() ?? defaultRef.current;
|
|
4076
4164
|
const handleChange = (newValue) => {
|
|
4077
4165
|
setColor(newValue);
|
|
@@ -4110,20 +4198,20 @@ var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
|
4110
4198
|
|
|
4111
4199
|
// src/components/fields/font-field.tsx
|
|
4112
4200
|
var React36 = __toESM(require("react"));
|
|
4113
|
-
var
|
|
4201
|
+
var import_react28 = require("react");
|
|
4114
4202
|
var import_editor_controls15 = require("@elementor/editor-controls");
|
|
4115
4203
|
var import_editor_ui12 = require("@elementor/editor-ui");
|
|
4116
4204
|
var import_icons15 = require("@elementor/icons");
|
|
4117
4205
|
var import_ui34 = require("@elementor/ui");
|
|
4118
4206
|
var import_i18n25 = require("@wordpress/i18n");
|
|
4119
4207
|
var FontField = ({ value, onChange, onValidationChange }) => {
|
|
4120
|
-
const [fontFamily, setFontFamily] = (0,
|
|
4121
|
-
const defaultRef = (0,
|
|
4208
|
+
const [fontFamily, setFontFamily] = (0, import_react28.useState)(value);
|
|
4209
|
+
const defaultRef = (0, import_react28.useRef)(null);
|
|
4122
4210
|
const anchorRef = usePopoverContentRef() ?? defaultRef.current;
|
|
4123
4211
|
const fontPopoverState = (0, import_ui34.usePopupState)({ variant: "popover" });
|
|
4124
4212
|
const fontFamilies = (0, import_editor_controls15.useFontFamilies)();
|
|
4125
4213
|
const sectionWidth = (0, import_editor_ui12.useSectionWidth)();
|
|
4126
|
-
const mapFontSubs = (0,
|
|
4214
|
+
const mapFontSubs = (0, import_react28.useMemo)(() => {
|
|
4127
4215
|
return fontFamilies.map(({ label, fonts }) => ({
|
|
4128
4216
|
label,
|
|
4129
4217
|
items: fonts
|
|
@@ -4139,7 +4227,7 @@ var FontField = ({ value, onChange, onValidationChange }) => {
|
|
|
4139
4227
|
handleChange(newFontFamily);
|
|
4140
4228
|
fontPopoverState.close();
|
|
4141
4229
|
};
|
|
4142
|
-
const id = (0,
|
|
4230
|
+
const id = (0, import_react28.useId)();
|
|
4143
4231
|
return /* @__PURE__ */ React36.createElement(React36.Fragment, null, /* @__PURE__ */ React36.createElement(
|
|
4144
4232
|
import_ui34.UnstableTag,
|
|
4145
4233
|
{
|
|
@@ -4179,9 +4267,9 @@ var FontField = ({ value, onChange, onValidationChange }) => {
|
|
|
4179
4267
|
};
|
|
4180
4268
|
|
|
4181
4269
|
// src/prop-types/size-variable-prop-type.ts
|
|
4182
|
-
var
|
|
4270
|
+
var import_editor_props5 = require("@elementor/editor-props");
|
|
4183
4271
|
var import_schema4 = require("@elementor/schema");
|
|
4184
|
-
var sizeVariablePropTypeUtil = (0,
|
|
4272
|
+
var sizeVariablePropTypeUtil = (0, import_editor_props5.createPropUtils)("global-size-variable", import_schema4.z.string());
|
|
4185
4273
|
|
|
4186
4274
|
// src/transformers/empty-transformer.tsx
|
|
4187
4275
|
var import_editor_canvas5 = require("@elementor/editor-canvas");
|
|
@@ -4196,7 +4284,7 @@ function registerVariableTypes() {
|
|
|
4196
4284
|
valueField: ColorField,
|
|
4197
4285
|
icon: import_icons16.BrushIcon,
|
|
4198
4286
|
propTypeUtil: colorVariablePropTypeUtil,
|
|
4199
|
-
fallbackPropTypeUtil:
|
|
4287
|
+
fallbackPropTypeUtil: import_editor_props6.colorPropTypeUtil,
|
|
4200
4288
|
variableType: "color",
|
|
4201
4289
|
startIcon: ({ value }) => /* @__PURE__ */ React37.createElement(ColorIndicator, { size: "inherit", component: "span", value }),
|
|
4202
4290
|
defaultValue: "#ffffff",
|
|
@@ -4225,7 +4313,7 @@ function registerVariableTypes() {
|
|
|
4225
4313
|
valueField: FontField,
|
|
4226
4314
|
icon: import_icons16.TextIcon,
|
|
4227
4315
|
propTypeUtil: fontVariablePropTypeUtil,
|
|
4228
|
-
fallbackPropTypeUtil:
|
|
4316
|
+
fallbackPropTypeUtil: import_editor_props6.stringPropTypeUtil,
|
|
4229
4317
|
variableType: "font",
|
|
4230
4318
|
defaultValue: "Roboto"
|
|
4231
4319
|
});
|
|
@@ -4233,7 +4321,7 @@ function registerVariableTypes() {
|
|
|
4233
4321
|
isActive: false,
|
|
4234
4322
|
icon: import_icons16.ExpandDiagonalIcon,
|
|
4235
4323
|
propTypeUtil: sizeVariablePropTypeUtil,
|
|
4236
|
-
fallbackPropTypeUtil:
|
|
4324
|
+
fallbackPropTypeUtil: import_editor_props6.sizePropTypeUtil,
|
|
4237
4325
|
styleTransformer: EmptyTransformer,
|
|
4238
4326
|
variableType: "size",
|
|
4239
4327
|
selectionFilter: () => [],
|
|
@@ -4259,7 +4347,7 @@ function registerVariableTypes() {
|
|
|
4259
4347
|
|
|
4260
4348
|
// src/renderers/style-variables-renderer.tsx
|
|
4261
4349
|
var React38 = __toESM(require("react"));
|
|
4262
|
-
var
|
|
4350
|
+
var import_react29 = require("react");
|
|
4263
4351
|
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
4264
4352
|
var import_ui35 = require("@elementor/ui");
|
|
4265
4353
|
var VARIABLES_WRAPPER = ":root";
|
|
@@ -4278,8 +4366,8 @@ function usePortalContainer() {
|
|
|
4278
4366
|
return (0, import_editor_v1_adapters4.__privateUseListenTo)((0, import_editor_v1_adapters4.commandEndEvent)("editor/documents/attach-preview"), () => (0, import_editor_v1_adapters4.getCanvasIframeDocument)()?.head);
|
|
4279
4367
|
}
|
|
4280
4368
|
function useStyleVariables() {
|
|
4281
|
-
const [variables, setVariables] = (0,
|
|
4282
|
-
(0,
|
|
4369
|
+
const [variables, setVariables] = (0, import_react29.useState)({});
|
|
4370
|
+
(0, import_react29.useEffect)(() => {
|
|
4283
4371
|
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
4284
4372
|
return () => {
|
|
4285
4373
|
unsubscribe();
|
|
@@ -4299,21 +4387,21 @@ function convertToCssVariables(variables) {
|
|
|
4299
4387
|
|
|
4300
4388
|
// src/repeater-injections.ts
|
|
4301
4389
|
var import_editor_controls17 = require("@elementor/editor-controls");
|
|
4302
|
-
var
|
|
4390
|
+
var import_editor_props10 = require("@elementor/editor-props");
|
|
4303
4391
|
|
|
4304
4392
|
// src/components/variables-repeater-item-slot.tsx
|
|
4305
4393
|
var React39 = __toESM(require("react"));
|
|
4306
|
-
var
|
|
4394
|
+
var import_editor_props9 = require("@elementor/editor-props");
|
|
4307
4395
|
var import_ui36 = require("@elementor/ui");
|
|
4308
4396
|
var import_i18n27 = require("@wordpress/i18n");
|
|
4309
4397
|
|
|
4310
4398
|
// src/utils/size-value.ts
|
|
4311
|
-
var
|
|
4399
|
+
var import_editor_props8 = require("@elementor/editor-props");
|
|
4312
4400
|
|
|
4313
4401
|
// src/prop-types/custom-size-variable-prop-type.ts
|
|
4314
|
-
var
|
|
4402
|
+
var import_editor_props7 = require("@elementor/editor-props");
|
|
4315
4403
|
var import_schema5 = require("@elementor/schema");
|
|
4316
|
-
var customSizeVariablePropTypeUtil = (0,
|
|
4404
|
+
var customSizeVariablePropTypeUtil = (0, import_editor_props7.createPropUtils)("global-custom-size-variable", import_schema5.z.string());
|
|
4317
4405
|
|
|
4318
4406
|
// src/utils/size-value.ts
|
|
4319
4407
|
var DEFAULT_UNIT = "px";
|
|
@@ -4323,7 +4411,7 @@ function sizeValue(value) {
|
|
|
4323
4411
|
const variable = getVariable(value?.value);
|
|
4324
4412
|
return variable?.value;
|
|
4325
4413
|
}
|
|
4326
|
-
if (
|
|
4414
|
+
if (import_editor_props8.sizePropTypeUtil.isValid(value)) {
|
|
4327
4415
|
const { size, unit } = value.value;
|
|
4328
4416
|
if ("custom" !== unit) {
|
|
4329
4417
|
return `${size ?? 0}${unit ?? DEFAULT_UNIT}`;
|
|
@@ -4354,14 +4442,14 @@ var BoxShadowRepeaterColorIndicator = ({ value }) => {
|
|
|
4354
4442
|
return /* @__PURE__ */ React39.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
|
|
4355
4443
|
};
|
|
4356
4444
|
var FilterDropShadowIconIndicator = ({ value }) => {
|
|
4357
|
-
const { args } =
|
|
4358
|
-
const { color } =
|
|
4445
|
+
const { args } = import_editor_props9.cssFilterFunctionPropUtil.extract(value) || {};
|
|
4446
|
+
const { color } = import_editor_props9.dropShadowFilterPropTypeUtil.extract(args) || {};
|
|
4359
4447
|
const colorVariable = getVariable(color?.value || "");
|
|
4360
4448
|
return /* @__PURE__ */ React39.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
|
|
4361
4449
|
};
|
|
4362
4450
|
var FilterSingleSizeRepeaterLabel = ({ value }) => {
|
|
4363
|
-
const cssFilterFunction =
|
|
4364
|
-
if (
|
|
4451
|
+
const cssFilterFunction = import_editor_props9.cssFilterFunctionPropUtil.extract(value);
|
|
4452
|
+
if (import_editor_props9.dropShadowFilterPropTypeUtil.isValid(cssFilterFunction?.args)) {
|
|
4365
4453
|
return null;
|
|
4366
4454
|
}
|
|
4367
4455
|
const args = cssFilterFunction?.args;
|
|
@@ -4370,8 +4458,8 @@ var FilterSingleSizeRepeaterLabel = ({ value }) => {
|
|
|
4370
4458
|
return /* @__PURE__ */ React39.createElement(React39.Fragment, null, /* @__PURE__ */ React39.createElement(import_ui36.Box, { component: "span", style: { textTransform: "capitalize" } }, `${func}: `), /* @__PURE__ */ React39.createElement(import_ui36.Box, { component: "span" }, rendered));
|
|
4371
4459
|
};
|
|
4372
4460
|
var FilterDropShadowRepeaterLabel = ({ value }) => {
|
|
4373
|
-
const { args } =
|
|
4374
|
-
const { xAxis, yAxis, blur } =
|
|
4461
|
+
const { args } = import_editor_props9.cssFilterFunctionPropUtil.extract(value) || {};
|
|
4462
|
+
const { xAxis, yAxis, blur } = import_editor_props9.dropShadowFilterPropTypeUtil.extract(args) || {};
|
|
4375
4463
|
const labels = [];
|
|
4376
4464
|
for (const val of [xAxis, yAxis, blur]) {
|
|
4377
4465
|
const rendered = sizeValue(val);
|
|
@@ -4382,7 +4470,7 @@ var FilterDropShadowRepeaterLabel = ({ value }) => {
|
|
|
4382
4470
|
return /* @__PURE__ */ React39.createElement(import_ui36.Box, { component: "span" }, (0, import_i18n27.__)("Drop shadow:", "elementor"), " ", labels.join(" "));
|
|
4383
4471
|
};
|
|
4384
4472
|
var BoxShadowRepeaterLabel = ({ value }) => {
|
|
4385
|
-
const { position, hOffset, vOffset, blur, spread } =
|
|
4473
|
+
const { position, hOffset, vOffset, blur, spread } = import_editor_props9.shadowPropTypeUtil.extract(value) || {};
|
|
4386
4474
|
const labels = [];
|
|
4387
4475
|
for (const val of [hOffset, vOffset, blur, spread]) {
|
|
4388
4476
|
const rendered = sizeValue(val);
|
|
@@ -4395,9 +4483,9 @@ var BoxShadowRepeaterLabel = ({ value }) => {
|
|
|
4395
4483
|
};
|
|
4396
4484
|
var TransformRepeaterLabel = ({ value }) => {
|
|
4397
4485
|
const labels = [];
|
|
4398
|
-
if (
|
|
4486
|
+
if (import_editor_props9.moveTransformPropTypeUtil.isValid(value)) {
|
|
4399
4487
|
labels.push((0, import_i18n27.__)("Move:", "elementor"));
|
|
4400
|
-
const { x, y, z: z6 } =
|
|
4488
|
+
const { x, y, z: z6 } = import_editor_props9.moveTransformPropTypeUtil.extract(value) || {};
|
|
4401
4489
|
for (const val of [x, y, z6]) {
|
|
4402
4490
|
const rendered = sizeValue(val);
|
|
4403
4491
|
if (rendered) {
|
|
@@ -4411,7 +4499,7 @@ var TransitionsSizeVariableLabel = ({ value: prop }) => {
|
|
|
4411
4499
|
let label = "";
|
|
4412
4500
|
const variableId = prop?.value?.size?.value || "";
|
|
4413
4501
|
const variable = getVariable(variableId);
|
|
4414
|
-
if (variable &&
|
|
4502
|
+
if (variable && import_editor_props9.selectionSizePropTypeUtil.isValid(prop)) {
|
|
4415
4503
|
const selection = prop.value?.selection?.value?.key?.value;
|
|
4416
4504
|
if (selection) {
|
|
4417
4505
|
label += `${selection}: `;
|
|
@@ -4434,14 +4522,14 @@ function backgroundOverlayRepeaterInjections() {
|
|
|
4434
4522
|
id: "background-color-variables-icon",
|
|
4435
4523
|
component: BackgroundRepeaterColorIndicator,
|
|
4436
4524
|
condition: ({ value }) => {
|
|
4437
|
-
return hasAssignedColorVariable(
|
|
4525
|
+
return hasAssignedColorVariable(import_editor_props10.backgroundColorOverlayPropTypeUtil.extract(value)?.color);
|
|
4438
4526
|
}
|
|
4439
4527
|
});
|
|
4440
4528
|
(0, import_editor_controls17.injectIntoRepeaterItemLabel)({
|
|
4441
4529
|
id: "background-color-variables-label",
|
|
4442
4530
|
component: BackgroundRepeaterLabel,
|
|
4443
4531
|
condition: ({ value }) => {
|
|
4444
|
-
return hasAssignedColorVariable(
|
|
4532
|
+
return hasAssignedColorVariable(import_editor_props10.backgroundColorOverlayPropTypeUtil.extract(value)?.color);
|
|
4445
4533
|
}
|
|
4446
4534
|
});
|
|
4447
4535
|
}
|
|
@@ -4450,7 +4538,7 @@ function boxShadowRepeaterInjections() {
|
|
|
4450
4538
|
id: "box-shadow-color-variables-icon",
|
|
4451
4539
|
component: BoxShadowRepeaterColorIndicator,
|
|
4452
4540
|
condition: ({ value }) => {
|
|
4453
|
-
const { color } =
|
|
4541
|
+
const { color } = import_editor_props10.shadowPropTypeUtil.extract(value) || {};
|
|
4454
4542
|
return hasAssignedColorVariable(color);
|
|
4455
4543
|
}
|
|
4456
4544
|
});
|
|
@@ -4458,7 +4546,7 @@ function boxShadowRepeaterInjections() {
|
|
|
4458
4546
|
id: "color-variables-box-shadow-label",
|
|
4459
4547
|
component: BoxShadowRepeaterLabel,
|
|
4460
4548
|
condition: ({ value }) => {
|
|
4461
|
-
const { hOffset, vOffset, blur, spread } =
|
|
4549
|
+
const { hOffset, vOffset, blur, spread } = import_editor_props10.shadowPropTypeUtil.extract(value) || {};
|
|
4462
4550
|
return hasAssignedSizeVariable(hOffset) || hasAssignedSizeVariable(vOffset) || hasAssignedSizeVariable(blur) || hasAssignedSizeVariable(spread);
|
|
4463
4551
|
}
|
|
4464
4552
|
});
|
|
@@ -4468,8 +4556,8 @@ function transformRepeaterInjections() {
|
|
|
4468
4556
|
id: "transform-size-variables-label",
|
|
4469
4557
|
component: TransformRepeaterLabel,
|
|
4470
4558
|
condition: ({ value }) => {
|
|
4471
|
-
if (
|
|
4472
|
-
const { x: xAxis, y: yAxis, z: zAxis } =
|
|
4559
|
+
if (import_editor_props10.moveTransformPropTypeUtil.isValid(value)) {
|
|
4560
|
+
const { x: xAxis, y: yAxis, z: zAxis } = import_editor_props10.moveTransformPropTypeUtil.extract(value) || {};
|
|
4473
4561
|
return hasAssignedSizeVariable(xAxis) || hasAssignedSizeVariable(yAxis) || hasAssignedSizeVariable(zAxis);
|
|
4474
4562
|
}
|
|
4475
4563
|
return false;
|
|
@@ -4481,7 +4569,7 @@ function transitionsRepeaterInjections() {
|
|
|
4481
4569
|
id: "transition-size-variables-label",
|
|
4482
4570
|
component: TransitionsSizeVariableLabel,
|
|
4483
4571
|
condition: ({ value }) => {
|
|
4484
|
-
return hasAssignedSizeVariable(
|
|
4572
|
+
return hasAssignedSizeVariable(import_editor_props10.selectionSizePropTypeUtil.extract(value)?.size);
|
|
4485
4573
|
}
|
|
4486
4574
|
});
|
|
4487
4575
|
}
|
|
@@ -4490,12 +4578,12 @@ function filterRepeaterInjections() {
|
|
|
4490
4578
|
id: "filters-color-variables-icon",
|
|
4491
4579
|
component: FilterDropShadowIconIndicator,
|
|
4492
4580
|
condition: ({ value }) => {
|
|
4493
|
-
if (!
|
|
4581
|
+
if (!import_editor_props10.cssFilterFunctionPropUtil.isValid(value)) {
|
|
4494
4582
|
return false;
|
|
4495
4583
|
}
|
|
4496
|
-
const args =
|
|
4497
|
-
if (
|
|
4498
|
-
return hasAssignedColorVariable(
|
|
4584
|
+
const args = import_editor_props10.cssFilterFunctionPropUtil.extract(value)?.args;
|
|
4585
|
+
if (import_editor_props10.dropShadowFilterPropTypeUtil.isValid(args)) {
|
|
4586
|
+
return hasAssignedColorVariable(import_editor_props10.dropShadowFilterPropTypeUtil.extract(args)?.color);
|
|
4499
4587
|
}
|
|
4500
4588
|
return false;
|
|
4501
4589
|
}
|
|
@@ -4504,12 +4592,12 @@ function filterRepeaterInjections() {
|
|
|
4504
4592
|
id: "filters-drop-shadow-size-variables-label",
|
|
4505
4593
|
component: FilterDropShadowRepeaterLabel,
|
|
4506
4594
|
condition: ({ value }) => {
|
|
4507
|
-
if (!
|
|
4595
|
+
if (!import_editor_props10.cssFilterFunctionPropUtil.isValid(value)) {
|
|
4508
4596
|
return false;
|
|
4509
4597
|
}
|
|
4510
|
-
const args =
|
|
4511
|
-
if (
|
|
4512
|
-
const { xAxis, yAxis, blur } =
|
|
4598
|
+
const args = import_editor_props10.cssFilterFunctionPropUtil.extract(value)?.args;
|
|
4599
|
+
if (import_editor_props10.dropShadowFilterPropTypeUtil.isValid(args)) {
|
|
4600
|
+
const { xAxis, yAxis, blur } = import_editor_props10.dropShadowFilterPropTypeUtil.extract(args) || {};
|
|
4513
4601
|
return hasAssignedSizeVariable(xAxis) || hasAssignedSizeVariable(yAxis) || hasAssignedSizeVariable(blur);
|
|
4514
4602
|
}
|
|
4515
4603
|
return false;
|
|
@@ -4519,10 +4607,10 @@ function filterRepeaterInjections() {
|
|
|
4519
4607
|
id: "filters-size-variables-label",
|
|
4520
4608
|
component: FilterSingleSizeRepeaterLabel,
|
|
4521
4609
|
condition: ({ value }) => {
|
|
4522
|
-
if (!
|
|
4610
|
+
if (!import_editor_props10.cssFilterFunctionPropUtil.isValid(value)) {
|
|
4523
4611
|
return false;
|
|
4524
4612
|
}
|
|
4525
|
-
const args =
|
|
4613
|
+
const args = import_editor_props10.cssFilterFunctionPropUtil.extract(value)?.args;
|
|
4526
4614
|
return hasAssignedSizeVariable(args?.value?.size);
|
|
4527
4615
|
}
|
|
4528
4616
|
});
|
|
@@ -4563,7 +4651,7 @@ function init() {
|
|
|
4563
4651
|
useProps: usePropVariableAction
|
|
4564
4652
|
});
|
|
4565
4653
|
service.init();
|
|
4566
|
-
const variablesMcpRegistry = (0,
|
|
4654
|
+
const variablesMcpRegistry = (0, import_editor_mcp3.getMCPByDomain)("variables", {
|
|
4567
4655
|
instructions: `Everything related to V4 ( Atomic ) variables.
|
|
4568
4656
|
# Global variables
|
|
4569
4657
|
- Create/update/delete global variables
|
|
@@ -4571,7 +4659,7 @@ function init() {
|
|
|
4571
4659
|
- Get details of a global variable
|
|
4572
4660
|
`
|
|
4573
4661
|
});
|
|
4574
|
-
initMcp(variablesMcpRegistry, (0,
|
|
4662
|
+
initMcp(variablesMcpRegistry, (0, import_editor_mcp3.getMCPByDomain)("canvas"));
|
|
4575
4663
|
(0, import_editor.injectIntoTop)({
|
|
4576
4664
|
id: "canvas-style-variables-render",
|
|
4577
4665
|
component: StyleVariablesRenderer
|
|
@@ -4580,9 +4668,13 @@ function init() {
|
|
|
4580
4668
|
id: "variables-import-listener",
|
|
4581
4669
|
component: GlobalStylesImportListener
|
|
4582
4670
|
});
|
|
4671
|
+
(0, import_editor.injectIntoLogic)({
|
|
4672
|
+
id: "mcp-variable-connect-listener",
|
|
4673
|
+
component: McpVariableConnectListener
|
|
4674
|
+
});
|
|
4583
4675
|
}
|
|
4584
4676
|
function hasVariableAssigned(value) {
|
|
4585
|
-
if ((0,
|
|
4677
|
+
if ((0, import_editor_props11.isTransformable)(value)) {
|
|
4586
4678
|
return hasVariableType(value.$$type);
|
|
4587
4679
|
}
|
|
4588
4680
|
return false;
|