@elementor/editor-variables 4.0.0-675 → 4.0.0-677
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +77 -42
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +56 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/ui/variable-promotion-chip.tsx +14 -4
- package/src/components/variables-manager/ui/variable-table-row.tsx +3 -0
- package/src/components/variables-manager/variables-manager-create-menu.tsx +7 -0
- package/src/components/variables-selection.tsx +12 -1
- package/src/register-variable-types.tsx +10 -1
package/dist/index.mjs
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
|
|
16
16
|
// src/components/variables-manager/variables-manager-panel.tsx
|
|
17
17
|
import * as React14 from "react";
|
|
18
|
-
import { useCallback as
|
|
18
|
+
import { useCallback as useCallback6, useEffect as useEffect3, useState as useState6 } from "react";
|
|
19
19
|
import { useSuppressedMessage } from "@elementor/editor-current-user";
|
|
20
20
|
import {
|
|
21
21
|
__createPanel as createPanel,
|
|
@@ -1106,17 +1106,25 @@ var useQuotaPermissions = (variableType) => {
|
|
|
1106
1106
|
|
|
1107
1107
|
// src/components/ui/variable-promotion-chip.tsx
|
|
1108
1108
|
import * as React6 from "react";
|
|
1109
|
-
import { forwardRef, useImperativeHandle, useState as useState3 } from "react";
|
|
1109
|
+
import { forwardRef, useCallback as useCallback4, useImperativeHandle, useState as useState3 } from "react";
|
|
1110
|
+
import { trackUpgradePromotionClick, trackViewPromotion } from "@elementor/editor-controls";
|
|
1110
1111
|
import { PromotionChip, PromotionPopover, useCanvasClickHandler } from "@elementor/editor-ui";
|
|
1111
1112
|
import { Box } from "@elementor/ui";
|
|
1112
1113
|
import { capitalize } from "@elementor/utils";
|
|
1113
1114
|
import { __ as __7, sprintf as sprintf2 } from "@wordpress/i18n";
|
|
1114
1115
|
var VariablePromotionChip = forwardRef(
|
|
1115
|
-
({ variableType, upgradeUrl }, ref) => {
|
|
1116
|
+
({ variableType, upgradeUrl, trackingData }, ref) => {
|
|
1116
1117
|
const [isOpen, setIsOpen] = useState3(false);
|
|
1117
1118
|
useCanvasClickHandler(isOpen, () => setIsOpen(false));
|
|
1118
|
-
const toggle = (
|
|
1119
|
-
|
|
1119
|
+
const toggle = useCallback4(() => {
|
|
1120
|
+
setIsOpen((prev) => {
|
|
1121
|
+
if (!prev) {
|
|
1122
|
+
trackViewPromotion(trackingData);
|
|
1123
|
+
}
|
|
1124
|
+
return !prev;
|
|
1125
|
+
});
|
|
1126
|
+
}, [trackingData]);
|
|
1127
|
+
useImperativeHandle(ref, () => ({ toggle }), [toggle]);
|
|
1120
1128
|
const title = sprintf2(
|
|
1121
1129
|
/* translators: %s: Variable Type. */
|
|
1122
1130
|
__7("%s variables", "elementor"),
|
|
@@ -1138,7 +1146,8 @@ var VariablePromotionChip = forwardRef(
|
|
|
1138
1146
|
onClose: (e) => {
|
|
1139
1147
|
e.stopPropagation();
|
|
1140
1148
|
setIsOpen(false);
|
|
1141
|
-
}
|
|
1149
|
+
},
|
|
1150
|
+
onCtaClick: () => trackUpgradePromotionClick(trackingData)
|
|
1142
1151
|
},
|
|
1143
1152
|
/* @__PURE__ */ React6.createElement(
|
|
1144
1153
|
Box,
|
|
@@ -1156,6 +1165,11 @@ var VariablePromotionChip = forwardRef(
|
|
|
1156
1165
|
);
|
|
1157
1166
|
|
|
1158
1167
|
// src/components/variables-manager/variables-manager-create-menu.tsx
|
|
1168
|
+
var TRACKING_DATA = {
|
|
1169
|
+
target_name: "variables_manager",
|
|
1170
|
+
target_location: "variables_manager",
|
|
1171
|
+
location_l1: "create variable menu"
|
|
1172
|
+
};
|
|
1159
1173
|
var SIZE = "tiny";
|
|
1160
1174
|
var VariableManagerCreateMenu = ({ variables, onCreate, menuState }) => {
|
|
1161
1175
|
const buttonRef = useRef2(null);
|
|
@@ -1238,7 +1252,8 @@ var MenuOption = ({
|
|
|
1238
1252
|
{
|
|
1239
1253
|
variableType: config.variableType,
|
|
1240
1254
|
upgradeUrl: `https://go.elementor.com/go-pro-manager-${config.variableType}-variable/`,
|
|
1241
|
-
ref: promotionRef
|
|
1255
|
+
ref: promotionRef,
|
|
1256
|
+
trackingData: TRACKING_DATA
|
|
1242
1257
|
}
|
|
1243
1258
|
));
|
|
1244
1259
|
};
|
|
@@ -1385,7 +1400,7 @@ var LabelField = ({
|
|
|
1385
1400
|
|
|
1386
1401
|
// src/components/variables-manager/variable-editable-cell.tsx
|
|
1387
1402
|
import * as React10 from "react";
|
|
1388
|
-
import { useCallback as
|
|
1403
|
+
import { useCallback as useCallback5, useEffect, useRef as useRef4, useState as useState5 } from "react";
|
|
1389
1404
|
import { ClickAwayListener, Stack as Stack4 } from "@elementor/ui";
|
|
1390
1405
|
var VariableEditableCell = React10.memo(
|
|
1391
1406
|
({
|
|
@@ -1406,7 +1421,7 @@ var VariableEditableCell = React10.memo(
|
|
|
1406
1421
|
const { labelFieldError, setLabelFieldError } = useLabelError();
|
|
1407
1422
|
const [valueFieldError, setValueFieldError] = useState5("");
|
|
1408
1423
|
const rowRef = useRef4(null);
|
|
1409
|
-
const handleSave =
|
|
1424
|
+
const handleSave = useCallback5(() => {
|
|
1410
1425
|
const hasError = fieldType === "label" && labelFieldError?.message || fieldType === "value" && valueFieldError;
|
|
1411
1426
|
if (!hasError) {
|
|
1412
1427
|
onChange(value);
|
|
@@ -1442,10 +1457,10 @@ var VariableEditableCell = React10.memo(
|
|
|
1442
1457
|
setIsEditing(true);
|
|
1443
1458
|
}
|
|
1444
1459
|
};
|
|
1445
|
-
const handleChange =
|
|
1460
|
+
const handleChange = useCallback5((newValue) => {
|
|
1446
1461
|
setValue(newValue);
|
|
1447
1462
|
}, []);
|
|
1448
|
-
const handleValidationChange =
|
|
1463
|
+
const handleValidationChange = useCallback5(
|
|
1449
1464
|
(errorMsg) => {
|
|
1450
1465
|
if (fieldType === "label") {
|
|
1451
1466
|
setLabelFieldError({
|
|
@@ -1576,6 +1591,7 @@ var VariableEditMenu = ({ menuActions, disabled, itemId }) => {
|
|
|
1576
1591
|
};
|
|
1577
1592
|
|
|
1578
1593
|
// src/components/variables-manager/ui/variable-table-row.tsx
|
|
1594
|
+
var TRACKING_DATA2 = { target_name: "variables_manager", target_location: "variables_manager" };
|
|
1579
1595
|
var VariableRow = (props) => {
|
|
1580
1596
|
const {
|
|
1581
1597
|
row,
|
|
@@ -1738,7 +1754,8 @@ var VariableRow = (props) => {
|
|
|
1738
1754
|
{
|
|
1739
1755
|
variableType: row.variableType,
|
|
1740
1756
|
upgradeUrl: `https://go.elementor.com/renew-license-manager-${row.variableType}-variable`,
|
|
1741
|
-
ref: promotionRef
|
|
1757
|
+
ref: promotionRef,
|
|
1758
|
+
trackingData: TRACKING_DATA2
|
|
1742
1759
|
}
|
|
1743
1760
|
), /* @__PURE__ */ React12.createElement(VariableEditMenu, { menuActions: menuActions(row.id), disabled: isSorting, itemId: row.id })))
|
|
1744
1761
|
);
|
|
@@ -1897,7 +1914,7 @@ function VariablesManagerPanel() {
|
|
|
1897
1914
|
}
|
|
1898
1915
|
closePanel();
|
|
1899
1916
|
};
|
|
1900
|
-
const handleCreateVariable =
|
|
1917
|
+
const handleCreateVariable = useCallback6(
|
|
1901
1918
|
(type, defaultName, defaultValue) => {
|
|
1902
1919
|
const newId = createVariable2(type, defaultName, defaultValue);
|
|
1903
1920
|
if (newId) {
|
|
@@ -1931,21 +1948,21 @@ function VariablesManagerPanel() {
|
|
|
1931
1948
|
setIsSaving(false);
|
|
1932
1949
|
}
|
|
1933
1950
|
};
|
|
1934
|
-
const handleDeleteVariableWithConfirmation =
|
|
1951
|
+
const handleDeleteVariableWithConfirmation = useCallback6(
|
|
1935
1952
|
(itemId) => {
|
|
1936
1953
|
handleDeleteVariable(itemId);
|
|
1937
1954
|
setDeleteConfirmation(null);
|
|
1938
1955
|
},
|
|
1939
1956
|
[handleDeleteVariable]
|
|
1940
1957
|
);
|
|
1941
|
-
const handleStopSyncWithConfirmation =
|
|
1958
|
+
const handleStopSyncWithConfirmation = useCallback6(
|
|
1942
1959
|
(itemId) => {
|
|
1943
1960
|
handleStopSync(itemId);
|
|
1944
1961
|
setStopSyncConfirmation(null);
|
|
1945
1962
|
},
|
|
1946
1963
|
[handleStopSync]
|
|
1947
1964
|
);
|
|
1948
|
-
const handleShowStopSyncDialog =
|
|
1965
|
+
const handleShowStopSyncDialog = useCallback6(
|
|
1949
1966
|
(itemId) => {
|
|
1950
1967
|
if (!isStopSyncSuppressed) {
|
|
1951
1968
|
setStopSyncConfirmation(itemId);
|
|
@@ -1955,7 +1972,7 @@ function VariablesManagerPanel() {
|
|
|
1955
1972
|
},
|
|
1956
1973
|
[isStopSyncSuppressed, handleStopSync]
|
|
1957
1974
|
);
|
|
1958
|
-
const buildMenuActions =
|
|
1975
|
+
const buildMenuActions = useCallback6(
|
|
1959
1976
|
(variableId) => {
|
|
1960
1977
|
const variable = variables[variableId];
|
|
1961
1978
|
if (!variable) {
|
|
@@ -2712,8 +2729,9 @@ var VariableEdit = ({ onClose, onGoBack, onSubmit, editId }) => {
|
|
|
2712
2729
|
};
|
|
2713
2730
|
|
|
2714
2731
|
// src/components/variables-selection.tsx
|
|
2715
|
-
import { useState as useState12 } from "react";
|
|
2732
|
+
import { useEffect as useEffect7, useState as useState12 } from "react";
|
|
2716
2733
|
import * as React21 from "react";
|
|
2734
|
+
import { trackViewPromotion as trackViewPromotion2 } from "@elementor/editor-controls";
|
|
2717
2735
|
import {
|
|
2718
2736
|
PopoverHeader as PopoverHeader3,
|
|
2719
2737
|
PopoverMenuList,
|
|
@@ -2901,6 +2919,15 @@ var VariablesSelection = ({ closePopover, onAdd, onEdit, onSettings, disabled =
|
|
|
2901
2919
|
const handleClearSearch = () => {
|
|
2902
2920
|
setSearchValue("");
|
|
2903
2921
|
};
|
|
2922
|
+
useEffect7(() => {
|
|
2923
|
+
if (disabled) {
|
|
2924
|
+
trackViewPromotion2({
|
|
2925
|
+
target_name: "variables_popover",
|
|
2926
|
+
target_location: "widget_panel",
|
|
2927
|
+
location_l1: "variables_list"
|
|
2928
|
+
});
|
|
2929
|
+
}
|
|
2930
|
+
}, [disabled]);
|
|
2904
2931
|
return /* @__PURE__ */ React21.createElement(SectionPopoverBody3, null, /* @__PURE__ */ React21.createElement(
|
|
2905
2932
|
PopoverHeader3,
|
|
2906
2933
|
{
|
|
@@ -3779,6 +3806,7 @@ function initMcp() {
|
|
|
3779
3806
|
|
|
3780
3807
|
// src/register-variable-types.tsx
|
|
3781
3808
|
import * as React37 from "react";
|
|
3809
|
+
import { trackUpgradePromotionClick as trackUpgradePromotionClick2 } from "@elementor/editor-controls";
|
|
3782
3810
|
import { colorPropTypeUtil, sizePropTypeUtil, stringPropTypeUtil } from "@elementor/editor-props";
|
|
3783
3811
|
import { CtaButton } from "@elementor/editor-ui";
|
|
3784
3812
|
import { isExperimentActive as isExperimentActive2 } from "@elementor/editor-v1-adapters";
|
|
@@ -3961,7 +3989,14 @@ function registerVariableTypes() {
|
|
|
3961
3989
|
styleTransformer: EmptyTransformer,
|
|
3962
3990
|
variableType: "size",
|
|
3963
3991
|
selectionFilter: () => [],
|
|
3964
|
-
emptyState: /* @__PURE__ */ React37.createElement(
|
|
3992
|
+
emptyState: /* @__PURE__ */ React37.createElement(
|
|
3993
|
+
CtaButton,
|
|
3994
|
+
{
|
|
3995
|
+
size: "small",
|
|
3996
|
+
href: "https://go.elementor.com/go-pro-panel-size-variable/",
|
|
3997
|
+
onClick: () => trackUpgradePromotionClick2({ target_name: "variables_popover", location_l1: "variables_list" })
|
|
3998
|
+
}
|
|
3999
|
+
)
|
|
3965
4000
|
};
|
|
3966
4001
|
registerVariableType({
|
|
3967
4002
|
...sizePromotions,
|
|
@@ -3976,7 +4011,7 @@ function registerVariableTypes() {
|
|
|
3976
4011
|
|
|
3977
4012
|
// src/renderers/style-variables-renderer.tsx
|
|
3978
4013
|
import * as React38 from "react";
|
|
3979
|
-
import { useEffect as
|
|
4014
|
+
import { useEffect as useEffect8, useState as useState20 } from "react";
|
|
3980
4015
|
import {
|
|
3981
4016
|
__privateUseListenTo as useListenTo,
|
|
3982
4017
|
commandEndEvent,
|
|
@@ -4000,7 +4035,7 @@ function usePortalContainer() {
|
|
|
4000
4035
|
}
|
|
4001
4036
|
function useStyleVariables() {
|
|
4002
4037
|
const [variables, setVariables] = useState20({});
|
|
4003
|
-
|
|
4038
|
+
useEffect8(() => {
|
|
4004
4039
|
const unsubscribe = styleVariablesRepository.subscribe(setVariables);
|
|
4005
4040
|
return () => {
|
|
4006
4041
|
unsubscribe();
|