@elementor/editor-variables 3.32.0-30 → 3.32.0-31
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 +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +22 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -12
- package/src/components/ui/variable/assigned-variable.tsx +3 -5
- package/src/components/ui/variable/deleted-variable.tsx +3 -4
- package/src/utils/unlink-variable.ts +27 -0
- package/src/variables-registry/create-variable-type-registry.ts +10 -1
package/dist/index.mjs
CHANGED
|
@@ -456,6 +456,7 @@ function createVariableTypeRegistry() {
|
|
|
456
456
|
propTypeUtil,
|
|
457
457
|
variableType,
|
|
458
458
|
selectionFilter,
|
|
459
|
+
valueTransformer,
|
|
459
460
|
fallbackPropTypeUtil
|
|
460
461
|
}) => {
|
|
461
462
|
if (variableTypes[propTypeUtil.key]) {
|
|
@@ -468,6 +469,7 @@ function createVariableTypeRegistry() {
|
|
|
468
469
|
propTypeUtil,
|
|
469
470
|
variableType,
|
|
470
471
|
selectionFilter,
|
|
472
|
+
valueTransformer,
|
|
471
473
|
fallbackPropTypeUtil
|
|
472
474
|
};
|
|
473
475
|
registerTransformer(propTypeUtil.key);
|
|
@@ -495,6 +497,22 @@ function createVariableTypeRegistry() {
|
|
|
495
497
|
// src/variables-registry/variable-type-registry.ts
|
|
496
498
|
var { registerVariableType, getVariableType, hasVariableType } = createVariableTypeRegistry();
|
|
497
499
|
|
|
500
|
+
// src/utils/unlink-variable.ts
|
|
501
|
+
function transformValueBeforeUnlink(variable, propTypeKey) {
|
|
502
|
+
const { valueTransformer } = getVariableType(propTypeKey);
|
|
503
|
+
if (valueTransformer) {
|
|
504
|
+
return valueTransformer(variable.value);
|
|
505
|
+
}
|
|
506
|
+
return variable.value;
|
|
507
|
+
}
|
|
508
|
+
function createUnlinkHandler(variable, propTypeKey, setValue) {
|
|
509
|
+
return () => {
|
|
510
|
+
const { fallbackPropTypeUtil } = getVariableType(propTypeKey);
|
|
511
|
+
const transformedValue = transformValueBeforeUnlink(variable, propTypeKey);
|
|
512
|
+
setValue(fallbackPropTypeUtil.create(transformedValue));
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
|
|
498
516
|
// src/components/variable-selection-popover.tsx
|
|
499
517
|
import * as React15 from "react";
|
|
500
518
|
import { useState as useState7 } from "react";
|
|
@@ -1443,7 +1461,7 @@ var AssignedTag = ({ startIcon, label, onUnlink, ...props }) => {
|
|
|
1443
1461
|
|
|
1444
1462
|
// src/components/ui/variable/assigned-variable.tsx
|
|
1445
1463
|
var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
1446
|
-
const {
|
|
1464
|
+
const { startIcon, propTypeUtil } = getVariableType(propTypeKey);
|
|
1447
1465
|
const { setValue } = useBoundProp6();
|
|
1448
1466
|
const anchorRef = useRef(null);
|
|
1449
1467
|
const popupId = useId2();
|
|
@@ -1451,10 +1469,7 @@ var AssignedVariable = ({ variable, propTypeKey }) => {
|
|
|
1451
1469
|
variant: "popover",
|
|
1452
1470
|
popupId: `elementor-variables-list-${popupId}`
|
|
1453
1471
|
});
|
|
1454
|
-
const unlinkVariable = (
|
|
1455
|
-
const fallbackValue = fallbackPropTypeUtil.create(variable.value);
|
|
1456
|
-
setValue(fallbackValue);
|
|
1457
|
-
};
|
|
1472
|
+
const unlinkVariable = createUnlinkHandler(variable, propTypeKey, setValue);
|
|
1458
1473
|
const StartIcon = startIcon || (() => null);
|
|
1459
1474
|
return /* @__PURE__ */ React17.createElement(Box5, { ref: anchorRef }, /* @__PURE__ */ React17.createElement(
|
|
1460
1475
|
AssignedTag,
|
|
@@ -1634,7 +1649,7 @@ var DeletedTag = React20.forwardRef(({ label, onClick, ...props }, ref) => {
|
|
|
1634
1649
|
|
|
1635
1650
|
// src/components/ui/variable/deleted-variable.tsx
|
|
1636
1651
|
var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
1637
|
-
const {
|
|
1652
|
+
const { propTypeUtil } = getVariableType(propTypeKey);
|
|
1638
1653
|
const { setValue } = useBoundProp8();
|
|
1639
1654
|
const userPermissions = usePermissions();
|
|
1640
1655
|
const [showInfotip, setShowInfotip] = useState9(false);
|
|
@@ -1648,9 +1663,7 @@ var DeletedVariable = ({ variable, propTypeKey }) => {
|
|
|
1648
1663
|
});
|
|
1649
1664
|
const handlers = {};
|
|
1650
1665
|
if (userPermissions.canUnlink()) {
|
|
1651
|
-
handlers.onUnlink = (
|
|
1652
|
-
setValue(fallbackPropTypeUtil.create(variable.value));
|
|
1653
|
-
};
|
|
1666
|
+
handlers.onUnlink = createUnlinkHandler(variable, propTypeKey, setValue);
|
|
1654
1667
|
}
|
|
1655
1668
|
if (userPermissions.canRestore()) {
|
|
1656
1669
|
handlers.onRestore = () => {
|