@elementor/editor-variables 3.33.0-137 → 3.33.0-139
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +39 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
- package/src/batch-operations.ts +4 -1
- package/src/components/variables-manager/variables-manager-table.tsx +29 -1
- package/src/hooks/use-prop-variables.ts +8 -2
- package/src/storage.ts +1 -0
- package/src/types.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -50,13 +50,14 @@ var buildOperationsArray = (originalVariables, currentVariables) => {
|
|
|
50
50
|
...original.label !== variable.label && { label: variable.label },
|
|
51
51
|
...original.value !== variable.value && { value: variable.value }
|
|
52
52
|
});
|
|
53
|
-
} else if (!variable.deleted && (original.label !== variable.label || original.value !== variable.value)) {
|
|
53
|
+
} else if (!variable.deleted && (original.label !== variable.label || original.value !== variable.value || original.order !== variable.order)) {
|
|
54
54
|
operations.push({
|
|
55
55
|
type: "update",
|
|
56
56
|
id: id2,
|
|
57
57
|
variable: {
|
|
58
58
|
...original.label !== variable.label && { label: variable.label },
|
|
59
|
-
...original.value !== variable.value && { value: variable.value }
|
|
59
|
+
...original.value !== variable.value && { value: variable.value },
|
|
60
|
+
...original.order !== variable.order && { order: variable.order }
|
|
60
61
|
}
|
|
61
62
|
});
|
|
62
63
|
}
|
|
@@ -592,8 +593,13 @@ var useFilteredVariables = (searchValue, propTypeKey) => {
|
|
|
592
593
|
const baseVariables = usePropVariables(propTypeKey);
|
|
593
594
|
const typeFilteredVariables = useVariableSelectionFilter(baseVariables);
|
|
594
595
|
const searchFilteredVariables = filterVariablesBySearchValue(typeFilteredVariables, searchValue);
|
|
596
|
+
const sortedVariables = searchFilteredVariables.sort((a, b) => {
|
|
597
|
+
const orderA = a.order ?? Number.MAX_SAFE_INTEGER;
|
|
598
|
+
const orderB = b.order ?? Number.MAX_SAFE_INTEGER;
|
|
599
|
+
return orderA - orderB;
|
|
600
|
+
});
|
|
595
601
|
return {
|
|
596
|
-
list:
|
|
602
|
+
list: sortedVariables,
|
|
597
603
|
hasMatches: searchFilteredVariables.length > 0,
|
|
598
604
|
isSourceNotEmpty: typeFilteredVariables.length > 0,
|
|
599
605
|
hasNoCompatibleVariables: baseVariables.length > 0 && typeFilteredVariables.length === 0
|
|
@@ -613,10 +619,11 @@ var usePropVariables = (propKey) => {
|
|
|
613
619
|
};
|
|
614
620
|
var normalizeVariables = (propKey) => {
|
|
615
621
|
const variables = getVariables(false);
|
|
616
|
-
return Object.entries(variables).filter(([, variable]) => variable.type === propKey).map(([key, { label, value }]) => ({
|
|
622
|
+
return Object.entries(variables).filter(([, variable]) => variable.type === propKey).map(([key, { label, value, order }]) => ({
|
|
617
623
|
key,
|
|
618
624
|
label,
|
|
619
|
-
value
|
|
625
|
+
value,
|
|
626
|
+
order
|
|
620
627
|
}));
|
|
621
628
|
};
|
|
622
629
|
var extractId = ({ id: id2 }) => id2;
|
|
@@ -1065,7 +1072,13 @@ var VariablesManagerTable = ({
|
|
|
1065
1072
|
variableRowRefs.current.delete(id2);
|
|
1066
1073
|
}
|
|
1067
1074
|
};
|
|
1068
|
-
|
|
1075
|
+
useEffect2(() => {
|
|
1076
|
+
const sortedIds = [...ids].sort(sortVariablesOrder(variables));
|
|
1077
|
+
if (JSON.stringify(sortedIds) !== JSON.stringify(ids)) {
|
|
1078
|
+
setIds(sortedIds);
|
|
1079
|
+
}
|
|
1080
|
+
}, [ids, variables, setIds]);
|
|
1081
|
+
const rows = ids.filter((id2) => !variables[id2].deleted).sort(sortVariablesOrder(variables)).map((id2) => {
|
|
1069
1082
|
const variable = variables[id2];
|
|
1070
1083
|
const variableType = getVariableType(variable.type);
|
|
1071
1084
|
return {
|
|
@@ -1084,7 +1097,19 @@ var VariablesManagerTable = ({
|
|
|
1084
1097
|
UnstableSortableProvider,
|
|
1085
1098
|
{
|
|
1086
1099
|
value: ids,
|
|
1087
|
-
onChange:
|
|
1100
|
+
onChange: (newIds) => {
|
|
1101
|
+
const updatedVariables = { ...variables };
|
|
1102
|
+
newIds.forEach((id2, index) => {
|
|
1103
|
+
if (updatedVariables[id2]) {
|
|
1104
|
+
updatedVariables[id2] = {
|
|
1105
|
+
...updatedVariables[id2],
|
|
1106
|
+
order: index + 1
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1110
|
+
handleOnChange(updatedVariables);
|
|
1111
|
+
setIds(newIds);
|
|
1112
|
+
},
|
|
1088
1113
|
variant: "static",
|
|
1089
1114
|
restrictAxis: true,
|
|
1090
1115
|
dragOverlay: ({ children: dragOverlayChildren, ...dragOverlayProps }) => /* @__PURE__ */ React9.createElement(Table, { sx: tableSX, ...dragOverlayProps }, /* @__PURE__ */ React9.createElement(TableBody, null, dragOverlayChildren))
|
|
@@ -1234,6 +1259,13 @@ var VariablesManagerTable = ({
|
|
|
1234
1259
|
))
|
|
1235
1260
|
))));
|
|
1236
1261
|
};
|
|
1262
|
+
function sortVariablesOrder(variables) {
|
|
1263
|
+
return (a, b) => {
|
|
1264
|
+
const orderA = variables[a]?.order ?? Number.MAX_SAFE_INTEGER;
|
|
1265
|
+
const orderB = variables[b]?.order ?? Number.MAX_SAFE_INTEGER;
|
|
1266
|
+
return orderA - orderB;
|
|
1267
|
+
};
|
|
1268
|
+
}
|
|
1237
1269
|
|
|
1238
1270
|
// src/components/variables-manager/variables-manager-panel.tsx
|
|
1239
1271
|
var id = "variables-manager";
|