@elementor/editor-variables 4.3.0-948 → 4.3.0-950
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 +229 -134
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +133 -38
- 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 +27 -9
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)();
|
|
@@ -508,7 +519,7 @@ var service = {
|
|
|
508
519
|
return variables;
|
|
509
520
|
});
|
|
510
521
|
},
|
|
511
|
-
create: ({ type, label, value }) => {
|
|
522
|
+
create: ({ type, label, value }, options = {}) => {
|
|
512
523
|
return apiClient.create(type, label, value).then((response) => {
|
|
513
524
|
const { success, data: payload } = response.data;
|
|
514
525
|
if (!success) {
|
|
@@ -524,13 +535,18 @@ var service = {
|
|
|
524
535
|
styleVariablesRepository.update({
|
|
525
536
|
[variableId]: createdVariable
|
|
526
537
|
});
|
|
538
|
+
trackVariableEvent({
|
|
539
|
+
varType: type,
|
|
540
|
+
action: "save",
|
|
541
|
+
...options.eventData
|
|
542
|
+
});
|
|
527
543
|
return {
|
|
528
544
|
id: variableId,
|
|
529
545
|
variable: createdVariable
|
|
530
546
|
};
|
|
531
547
|
});
|
|
532
548
|
},
|
|
533
|
-
update: (id, { label, value, type }) => {
|
|
549
|
+
update: (id, { label, value, type }, options = {}) => {
|
|
534
550
|
return apiClient.update(id, label, value, type).then((response) => {
|
|
535
551
|
const { success, data: payload } = response.data;
|
|
536
552
|
if (!success) {
|
|
@@ -546,6 +562,11 @@ var service = {
|
|
|
546
562
|
styleVariablesRepository.update({
|
|
547
563
|
[variableId]: updatedVariable
|
|
548
564
|
});
|
|
565
|
+
trackVariableEvent({
|
|
566
|
+
varType: updatedVariable.type,
|
|
567
|
+
action: "update",
|
|
568
|
+
...options.eventData
|
|
569
|
+
});
|
|
549
570
|
return {
|
|
550
571
|
id: variableId,
|
|
551
572
|
variable: updatedVariable
|
|
@@ -1022,11 +1043,11 @@ var normalizeVariables = (propKey) => {
|
|
|
1022
1043
|
return variablesToList(variables).filter((variable) => matchingTypes.includes(variable.type)).map(toNormalizedVariable);
|
|
1023
1044
|
};
|
|
1024
1045
|
var extractId = ({ id }) => id;
|
|
1025
|
-
var createVariable = (newVariable) => {
|
|
1026
|
-
return service.create(newVariable).then(extractId);
|
|
1046
|
+
var createVariable = (newVariable, options) => {
|
|
1047
|
+
return service.create(newVariable, options).then(extractId);
|
|
1027
1048
|
};
|
|
1028
|
-
var updateVariable = (updateId, { value, label, type }) => {
|
|
1029
|
-
return service.update(updateId, { value, label, type }).then(extractId);
|
|
1049
|
+
var updateVariable = (updateId, { value, label, type }, options) => {
|
|
1050
|
+
return service.update(updateId, { value, label, type }, options).then(extractId);
|
|
1030
1051
|
};
|
|
1031
1052
|
var deleteVariable = (deleteId) => {
|
|
1032
1053
|
return service.delete(deleteId).then(extractId);
|
|
@@ -2353,8 +2374,8 @@ var StopSyncConfirmationDialog = ({ open, onClose, onConfirm }) => {
|
|
|
2353
2374
|
// src/init.ts
|
|
2354
2375
|
var import_editor = require("@elementor/editor");
|
|
2355
2376
|
var import_editor_controls18 = require("@elementor/editor-controls");
|
|
2356
|
-
var
|
|
2357
|
-
var
|
|
2377
|
+
var import_editor_mcp3 = require("@elementor/editor-mcp");
|
|
2378
|
+
var import_editor_props11 = require("@elementor/editor-props");
|
|
2358
2379
|
var import_menus = require("@elementor/menus");
|
|
2359
2380
|
|
|
2360
2381
|
// src/components/global-styles-import-listener.tsx
|
|
@@ -2373,12 +2394,84 @@ function GlobalStylesImportListener() {
|
|
|
2373
2394
|
return null;
|
|
2374
2395
|
}
|
|
2375
2396
|
|
|
2397
|
+
// src/components/mcp-variable-connect-listener.tsx
|
|
2398
|
+
var import_react15 = require("react");
|
|
2399
|
+
var import_editor_mcp = require("@elementor/editor-mcp");
|
|
2400
|
+
|
|
2401
|
+
// src/utils/extract-variables-from-style-value.ts
|
|
2402
|
+
var import_editor_props3 = require("@elementor/editor-props");
|
|
2403
|
+
var VARIABLE_TYPE_KEYS = [
|
|
2404
|
+
"global-color-variable",
|
|
2405
|
+
"global-font-variable",
|
|
2406
|
+
"global-size-variable",
|
|
2407
|
+
"global-custom-size-variable"
|
|
2408
|
+
];
|
|
2409
|
+
function tryExtractVariable(value) {
|
|
2410
|
+
for (const key of VARIABLE_TYPE_KEYS) {
|
|
2411
|
+
const propUtil = (0, import_editor_props3.getPropSchemaFromCache)(key);
|
|
2412
|
+
if (propUtil?.isValid(value)) {
|
|
2413
|
+
return {
|
|
2414
|
+
type: key,
|
|
2415
|
+
variableId: propUtil.extract(value)
|
|
2416
|
+
};
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
return null;
|
|
2420
|
+
}
|
|
2421
|
+
function traverse(value, path, result) {
|
|
2422
|
+
const extracted = tryExtractVariable(value);
|
|
2423
|
+
if (extracted) {
|
|
2424
|
+
result.push({
|
|
2425
|
+
...extracted,
|
|
2426
|
+
controlPath: path.join(".")
|
|
2427
|
+
});
|
|
2428
|
+
return;
|
|
2429
|
+
}
|
|
2430
|
+
if ((0, import_editor_props3.isTransformable)(value)) {
|
|
2431
|
+
traverse(value.value, path, result);
|
|
2432
|
+
return;
|
|
2433
|
+
}
|
|
2434
|
+
if (value && typeof value === "object") {
|
|
2435
|
+
for (const [key, val] of Object.entries(value)) {
|
|
2436
|
+
traverse(val, [...path, key], result);
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
}
|
|
2440
|
+
function extractVariablesFromStyleValue(styleValue) {
|
|
2441
|
+
const result = [];
|
|
2442
|
+
traverse(styleValue, [], result);
|
|
2443
|
+
return result;
|
|
2444
|
+
}
|
|
2445
|
+
|
|
2446
|
+
// src/components/mcp-variable-connect-listener.tsx
|
|
2447
|
+
function McpVariableConnectListener() {
|
|
2448
|
+
(0, import_react15.useEffect)(() => {
|
|
2449
|
+
const handleMcpStylesApplied = (event) => {
|
|
2450
|
+
const { styleValue } = event.detail;
|
|
2451
|
+
const variables = extractVariablesFromStyleValue(styleValue);
|
|
2452
|
+
variables.forEach(({ type, controlPath }) => {
|
|
2453
|
+
trackVariableEvent({
|
|
2454
|
+
varType: type,
|
|
2455
|
+
controlPath,
|
|
2456
|
+
action: "connect",
|
|
2457
|
+
executedBy: "mcp_tool"
|
|
2458
|
+
});
|
|
2459
|
+
});
|
|
2460
|
+
};
|
|
2461
|
+
window.addEventListener(import_editor_mcp.MCP_STYLES_APPLIED_EVENT, handleMcpStylesApplied);
|
|
2462
|
+
return () => {
|
|
2463
|
+
window.removeEventListener(import_editor_mcp.MCP_STYLES_APPLIED_EVENT, handleMcpStylesApplied);
|
|
2464
|
+
};
|
|
2465
|
+
}, []);
|
|
2466
|
+
return null;
|
|
2467
|
+
}
|
|
2468
|
+
|
|
2376
2469
|
// src/controls/variable-control.tsx
|
|
2377
2470
|
var React33 = __toESM(require("react"));
|
|
2378
2471
|
var import_editor_controls13 = require("@elementor/editor-controls");
|
|
2379
2472
|
|
|
2380
2473
|
// src/components/ui/variable/assigned-variable.tsx
|
|
2381
|
-
var
|
|
2474
|
+
var import_react22 = require("react");
|
|
2382
2475
|
var React24 = __toESM(require("react"));
|
|
2383
2476
|
var import_editor_controls8 = require("@elementor/editor-controls");
|
|
2384
2477
|
var import_icons12 = require("@elementor/icons");
|
|
@@ -2402,25 +2495,25 @@ function createUnlinkHandler(variable, propTypeKey, setValue) {
|
|
|
2402
2495
|
|
|
2403
2496
|
// src/components/variable-selection-popover.tsx
|
|
2404
2497
|
var React22 = __toESM(require("react"));
|
|
2405
|
-
var
|
|
2498
|
+
var import_react21 = require("react");
|
|
2406
2499
|
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
2407
2500
|
|
|
2408
2501
|
// src/context/variable-selection-popover.context.tsx
|
|
2409
2502
|
var React15 = __toESM(require("react"));
|
|
2410
|
-
var
|
|
2503
|
+
var import_react16 = require("react");
|
|
2411
2504
|
var import_ui15 = require("@elementor/ui");
|
|
2412
|
-
var PopoverContentRefContext = (0,
|
|
2505
|
+
var PopoverContentRefContext = (0, import_react16.createContext)(null);
|
|
2413
2506
|
var PopoverContentRefContextProvider = ({ children }) => {
|
|
2414
|
-
const [anchorRef, setAnchorRef] = (0,
|
|
2507
|
+
const [anchorRef, setAnchorRef] = (0, import_react16.useState)(null);
|
|
2415
2508
|
return /* @__PURE__ */ React15.createElement(PopoverContentRefContext.Provider, { value: anchorRef }, /* @__PURE__ */ React15.createElement(import_ui15.Box, { ref: setAnchorRef }, children));
|
|
2416
2509
|
};
|
|
2417
2510
|
var usePopoverContentRef = () => {
|
|
2418
|
-
return (0,
|
|
2511
|
+
return (0, import_react16.useContext)(PopoverContentRefContext);
|
|
2419
2512
|
};
|
|
2420
2513
|
|
|
2421
2514
|
// src/components/variable-creation.tsx
|
|
2422
2515
|
var React17 = __toESM(require("react"));
|
|
2423
|
-
var
|
|
2516
|
+
var import_react17 = require("react");
|
|
2424
2517
|
var import_editor_controls5 = require("@elementor/editor-controls");
|
|
2425
2518
|
var import_editor_ui6 = require("@elementor/editor-ui");
|
|
2426
2519
|
var import_icons6 = require("@elementor/icons");
|
|
@@ -2441,7 +2534,7 @@ var useInitialValue = () => {
|
|
|
2441
2534
|
|
|
2442
2535
|
// src/hooks/use-variable-bound-prop.ts
|
|
2443
2536
|
var import_editor_controls4 = require("@elementor/editor-controls");
|
|
2444
|
-
var
|
|
2537
|
+
var import_editor_props4 = require("@elementor/editor-props");
|
|
2445
2538
|
var useVariableBoundProp = () => {
|
|
2446
2539
|
const { propTypeUtil } = useVariableType();
|
|
2447
2540
|
const boundProp = (0, import_editor_controls4.useBoundProp)(propTypeUtil);
|
|
@@ -2461,7 +2554,7 @@ var resolveBoundPropAndSetValue = (value, boundProp) => {
|
|
|
2461
2554
|
return boundProp.setValue(value);
|
|
2462
2555
|
};
|
|
2463
2556
|
var unwrapValue = (input) => {
|
|
2464
|
-
if ((0,
|
|
2557
|
+
if ((0, import_editor_props4.isTransformable)(input)) {
|
|
2465
2558
|
return input.value;
|
|
2466
2559
|
}
|
|
2467
2560
|
return input;
|
|
@@ -2477,15 +2570,15 @@ var FormField = ({ id, label, errorMsg, noticeMsg, children }) => {
|
|
|
2477
2570
|
// src/components/variable-creation.tsx
|
|
2478
2571
|
var SIZE2 = "tiny";
|
|
2479
2572
|
var VariableCreation = ({ onGoBack, onClose }) => {
|
|
2480
|
-
const { icon: VariableIcon, valueField: ValueField,
|
|
2573
|
+
const { icon: VariableIcon, valueField: ValueField, propTypeUtil } = useVariableType();
|
|
2481
2574
|
const { setVariableValue: setVariable, path } = useVariableBoundProp();
|
|
2482
2575
|
const { propType } = (0, import_editor_controls5.useBoundProp)();
|
|
2483
2576
|
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,
|
|
2577
|
+
const [value, setValue] = (0, import_react17.useState)(initialValue);
|
|
2578
|
+
const [label, setLabel] = (0, import_react17.useState)("");
|
|
2579
|
+
const [errorMessage, setErrorMessage] = (0, import_react17.useState)("");
|
|
2580
|
+
const [valueFieldError, setValueFieldError] = (0, import_react17.useState)("");
|
|
2581
|
+
const [propTypeKey, setPropTypeKey] = (0, import_react17.useState)(propTypeUtil.key);
|
|
2489
2582
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
2490
2583
|
const resetFields = () => {
|
|
2491
2584
|
setValue("");
|
|
@@ -2498,11 +2591,14 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2498
2591
|
onClose();
|
|
2499
2592
|
};
|
|
2500
2593
|
const handleCreateAndTrack = () => {
|
|
2501
|
-
createVariable(
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2594
|
+
createVariable(
|
|
2595
|
+
{
|
|
2596
|
+
value,
|
|
2597
|
+
label,
|
|
2598
|
+
type: propTypeKey
|
|
2599
|
+
},
|
|
2600
|
+
{ eventData: { controlPath: path.join(".") } }
|
|
2601
|
+
).then((key) => {
|
|
2506
2602
|
setVariable(key);
|
|
2507
2603
|
closePopover();
|
|
2508
2604
|
}).catch((error) => {
|
|
@@ -2517,11 +2613,6 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2517
2613
|
}
|
|
2518
2614
|
setErrorMessage(ERROR_MESSAGES.UNEXPECTED_ERROR);
|
|
2519
2615
|
});
|
|
2520
|
-
trackVariableEvent({
|
|
2521
|
-
varType: variableType,
|
|
2522
|
-
controlPath: path.join("."),
|
|
2523
|
-
action: "save"
|
|
2524
|
-
});
|
|
2525
2616
|
};
|
|
2526
2617
|
const hasEmptyFields = () => {
|
|
2527
2618
|
if ("" === label.trim()) {
|
|
@@ -2606,7 +2697,7 @@ var VariableCreation = ({ onGoBack, onClose }) => {
|
|
|
2606
2697
|
|
|
2607
2698
|
// src/components/variable-edit.tsx
|
|
2608
2699
|
var React19 = __toESM(require("react"));
|
|
2609
|
-
var
|
|
2700
|
+
var import_react19 = require("react");
|
|
2610
2701
|
var import_editor_controls6 = require("@elementor/editor-controls");
|
|
2611
2702
|
var import_editor_current_user3 = require("@elementor/editor-current-user");
|
|
2612
2703
|
var import_editor_ui7 = require("@elementor/editor-ui");
|
|
@@ -2616,7 +2707,7 @@ var import_i18n13 = require("@wordpress/i18n");
|
|
|
2616
2707
|
|
|
2617
2708
|
// src/components/ui/edit-confirmation-dialog.tsx
|
|
2618
2709
|
var React18 = __toESM(require("react"));
|
|
2619
|
-
var
|
|
2710
|
+
var import_react18 = require("react");
|
|
2620
2711
|
var import_icons7 = require("@elementor/icons");
|
|
2621
2712
|
var import_ui18 = require("@elementor/ui");
|
|
2622
2713
|
var import_i18n12 = require("@wordpress/i18n");
|
|
@@ -2626,7 +2717,7 @@ var EditConfirmationDialog = ({
|
|
|
2626
2717
|
onConfirm,
|
|
2627
2718
|
onSuppressMessage
|
|
2628
2719
|
}) => {
|
|
2629
|
-
const [dontShowAgain, setDontShowAgain] = (0,
|
|
2720
|
+
const [dontShowAgain, setDontShowAgain] = (0, import_react18.useState)(false);
|
|
2630
2721
|
const handleSave = () => {
|
|
2631
2722
|
if (dontShowAgain) {
|
|
2632
2723
|
onSuppressMessage?.();
|
|
@@ -2657,23 +2748,23 @@ var SIZE3 = "tiny";
|
|
|
2657
2748
|
var DELETE_LABEL = (0, import_i18n13.__)("Delete variable", "elementor");
|
|
2658
2749
|
var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
2659
2750
|
const { icon: VariableIcon, valueField: ValueField, variableType, propTypeUtil } = useVariableType();
|
|
2660
|
-
const { setVariableValue: notifyBoundPropChange, variableId } = useVariableBoundProp();
|
|
2751
|
+
const { setVariableValue: notifyBoundPropChange, variableId, path } = useVariableBoundProp();
|
|
2661
2752
|
const { propType } = (0, import_editor_controls6.useBoundProp)();
|
|
2662
2753
|
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,
|
|
2754
|
+
const [deleteConfirmation, setDeleteConfirmation] = (0, import_react19.useState)(false);
|
|
2755
|
+
const [editConfirmation, setEditConfirmation] = (0, import_react19.useState)(false);
|
|
2756
|
+
const [errorMessage, setErrorMessage] = (0, import_react19.useState)("");
|
|
2757
|
+
const [valueFieldError, setValueFieldError] = (0, import_react19.useState)("");
|
|
2667
2758
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
2668
2759
|
const variable = useVariable(editId);
|
|
2669
|
-
const [propTypeKey, setPropTypeKey] = (0,
|
|
2760
|
+
const [propTypeKey, setPropTypeKey] = (0, import_react19.useState)(variable?.type ?? propTypeUtil.key);
|
|
2670
2761
|
if (!variable) {
|
|
2671
2762
|
throw new Error(`Global ${variableType} variable not found`);
|
|
2672
2763
|
}
|
|
2673
2764
|
const userPermissions = usePermissions();
|
|
2674
|
-
const [value, setValue] = (0,
|
|
2675
|
-
const [label, setLabel] = (0,
|
|
2676
|
-
(0,
|
|
2765
|
+
const [value, setValue] = (0, import_react19.useState)(() => variable.value);
|
|
2766
|
+
const [label, setLabel] = (0, import_react19.useState)(() => variable.label);
|
|
2767
|
+
(0, import_react19.useEffect)(() => {
|
|
2677
2768
|
styleVariablesRepository.update({
|
|
2678
2769
|
[editId]: {
|
|
2679
2770
|
...variable,
|
|
@@ -2696,7 +2787,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2696
2787
|
const handleSaveVariable = () => {
|
|
2697
2788
|
const typeChanged = propTypeKey !== variable.type;
|
|
2698
2789
|
const updatePayload = typeChanged ? { value, label, type: propTypeKey } : { value, label };
|
|
2699
|
-
updateVariable(editId, updatePayload).then(() => {
|
|
2790
|
+
updateVariable(editId, updatePayload, { eventData: { controlPath: path.join(".") } }).then(() => {
|
|
2700
2791
|
maybeTriggerBoundPropChange();
|
|
2701
2792
|
onSubmit?.();
|
|
2702
2793
|
}).catch((error) => {
|
|
@@ -2838,7 +2929,7 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2838
2929
|
};
|
|
2839
2930
|
|
|
2840
2931
|
// src/components/variables-selection.tsx
|
|
2841
|
-
var
|
|
2932
|
+
var import_react20 = require("react");
|
|
2842
2933
|
var React21 = __toESM(require("react"));
|
|
2843
2934
|
var import_editor_controls7 = require("@elementor/editor-controls");
|
|
2844
2935
|
var import_editor_ui9 = require("@elementor/editor-ui");
|
|
@@ -2946,7 +3037,7 @@ var getProUpgradeUrl = (variableType) => `https://go.elementor.com/renew-license
|
|
|
2946
3037
|
var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled = false }) => {
|
|
2947
3038
|
const { icon: VariableIcon, startIcon, variableType, propTypeUtil, emptyState } = useVariableType();
|
|
2948
3039
|
const { value: variable, setValue: setVariable, path } = useVariableBoundProp();
|
|
2949
|
-
const [searchValue, setSearchValue] = (0,
|
|
3040
|
+
const [searchValue, setSearchValue] = (0, import_react20.useState)("");
|
|
2950
3041
|
const {
|
|
2951
3042
|
list: variables,
|
|
2952
3043
|
hasMatches: hasSearchResults,
|
|
@@ -3024,7 +3115,7 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled =
|
|
|
3024
3115
|
const handleClearSearch = () => {
|
|
3025
3116
|
setSearchValue("");
|
|
3026
3117
|
};
|
|
3027
|
-
(0,
|
|
3118
|
+
(0, import_react20.useEffect)(() => {
|
|
3028
3119
|
if (disabled) {
|
|
3029
3120
|
(0, import_editor_controls7.trackViewPromotion)({
|
|
3030
3121
|
target_name: "variables_popover",
|
|
@@ -3132,8 +3223,8 @@ var VIEW_LIST = "list";
|
|
|
3132
3223
|
var VIEW_ADD = "add";
|
|
3133
3224
|
var VIEW_EDIT = "edit";
|
|
3134
3225
|
var VariableSelectionPopover = ({ closePopover, propTypeKey, selectedVariable }) => {
|
|
3135
|
-
const [currentView, setCurrentView] = (0,
|
|
3136
|
-
const [editId, setEditId] = (0,
|
|
3226
|
+
const [currentView, setCurrentView] = (0, import_react21.useState)(VIEW_LIST);
|
|
3227
|
+
const [editId, setEditId] = (0, import_react21.useState)("");
|
|
3137
3228
|
const onSettingsAvailable = (0, import_editor_v1_adapters2.isExperimentActive)("e_variables_manager") ? () => {
|
|
3138
3229
|
window.dispatchEvent(
|
|
3139
3230
|
new CustomEvent("elementor/toggle-design-system", { detail: { tab: "variables" } })
|
|
@@ -3245,8 +3336,8 @@ var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
|
|
|
3245
3336
|
var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
3246
3337
|
const { startIcon, propTypeUtil } = getVariableType(propTypeKey);
|
|
3247
3338
|
const { setValue } = (0, import_editor_controls8.useBoundProp)();
|
|
3248
|
-
const anchorRef = (0,
|
|
3249
|
-
const popupId = (0,
|
|
3339
|
+
const anchorRef = (0, import_react22.useRef)(null);
|
|
3340
|
+
const popupId = (0, import_react22.useId)();
|
|
3250
3341
|
const popupState = (0, import_ui24.usePopupState)({
|
|
3251
3342
|
variant: "popover",
|
|
3252
3343
|
popupId: `elementor-variables-list-${popupId}`
|
|
@@ -3286,14 +3377,14 @@ var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
|
3286
3377
|
|
|
3287
3378
|
// src/components/ui/variable/deleted-variable.tsx
|
|
3288
3379
|
var React28 = __toESM(require("react"));
|
|
3289
|
-
var
|
|
3380
|
+
var import_react24 = require("react");
|
|
3290
3381
|
var import_editor_controls10 = require("@elementor/editor-controls");
|
|
3291
3382
|
var import_ui28 = require("@elementor/ui");
|
|
3292
3383
|
var import_i18n19 = require("@wordpress/i18n");
|
|
3293
3384
|
|
|
3294
3385
|
// src/components/variable-restore.tsx
|
|
3295
3386
|
var React25 = __toESM(require("react"));
|
|
3296
|
-
var
|
|
3387
|
+
var import_react23 = require("react");
|
|
3297
3388
|
var import_editor_controls9 = require("@elementor/editor-controls");
|
|
3298
3389
|
var import_editor_ui11 = require("@elementor/editor-ui");
|
|
3299
3390
|
var import_ui25 = require("@elementor/ui");
|
|
@@ -3307,11 +3398,11 @@ var VariableRestore = ({ variableId, onClose, onSubmit }) => {
|
|
|
3307
3398
|
if (!variable) {
|
|
3308
3399
|
throw new Error(`Global ${variableType} variable not found`);
|
|
3309
3400
|
}
|
|
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,
|
|
3401
|
+
const [errorMessage, setErrorMessage] = (0, import_react23.useState)("");
|
|
3402
|
+
const [valueFieldError, setValueFieldError] = (0, import_react23.useState)("");
|
|
3403
|
+
const [label, setLabel] = (0, import_react23.useState)(variable.label);
|
|
3404
|
+
const [value, setValue] = (0, import_react23.useState)(variable.value);
|
|
3405
|
+
const [propTypeKey, setPropTypeKey] = (0, import_react23.useState)(variable?.type ?? propTypeUtil.key);
|
|
3315
3406
|
const { labelFieldError, setLabelFieldError } = useLabelError({
|
|
3316
3407
|
value: variable.label,
|
|
3317
3408
|
message: ERROR_MESSAGES.DUPLICATED_LABEL
|
|
@@ -3468,11 +3559,11 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
3468
3559
|
const { propTypeUtil } = getVariableType(propTypeKey);
|
|
3469
3560
|
const boundProp = (0, import_editor_controls10.useBoundProp)();
|
|
3470
3561
|
const userPermissions = usePermissions();
|
|
3471
|
-
const [showInfotip, setShowInfotip] = (0,
|
|
3562
|
+
const [showInfotip, setShowInfotip] = (0, import_react24.useState)(false);
|
|
3472
3563
|
const toggleInfotip = () => setShowInfotip((prev) => !prev);
|
|
3473
3564
|
const closeInfotip = () => setShowInfotip(false);
|
|
3474
|
-
const deletedChipAnchorRef = (0,
|
|
3475
|
-
const popupId = (0,
|
|
3565
|
+
const deletedChipAnchorRef = (0, import_react24.useRef)(null);
|
|
3566
|
+
const popupId = (0, import_react24.useId)();
|
|
3476
3567
|
const popupState = (0, import_ui28.usePopupState)({
|
|
3477
3568
|
variant: "popover",
|
|
3478
3569
|
popupId: `elementor-variables-restore-${popupId}`
|
|
@@ -3559,7 +3650,7 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
3559
3650
|
|
|
3560
3651
|
// src/components/ui/variable/mismatch-variable.tsx
|
|
3561
3652
|
var React30 = __toESM(require("react"));
|
|
3562
|
-
var
|
|
3653
|
+
var import_react25 = require("react");
|
|
3563
3654
|
var import_editor_controls11 = require("@elementor/editor-controls");
|
|
3564
3655
|
var import_ui30 = require("@elementor/ui");
|
|
3565
3656
|
var import_i18n21 = require("@wordpress/i18n");
|
|
@@ -3597,13 +3688,13 @@ var MismatchVariableAlert = ({ onClose, onClear, triggerSelect }) => {
|
|
|
3597
3688
|
// src/components/ui/variable/mismatch-variable.tsx
|
|
3598
3689
|
var MismatchVariable = ({ variable }) => {
|
|
3599
3690
|
const { setValue, value } = (0, import_editor_controls11.useBoundProp)();
|
|
3600
|
-
const anchorRef = (0,
|
|
3601
|
-
const popupId = (0,
|
|
3691
|
+
const anchorRef = (0, import_react25.useRef)(null);
|
|
3692
|
+
const popupId = (0, import_react25.useId)();
|
|
3602
3693
|
const popupState = (0, import_ui30.usePopupState)({
|
|
3603
3694
|
variant: "popover",
|
|
3604
3695
|
popupId: `elementor-variables-list-${popupId}`
|
|
3605
3696
|
});
|
|
3606
|
-
const [infotipVisible, setInfotipVisible] = (0,
|
|
3697
|
+
const [infotipVisible, setInfotipVisible] = (0, import_react25.useState)(false);
|
|
3607
3698
|
const toggleInfotip = () => setInfotipVisible((prev) => !prev);
|
|
3608
3699
|
const closeInfotip = () => setInfotipVisible(false);
|
|
3609
3700
|
const triggerSelect = () => {
|
|
@@ -3676,7 +3767,7 @@ var MismatchVariable = ({ variable }) => {
|
|
|
3676
3767
|
|
|
3677
3768
|
// src/components/ui/variable/missing-variable.tsx
|
|
3678
3769
|
var React32 = __toESM(require("react"));
|
|
3679
|
-
var
|
|
3770
|
+
var import_react26 = require("react");
|
|
3680
3771
|
var import_editor_controls12 = require("@elementor/editor-controls");
|
|
3681
3772
|
var import_ui32 = require("@elementor/ui");
|
|
3682
3773
|
var import_i18n23 = require("@wordpress/i18n");
|
|
@@ -3706,7 +3797,7 @@ var MissingVariableAlert = ({ onClose, onClear }) => {
|
|
|
3706
3797
|
// src/components/ui/variable/missing-variable.tsx
|
|
3707
3798
|
var MissingVariable = () => {
|
|
3708
3799
|
const { setValue } = (0, import_editor_controls12.useBoundProp)();
|
|
3709
|
-
const [infotipVisible, setInfotipVisible] = (0,
|
|
3800
|
+
const [infotipVisible, setInfotipVisible] = (0, import_react26.useState)(false);
|
|
3710
3801
|
const toggleInfotip = () => setInfotipVisible((prev) => !prev);
|
|
3711
3802
|
const closeInfotip = () => setInfotipVisible(false);
|
|
3712
3803
|
const clearValue = () => setValue(null);
|
|
@@ -3804,11 +3895,11 @@ var getFontConfigs = () => {
|
|
|
3804
3895
|
};
|
|
3805
3896
|
|
|
3806
3897
|
// src/mcp/variable-tool-prompt.ts
|
|
3807
|
-
var
|
|
3898
|
+
var import_editor_mcp2 = require("@elementor/editor-mcp");
|
|
3808
3899
|
var import_utils3 = require("@elementor/utils");
|
|
3809
3900
|
var MANAGE_VARIABLES_GUIDE_URI = "elementor://variables/tools/manage-global-variable-guide";
|
|
3810
3901
|
var generateVariablesPrompt = () => {
|
|
3811
|
-
const prompt = (0,
|
|
3902
|
+
const prompt = (0, import_editor_mcp2.toolPrompts)("manage-global-variable");
|
|
3812
3903
|
const proIsActive = (0, import_utils3.isProActive)();
|
|
3813
3904
|
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
3905
|
- **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 +4107,7 @@ function getServiceActions(svc) {
|
|
|
4016
4107
|
if (valueError) {
|
|
4017
4108
|
throw new Error(valueError);
|
|
4018
4109
|
}
|
|
4019
|
-
return svc.create({ type, label, value });
|
|
4110
|
+
return svc.create({ type, label, value }, { eventData: { executedBy: "mcp_tool" } });
|
|
4020
4111
|
},
|
|
4021
4112
|
update({ id, label, value }) {
|
|
4022
4113
|
if (!id || !label || !value) {
|
|
@@ -4033,7 +4124,7 @@ function getServiceActions(svc) {
|
|
|
4033
4124
|
throw new Error(valueError);
|
|
4034
4125
|
}
|
|
4035
4126
|
}
|
|
4036
|
-
return svc.update(id, { label, value });
|
|
4127
|
+
return svc.update(id, { label, value }, { eventData: { executedBy: "mcp_tool" } });
|
|
4037
4128
|
},
|
|
4038
4129
|
delete({ id }) {
|
|
4039
4130
|
if (!id) {
|
|
@@ -4059,19 +4150,19 @@ function initMcp(reg, canvasMcpEntry) {
|
|
|
4059
4150
|
// src/register-variable-types.tsx
|
|
4060
4151
|
var React37 = __toESM(require("react"));
|
|
4061
4152
|
var import_editor_controls16 = require("@elementor/editor-controls");
|
|
4062
|
-
var
|
|
4153
|
+
var import_editor_props6 = require("@elementor/editor-props");
|
|
4063
4154
|
var import_editor_ui13 = require("@elementor/editor-ui");
|
|
4064
4155
|
var import_icons16 = require("@elementor/icons");
|
|
4065
4156
|
var import_i18n26 = require("@wordpress/i18n");
|
|
4066
4157
|
|
|
4067
4158
|
// src/components/fields/color-field.tsx
|
|
4068
4159
|
var React35 = __toESM(require("react"));
|
|
4069
|
-
var
|
|
4160
|
+
var import_react27 = require("react");
|
|
4070
4161
|
var import_ui33 = require("@elementor/ui");
|
|
4071
4162
|
var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
4072
|
-
const [color, setColor] = (0,
|
|
4073
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
4074
|
-
const defaultRef = (0,
|
|
4163
|
+
const [color, setColor] = (0, import_react27.useState)(value);
|
|
4164
|
+
const [errorMessage, setErrorMessage] = (0, import_react27.useState)("");
|
|
4165
|
+
const defaultRef = (0, import_react27.useRef)(null);
|
|
4075
4166
|
const anchorRef = usePopoverContentRef() ?? defaultRef.current;
|
|
4076
4167
|
const handleChange = (newValue) => {
|
|
4077
4168
|
setColor(newValue);
|
|
@@ -4110,20 +4201,20 @@ var ColorField = ({ value, onChange, onValidationChange }) => {
|
|
|
4110
4201
|
|
|
4111
4202
|
// src/components/fields/font-field.tsx
|
|
4112
4203
|
var React36 = __toESM(require("react"));
|
|
4113
|
-
var
|
|
4204
|
+
var import_react28 = require("react");
|
|
4114
4205
|
var import_editor_controls15 = require("@elementor/editor-controls");
|
|
4115
4206
|
var import_editor_ui12 = require("@elementor/editor-ui");
|
|
4116
4207
|
var import_icons15 = require("@elementor/icons");
|
|
4117
4208
|
var import_ui34 = require("@elementor/ui");
|
|
4118
4209
|
var import_i18n25 = require("@wordpress/i18n");
|
|
4119
4210
|
var FontField = ({ value, onChange, onValidationChange }) => {
|
|
4120
|
-
const [fontFamily, setFontFamily] = (0,
|
|
4121
|
-
const defaultRef = (0,
|
|
4211
|
+
const [fontFamily, setFontFamily] = (0, import_react28.useState)(value);
|
|
4212
|
+
const defaultRef = (0, import_react28.useRef)(null);
|
|
4122
4213
|
const anchorRef = usePopoverContentRef() ?? defaultRef.current;
|
|
4123
4214
|
const fontPopoverState = (0, import_ui34.usePopupState)({ variant: "popover" });
|
|
4124
4215
|
const fontFamilies = (0, import_editor_controls15.useFontFamilies)();
|
|
4125
4216
|
const sectionWidth = (0, import_editor_ui12.useSectionWidth)();
|
|
4126
|
-
const mapFontSubs = (0,
|
|
4217
|
+
const mapFontSubs = (0, import_react28.useMemo)(() => {
|
|
4127
4218
|
return fontFamilies.map(({ label, fonts }) => ({
|
|
4128
4219
|
label,
|
|
4129
4220
|
items: fonts
|
|
@@ -4139,7 +4230,7 @@ var FontField = ({ value, onChange, onValidationChange }) => {
|
|
|
4139
4230
|
handleChange(newFontFamily);
|
|
4140
4231
|
fontPopoverState.close();
|
|
4141
4232
|
};
|
|
4142
|
-
const id = (0,
|
|
4233
|
+
const id = (0, import_react28.useId)();
|
|
4143
4234
|
return /* @__PURE__ */ React36.createElement(React36.Fragment, null, /* @__PURE__ */ React36.createElement(
|
|
4144
4235
|
import_ui34.UnstableTag,
|
|
4145
4236
|
{
|
|
@@ -4179,9 +4270,9 @@ var FontField = ({ value, onChange, onValidationChange }) => {
|
|
|
4179
4270
|
};
|
|
4180
4271
|
|
|
4181
4272
|
// src/prop-types/size-variable-prop-type.ts
|
|
4182
|
-
var
|
|
4273
|
+
var import_editor_props5 = require("@elementor/editor-props");
|
|
4183
4274
|
var import_schema4 = require("@elementor/schema");
|
|
4184
|
-
var sizeVariablePropTypeUtil = (0,
|
|
4275
|
+
var sizeVariablePropTypeUtil = (0, import_editor_props5.createPropUtils)("global-size-variable", import_schema4.z.string());
|
|
4185
4276
|
|
|
4186
4277
|
// src/transformers/empty-transformer.tsx
|
|
4187
4278
|
var import_editor_canvas5 = require("@elementor/editor-canvas");
|
|
@@ -4196,7 +4287,7 @@ function registerVariableTypes() {
|
|
|
4196
4287
|
valueField: ColorField,
|
|
4197
4288
|
icon: import_icons16.BrushIcon,
|
|
4198
4289
|
propTypeUtil: colorVariablePropTypeUtil,
|
|
4199
|
-
fallbackPropTypeUtil:
|
|
4290
|
+
fallbackPropTypeUtil: import_editor_props6.colorPropTypeUtil,
|
|
4200
4291
|
variableType: "color",
|
|
4201
4292
|
startIcon: ({ value }) => /* @__PURE__ */ React37.createElement(ColorIndicator, { size: "inherit", component: "span", value }),
|
|
4202
4293
|
defaultValue: "#ffffff",
|
|
@@ -4225,7 +4316,7 @@ function registerVariableTypes() {
|
|
|
4225
4316
|
valueField: FontField,
|
|
4226
4317
|
icon: import_icons16.TextIcon,
|
|
4227
4318
|
propTypeUtil: fontVariablePropTypeUtil,
|
|
4228
|
-
fallbackPropTypeUtil:
|
|
4319
|
+
fallbackPropTypeUtil: import_editor_props6.stringPropTypeUtil,
|
|
4229
4320
|
variableType: "font",
|
|
4230
4321
|
defaultValue: "Roboto"
|
|
4231
4322
|
});
|
|
@@ -4233,7 +4324,7 @@ function registerVariableTypes() {
|
|
|
4233
4324
|
isActive: false,
|
|
4234
4325
|
icon: import_icons16.ExpandDiagonalIcon,
|
|
4235
4326
|
propTypeUtil: sizeVariablePropTypeUtil,
|
|
4236
|
-
fallbackPropTypeUtil:
|
|
4327
|
+
fallbackPropTypeUtil: import_editor_props6.sizePropTypeUtil,
|
|
4237
4328
|
styleTransformer: EmptyTransformer,
|
|
4238
4329
|
variableType: "size",
|
|
4239
4330
|
selectionFilter: () => [],
|
|
@@ -4259,7 +4350,7 @@ function registerVariableTypes() {
|
|
|
4259
4350
|
|
|
4260
4351
|
// src/renderers/style-variables-renderer.tsx
|
|
4261
4352
|
var React38 = __toESM(require("react"));
|
|
4262
|
-
var
|
|
4353
|
+
var import_react29 = require("react");
|
|
4263
4354
|
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
4264
4355
|
var import_ui35 = require("@elementor/ui");
|
|
4265
4356
|
var VARIABLES_WRAPPER = ":root";
|
|
@@ -4278,8 +4369,8 @@ function usePortalContainer() {
|
|
|
4278
4369
|
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
4370
|
}
|
|
4280
4371
|
function useStyleVariables() {
|
|
4281
|
-
const [variables, setVariables] = (0,
|
|
4282
|
-
(0,
|
|
4372
|
+
const [variables, setVariables] = (0, import_react29.useState)({});
|
|
4373
|
+
(0, import_react29.useEffect)(() => {
|
|
4283
4374
|
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
4284
4375
|
return () => {
|
|
4285
4376
|
unsubscribe();
|
|
@@ -4299,21 +4390,21 @@ function convertToCssVariables(variables) {
|
|
|
4299
4390
|
|
|
4300
4391
|
// src/repeater-injections.ts
|
|
4301
4392
|
var import_editor_controls17 = require("@elementor/editor-controls");
|
|
4302
|
-
var
|
|
4393
|
+
var import_editor_props10 = require("@elementor/editor-props");
|
|
4303
4394
|
|
|
4304
4395
|
// src/components/variables-repeater-item-slot.tsx
|
|
4305
4396
|
var React39 = __toESM(require("react"));
|
|
4306
|
-
var
|
|
4397
|
+
var import_editor_props9 = require("@elementor/editor-props");
|
|
4307
4398
|
var import_ui36 = require("@elementor/ui");
|
|
4308
4399
|
var import_i18n27 = require("@wordpress/i18n");
|
|
4309
4400
|
|
|
4310
4401
|
// src/utils/size-value.ts
|
|
4311
|
-
var
|
|
4402
|
+
var import_editor_props8 = require("@elementor/editor-props");
|
|
4312
4403
|
|
|
4313
4404
|
// src/prop-types/custom-size-variable-prop-type.ts
|
|
4314
|
-
var
|
|
4405
|
+
var import_editor_props7 = require("@elementor/editor-props");
|
|
4315
4406
|
var import_schema5 = require("@elementor/schema");
|
|
4316
|
-
var customSizeVariablePropTypeUtil = (0,
|
|
4407
|
+
var customSizeVariablePropTypeUtil = (0, import_editor_props7.createPropUtils)("global-custom-size-variable", import_schema5.z.string());
|
|
4317
4408
|
|
|
4318
4409
|
// src/utils/size-value.ts
|
|
4319
4410
|
var DEFAULT_UNIT = "px";
|
|
@@ -4323,7 +4414,7 @@ function sizeValue(value) {
|
|
|
4323
4414
|
const variable = getVariable(value?.value);
|
|
4324
4415
|
return variable?.value;
|
|
4325
4416
|
}
|
|
4326
|
-
if (
|
|
4417
|
+
if (import_editor_props8.sizePropTypeUtil.isValid(value)) {
|
|
4327
4418
|
const { size, unit } = value.value;
|
|
4328
4419
|
if ("custom" !== unit) {
|
|
4329
4420
|
return `${size ?? 0}${unit ?? DEFAULT_UNIT}`;
|
|
@@ -4354,14 +4445,14 @@ var BoxShadowRepeaterColorIndicator = ({ value }) => {
|
|
|
4354
4445
|
return /* @__PURE__ */ React39.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
|
|
4355
4446
|
};
|
|
4356
4447
|
var FilterDropShadowIconIndicator = ({ value }) => {
|
|
4357
|
-
const { args } =
|
|
4358
|
-
const { color } =
|
|
4448
|
+
const { args } = import_editor_props9.cssFilterFunctionPropUtil.extract(value) || {};
|
|
4449
|
+
const { color } = import_editor_props9.dropShadowFilterPropTypeUtil.extract(args) || {};
|
|
4359
4450
|
const colorVariable = getVariable(color?.value || "");
|
|
4360
4451
|
return /* @__PURE__ */ React39.createElement(ColorIndicator, { component: "span", size: "inherit", value: colorVariable?.value });
|
|
4361
4452
|
};
|
|
4362
4453
|
var FilterSingleSizeRepeaterLabel = ({ value }) => {
|
|
4363
|
-
const cssFilterFunction =
|
|
4364
|
-
if (
|
|
4454
|
+
const cssFilterFunction = import_editor_props9.cssFilterFunctionPropUtil.extract(value);
|
|
4455
|
+
if (import_editor_props9.dropShadowFilterPropTypeUtil.isValid(cssFilterFunction?.args)) {
|
|
4365
4456
|
return null;
|
|
4366
4457
|
}
|
|
4367
4458
|
const args = cssFilterFunction?.args;
|
|
@@ -4370,8 +4461,8 @@ var FilterSingleSizeRepeaterLabel = ({ value }) => {
|
|
|
4370
4461
|
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
4462
|
};
|
|
4372
4463
|
var FilterDropShadowRepeaterLabel = ({ value }) => {
|
|
4373
|
-
const { args } =
|
|
4374
|
-
const { xAxis, yAxis, blur } =
|
|
4464
|
+
const { args } = import_editor_props9.cssFilterFunctionPropUtil.extract(value) || {};
|
|
4465
|
+
const { xAxis, yAxis, blur } = import_editor_props9.dropShadowFilterPropTypeUtil.extract(args) || {};
|
|
4375
4466
|
const labels = [];
|
|
4376
4467
|
for (const val of [xAxis, yAxis, blur]) {
|
|
4377
4468
|
const rendered = sizeValue(val);
|
|
@@ -4382,7 +4473,7 @@ var FilterDropShadowRepeaterLabel = ({ value }) => {
|
|
|
4382
4473
|
return /* @__PURE__ */ React39.createElement(import_ui36.Box, { component: "span" }, (0, import_i18n27.__)("Drop shadow:", "elementor"), " ", labels.join(" "));
|
|
4383
4474
|
};
|
|
4384
4475
|
var BoxShadowRepeaterLabel = ({ value }) => {
|
|
4385
|
-
const { position, hOffset, vOffset, blur, spread } =
|
|
4476
|
+
const { position, hOffset, vOffset, blur, spread } = import_editor_props9.shadowPropTypeUtil.extract(value) || {};
|
|
4386
4477
|
const labels = [];
|
|
4387
4478
|
for (const val of [hOffset, vOffset, blur, spread]) {
|
|
4388
4479
|
const rendered = sizeValue(val);
|
|
@@ -4395,9 +4486,9 @@ var BoxShadowRepeaterLabel = ({ value }) => {
|
|
|
4395
4486
|
};
|
|
4396
4487
|
var TransformRepeaterLabel = ({ value }) => {
|
|
4397
4488
|
const labels = [];
|
|
4398
|
-
if (
|
|
4489
|
+
if (import_editor_props9.moveTransformPropTypeUtil.isValid(value)) {
|
|
4399
4490
|
labels.push((0, import_i18n27.__)("Move:", "elementor"));
|
|
4400
|
-
const { x, y, z: z6 } =
|
|
4491
|
+
const { x, y, z: z6 } = import_editor_props9.moveTransformPropTypeUtil.extract(value) || {};
|
|
4401
4492
|
for (const val of [x, y, z6]) {
|
|
4402
4493
|
const rendered = sizeValue(val);
|
|
4403
4494
|
if (rendered) {
|
|
@@ -4411,7 +4502,7 @@ var TransitionsSizeVariableLabel = ({ value: prop }) => {
|
|
|
4411
4502
|
let label = "";
|
|
4412
4503
|
const variableId = prop?.value?.size?.value || "";
|
|
4413
4504
|
const variable = getVariable(variableId);
|
|
4414
|
-
if (variable &&
|
|
4505
|
+
if (variable && import_editor_props9.selectionSizePropTypeUtil.isValid(prop)) {
|
|
4415
4506
|
const selection = prop.value?.selection?.value?.key?.value;
|
|
4416
4507
|
if (selection) {
|
|
4417
4508
|
label += `${selection}: `;
|
|
@@ -4434,14 +4525,14 @@ function backgroundOverlayRepeaterInjections() {
|
|
|
4434
4525
|
id: "background-color-variables-icon",
|
|
4435
4526
|
component: BackgroundRepeaterColorIndicator,
|
|
4436
4527
|
condition: ({ value }) => {
|
|
4437
|
-
return hasAssignedColorVariable(
|
|
4528
|
+
return hasAssignedColorVariable(import_editor_props10.backgroundColorOverlayPropTypeUtil.extract(value)?.color);
|
|
4438
4529
|
}
|
|
4439
4530
|
});
|
|
4440
4531
|
(0, import_editor_controls17.injectIntoRepeaterItemLabel)({
|
|
4441
4532
|
id: "background-color-variables-label",
|
|
4442
4533
|
component: BackgroundRepeaterLabel,
|
|
4443
4534
|
condition: ({ value }) => {
|
|
4444
|
-
return hasAssignedColorVariable(
|
|
4535
|
+
return hasAssignedColorVariable(import_editor_props10.backgroundColorOverlayPropTypeUtil.extract(value)?.color);
|
|
4445
4536
|
}
|
|
4446
4537
|
});
|
|
4447
4538
|
}
|
|
@@ -4450,7 +4541,7 @@ function boxShadowRepeaterInjections() {
|
|
|
4450
4541
|
id: "box-shadow-color-variables-icon",
|
|
4451
4542
|
component: BoxShadowRepeaterColorIndicator,
|
|
4452
4543
|
condition: ({ value }) => {
|
|
4453
|
-
const { color } =
|
|
4544
|
+
const { color } = import_editor_props10.shadowPropTypeUtil.extract(value) || {};
|
|
4454
4545
|
return hasAssignedColorVariable(color);
|
|
4455
4546
|
}
|
|
4456
4547
|
});
|
|
@@ -4458,7 +4549,7 @@ function boxShadowRepeaterInjections() {
|
|
|
4458
4549
|
id: "color-variables-box-shadow-label",
|
|
4459
4550
|
component: BoxShadowRepeaterLabel,
|
|
4460
4551
|
condition: ({ value }) => {
|
|
4461
|
-
const { hOffset, vOffset, blur, spread } =
|
|
4552
|
+
const { hOffset, vOffset, blur, spread } = import_editor_props10.shadowPropTypeUtil.extract(value) || {};
|
|
4462
4553
|
return hasAssignedSizeVariable(hOffset) || hasAssignedSizeVariable(vOffset) || hasAssignedSizeVariable(blur) || hasAssignedSizeVariable(spread);
|
|
4463
4554
|
}
|
|
4464
4555
|
});
|
|
@@ -4468,8 +4559,8 @@ function transformRepeaterInjections() {
|
|
|
4468
4559
|
id: "transform-size-variables-label",
|
|
4469
4560
|
component: TransformRepeaterLabel,
|
|
4470
4561
|
condition: ({ value }) => {
|
|
4471
|
-
if (
|
|
4472
|
-
const { x: xAxis, y: yAxis, z: zAxis } =
|
|
4562
|
+
if (import_editor_props10.moveTransformPropTypeUtil.isValid(value)) {
|
|
4563
|
+
const { x: xAxis, y: yAxis, z: zAxis } = import_editor_props10.moveTransformPropTypeUtil.extract(value) || {};
|
|
4473
4564
|
return hasAssignedSizeVariable(xAxis) || hasAssignedSizeVariable(yAxis) || hasAssignedSizeVariable(zAxis);
|
|
4474
4565
|
}
|
|
4475
4566
|
return false;
|
|
@@ -4481,7 +4572,7 @@ function transitionsRepeaterInjections() {
|
|
|
4481
4572
|
id: "transition-size-variables-label",
|
|
4482
4573
|
component: TransitionsSizeVariableLabel,
|
|
4483
4574
|
condition: ({ value }) => {
|
|
4484
|
-
return hasAssignedSizeVariable(
|
|
4575
|
+
return hasAssignedSizeVariable(import_editor_props10.selectionSizePropTypeUtil.extract(value)?.size);
|
|
4485
4576
|
}
|
|
4486
4577
|
});
|
|
4487
4578
|
}
|
|
@@ -4490,12 +4581,12 @@ function filterRepeaterInjections() {
|
|
|
4490
4581
|
id: "filters-color-variables-icon",
|
|
4491
4582
|
component: FilterDropShadowIconIndicator,
|
|
4492
4583
|
condition: ({ value }) => {
|
|
4493
|
-
if (!
|
|
4584
|
+
if (!import_editor_props10.cssFilterFunctionPropUtil.isValid(value)) {
|
|
4494
4585
|
return false;
|
|
4495
4586
|
}
|
|
4496
|
-
const args =
|
|
4497
|
-
if (
|
|
4498
|
-
return hasAssignedColorVariable(
|
|
4587
|
+
const args = import_editor_props10.cssFilterFunctionPropUtil.extract(value)?.args;
|
|
4588
|
+
if (import_editor_props10.dropShadowFilterPropTypeUtil.isValid(args)) {
|
|
4589
|
+
return hasAssignedColorVariable(import_editor_props10.dropShadowFilterPropTypeUtil.extract(args)?.color);
|
|
4499
4590
|
}
|
|
4500
4591
|
return false;
|
|
4501
4592
|
}
|
|
@@ -4504,12 +4595,12 @@ function filterRepeaterInjections() {
|
|
|
4504
4595
|
id: "filters-drop-shadow-size-variables-label",
|
|
4505
4596
|
component: FilterDropShadowRepeaterLabel,
|
|
4506
4597
|
condition: ({ value }) => {
|
|
4507
|
-
if (!
|
|
4598
|
+
if (!import_editor_props10.cssFilterFunctionPropUtil.isValid(value)) {
|
|
4508
4599
|
return false;
|
|
4509
4600
|
}
|
|
4510
|
-
const args =
|
|
4511
|
-
if (
|
|
4512
|
-
const { xAxis, yAxis, blur } =
|
|
4601
|
+
const args = import_editor_props10.cssFilterFunctionPropUtil.extract(value)?.args;
|
|
4602
|
+
if (import_editor_props10.dropShadowFilterPropTypeUtil.isValid(args)) {
|
|
4603
|
+
const { xAxis, yAxis, blur } = import_editor_props10.dropShadowFilterPropTypeUtil.extract(args) || {};
|
|
4513
4604
|
return hasAssignedSizeVariable(xAxis) || hasAssignedSizeVariable(yAxis) || hasAssignedSizeVariable(blur);
|
|
4514
4605
|
}
|
|
4515
4606
|
return false;
|
|
@@ -4519,10 +4610,10 @@ function filterRepeaterInjections() {
|
|
|
4519
4610
|
id: "filters-size-variables-label",
|
|
4520
4611
|
component: FilterSingleSizeRepeaterLabel,
|
|
4521
4612
|
condition: ({ value }) => {
|
|
4522
|
-
if (!
|
|
4613
|
+
if (!import_editor_props10.cssFilterFunctionPropUtil.isValid(value)) {
|
|
4523
4614
|
return false;
|
|
4524
4615
|
}
|
|
4525
|
-
const args =
|
|
4616
|
+
const args = import_editor_props10.cssFilterFunctionPropUtil.extract(value)?.args;
|
|
4526
4617
|
return hasAssignedSizeVariable(args?.value?.size);
|
|
4527
4618
|
}
|
|
4528
4619
|
});
|
|
@@ -4563,7 +4654,7 @@ function init() {
|
|
|
4563
4654
|
useProps: usePropVariableAction
|
|
4564
4655
|
});
|
|
4565
4656
|
service.init();
|
|
4566
|
-
const variablesMcpRegistry = (0,
|
|
4657
|
+
const variablesMcpRegistry = (0, import_editor_mcp3.getMCPByDomain)("variables", {
|
|
4567
4658
|
instructions: `Everything related to V4 ( Atomic ) variables.
|
|
4568
4659
|
# Global variables
|
|
4569
4660
|
- Create/update/delete global variables
|
|
@@ -4571,7 +4662,7 @@ function init() {
|
|
|
4571
4662
|
- Get details of a global variable
|
|
4572
4663
|
`
|
|
4573
4664
|
});
|
|
4574
|
-
initMcp(variablesMcpRegistry, (0,
|
|
4665
|
+
initMcp(variablesMcpRegistry, (0, import_editor_mcp3.getMCPByDomain)("canvas"));
|
|
4575
4666
|
(0, import_editor.injectIntoTop)({
|
|
4576
4667
|
id: "canvas-style-variables-render",
|
|
4577
4668
|
component: StyleVariablesRenderer
|
|
@@ -4580,9 +4671,13 @@ function init() {
|
|
|
4580
4671
|
id: "variables-import-listener",
|
|
4581
4672
|
component: GlobalStylesImportListener
|
|
4582
4673
|
});
|
|
4674
|
+
(0, import_editor.injectIntoLogic)({
|
|
4675
|
+
id: "mcp-variable-connect-listener",
|
|
4676
|
+
component: McpVariableConnectListener
|
|
4677
|
+
});
|
|
4583
4678
|
}
|
|
4584
4679
|
function hasVariableAssigned(value) {
|
|
4585
|
-
if ((0,
|
|
4680
|
+
if ((0, import_editor_props11.isTransformable)(value)) {
|
|
4586
4681
|
return hasVariableType(value.$$type);
|
|
4587
4682
|
}
|
|
4588
4683
|
return false;
|