@elementor/editor-variables 3.35.0-442 → 3.35.0-444
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 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +29 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/variables-manager/hooks/use-variables-manager-state.ts +8 -5
- package/src/components/variables-manager/variables-manager-panel.tsx +1 -1
- package/src/components/variables-manager/variables-manager-table.tsx +0 -1
- package/src/hooks/use-prop-variables.ts +5 -9
- package/src/utils/variables-to-list.ts +33 -0
- package/src/variables-registry/create-variable-type-registry.ts +1 -1
package/dist/index.mjs
CHANGED
|
@@ -875,6 +875,26 @@ function filterBySearch(variables, searchValue) {
|
|
|
875
875
|
return variables.filter((variable) => variable.label.toLowerCase().includes(lowerSearchValue));
|
|
876
876
|
}
|
|
877
877
|
|
|
878
|
+
// src/utils/variables-to-list.ts
|
|
879
|
+
var variablesToList = (variables) => {
|
|
880
|
+
return Object.entries(variables).map(([key, variable]) => ({ key, ...variable }));
|
|
881
|
+
};
|
|
882
|
+
var toNormalizedVariable = ({ key, label, value, order }) => ({
|
|
883
|
+
key,
|
|
884
|
+
label,
|
|
885
|
+
value,
|
|
886
|
+
order
|
|
887
|
+
});
|
|
888
|
+
var applySelectionFilters = (variables, variableTypes) => {
|
|
889
|
+
const grouped = {};
|
|
890
|
+
variables.forEach((item) => (grouped[item.type] ??= []).push(item));
|
|
891
|
+
return Object.entries(grouped).flatMap(([type, vars]) => {
|
|
892
|
+
const filter = variableTypes[type]?.selectionFilter;
|
|
893
|
+
const normalized = vars.map(toNormalizedVariable);
|
|
894
|
+
return (filter?.(normalized) ?? normalized).map((v) => ({ ...v, type }));
|
|
895
|
+
});
|
|
896
|
+
};
|
|
897
|
+
|
|
878
898
|
// src/hooks/use-prop-variables.ts
|
|
879
899
|
var getVariables = (includeDeleted = true) => {
|
|
880
900
|
const variables = service.variables();
|
|
@@ -931,12 +951,7 @@ var getMatchingTypes = (propKey) => {
|
|
|
931
951
|
var normalizeVariables = (propKey) => {
|
|
932
952
|
const variables = getVariables(false);
|
|
933
953
|
const matchingTypes = getMatchingTypes(propKey);
|
|
934
|
-
return
|
|
935
|
-
key,
|
|
936
|
-
label,
|
|
937
|
-
value,
|
|
938
|
-
order
|
|
939
|
-
}));
|
|
954
|
+
return variablesToList(variables).filter((variable) => matchingTypes.includes(variable.type)).map(toNormalizedVariable);
|
|
940
955
|
};
|
|
941
956
|
var extractId = ({ id: id2 }) => id2;
|
|
942
957
|
var createVariable = (newVariable) => {
|
|
@@ -1000,11 +1015,12 @@ var useVariablesManagerState = () => {
|
|
|
1000
1015
|
}
|
|
1001
1016
|
return { success: result.success };
|
|
1002
1017
|
}, [variables]);
|
|
1003
|
-
const filteredVariables = () => {
|
|
1004
|
-
const list =
|
|
1005
|
-
const
|
|
1006
|
-
|
|
1007
|
-
|
|
1018
|
+
const filteredVariables = useCallback3(() => {
|
|
1019
|
+
const list = variablesToList(variables).filter((v) => !v.deleted);
|
|
1020
|
+
const typeFiltered = applySelectionFilters(list, getVariableTypes());
|
|
1021
|
+
const searchFiltered = filterBySearch(typeFiltered, searchValue);
|
|
1022
|
+
return Object.fromEntries(searchFiltered.map(({ key, ...rest }) => [key, rest]));
|
|
1023
|
+
}, [variables, searchValue]);
|
|
1008
1024
|
return {
|
|
1009
1025
|
variables: filteredVariables(),
|
|
1010
1026
|
deletedVariables,
|
|
@@ -1498,7 +1514,7 @@ var VariablesManagerTable = ({
|
|
|
1498
1514
|
}
|
|
1499
1515
|
};
|
|
1500
1516
|
const ids = Object.keys(variables).sort(sortVariablesOrder(variables));
|
|
1501
|
-
const rows = ids.
|
|
1517
|
+
const rows = ids.map((id2) => {
|
|
1502
1518
|
const variable = variables[id2];
|
|
1503
1519
|
const variableType = getVariableType(variable.type);
|
|
1504
1520
|
if (!variableType) {
|
|
@@ -1836,7 +1852,7 @@ function VariablesManagerPanel() {
|
|
|
1836
1852
|
}
|
|
1837
1853
|
}
|
|
1838
1854
|
];
|
|
1839
|
-
const hasVariables = Object.
|
|
1855
|
+
const hasVariables = Object.keys(variables).length > 0;
|
|
1840
1856
|
return /* @__PURE__ */ React12.createElement(ThemeProvider, null, /* @__PURE__ */ React12.createElement(Panel, null, /* @__PURE__ */ React12.createElement(
|
|
1841
1857
|
PanelHeader,
|
|
1842
1858
|
{
|