@elementor/editor-editing-panel 4.2.0-871 → 4.2.0-873
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 +350 -269
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +329 -247
- package/dist/index.mjs.map +1 -1
- package/package.json +24 -24
- package/src/components/creatable-autocomplete/use-filter-options.ts +10 -2
- package/src/components/css-classes/css-class-selector.tsx +99 -28
- package/src/components/settings-tab.tsx +49 -9
package/dist/index.mjs
CHANGED
|
@@ -158,10 +158,12 @@ import {
|
|
|
158
158
|
validateStyleLabel as validateStyleLabel2
|
|
159
159
|
} from "@elementor/editor-styles-repository";
|
|
160
160
|
import { InfoAlert, WarningInfotip } from "@elementor/editor-ui";
|
|
161
|
+
import { isExperimentActive } from "@elementor/editor-v1-adapters";
|
|
161
162
|
import { ColorSwatchIcon, MapPinIcon } from "@elementor/icons";
|
|
162
163
|
import { createLocation as createLocation2 } from "@elementor/locations";
|
|
163
164
|
import {
|
|
164
165
|
Box as Box2,
|
|
166
|
+
Button,
|
|
165
167
|
Chip as Chip3,
|
|
166
168
|
FormLabel,
|
|
167
169
|
Link,
|
|
@@ -374,14 +376,20 @@ function useCreateOption(params) {
|
|
|
374
376
|
|
|
375
377
|
// src/components/creatable-autocomplete/use-filter-options.ts
|
|
376
378
|
import { createFilterOptions } from "@elementor/ui";
|
|
379
|
+
var STRIP_NON_CLASS_CHARS = /[^a-zA-Z0-9_-]/g;
|
|
380
|
+
function normalizeClassSearch(value) {
|
|
381
|
+
return value.replace(STRIP_NON_CLASS_CHARS, "").toLowerCase();
|
|
382
|
+
}
|
|
377
383
|
function useFilterOptions(parameters) {
|
|
378
384
|
const { options: options13, selected, onCreate, entityName } = parameters;
|
|
379
|
-
const filter = createFilterOptions(
|
|
385
|
+
const filter = createFilterOptions({
|
|
386
|
+
matchFrom: "any"
|
|
387
|
+
});
|
|
380
388
|
const filterOptions = (optionList, params) => {
|
|
381
389
|
const selectedValues = selected.map((option) => option.value);
|
|
382
390
|
const filteredOptions = filter(
|
|
383
391
|
optionList.filter((option) => !selectedValues.includes(option.value)),
|
|
384
|
-
params
|
|
392
|
+
{ ...params, inputValue: normalizeClassSearch(params.inputValue) }
|
|
385
393
|
);
|
|
386
394
|
const isExisting = options13.some((option) => params.inputValue === option.label);
|
|
387
395
|
const allowCreate = Boolean(onCreate) && params.inputValue !== "" && !selectedValues.includes(params.inputValue) && !isExisting;
|
|
@@ -1240,6 +1248,19 @@ var validateLabel = (newLabel) => {
|
|
|
1240
1248
|
// src/components/css-classes/css-class-selector.tsx
|
|
1241
1249
|
var ID = "elementor-css-class-selector";
|
|
1242
1250
|
var TAGS_LIMIT = 50;
|
|
1251
|
+
var EVENT_OPEN_GLOBAL_CLASSES_MANAGER = "elementor/open-global-classes-manager";
|
|
1252
|
+
var EVENT_TOGGLE_DESIGN_SYSTEM = "elementor/toggle-design-system";
|
|
1253
|
+
function openClassManagerPanel() {
|
|
1254
|
+
if (isExperimentActive("e_editor_design_system_panel")) {
|
|
1255
|
+
window.dispatchEvent(
|
|
1256
|
+
new CustomEvent(EVENT_TOGGLE_DESIGN_SYSTEM, {
|
|
1257
|
+
detail: { tab: "classes" }
|
|
1258
|
+
})
|
|
1259
|
+
);
|
|
1260
|
+
return;
|
|
1261
|
+
}
|
|
1262
|
+
window.dispatchEvent(new CustomEvent(EVENT_OPEN_GLOBAL_CLASSES_MANAGER));
|
|
1263
|
+
}
|
|
1243
1264
|
var EMPTY_OPTION = {
|
|
1244
1265
|
label: __6("local", "elementor"),
|
|
1245
1266
|
value: null,
|
|
@@ -1255,7 +1276,7 @@ function CssClassSelector() {
|
|
|
1255
1276
|
const autocompleteRef = useRef(null);
|
|
1256
1277
|
const [renameError, setRenameError] = useState4(null);
|
|
1257
1278
|
const handleSelect = useHandleSelect();
|
|
1258
|
-
const { create, validate, entityName } = useCreateAction();
|
|
1279
|
+
const { create, validate, entityName, isAtLimit, limitCount } = useCreateAction();
|
|
1259
1280
|
const appliedOptions = useAppliedOptions(options13);
|
|
1260
1281
|
const active = appliedOptions.find((option) => option.value === activeId) ?? EMPTY_OPTION;
|
|
1261
1282
|
const showPlaceholder = appliedOptions.every(({ fixed }) => fixed);
|
|
@@ -1284,7 +1305,7 @@ function CssClassSelector() {
|
|
|
1284
1305
|
onCreate: create ?? void 0,
|
|
1285
1306
|
validate: validate ?? void 0,
|
|
1286
1307
|
limitTags: TAGS_LIMIT,
|
|
1287
|
-
renderEmptyState: EmptyState,
|
|
1308
|
+
renderEmptyState: isAtLimit && typeof limitCount === "number" ? (props) => /* @__PURE__ */ React11.createElement(LimitReachedEmptyState, { limitCount, onClear: props.onClear }) : EmptyState,
|
|
1288
1309
|
getLimitTagsText: (more) => /* @__PURE__ */ React11.createElement(Chip3, { size: "tiny", variant: "standard", label: `+${more}`, clickable: true }),
|
|
1289
1310
|
renderTags: (values, getTagProps) => values.map((value, index) => {
|
|
1290
1311
|
const chipProps = getTagProps({ index });
|
|
@@ -1323,7 +1344,7 @@ function CssClassSelector() {
|
|
|
1323
1344
|
)
|
|
1324
1345
|
), !canEdit && /* @__PURE__ */ React11.createElement(InfoAlert, { sx: { mt: 1 } }, __6("With your current role, you can use existing classes but can\u2019t modify them.", "elementor")));
|
|
1325
1346
|
}
|
|
1326
|
-
var
|
|
1347
|
+
var EmptyStateLayout = ({ searchValue, onClear, children }) => /* @__PURE__ */ React11.createElement(Box2, { sx: { py: 4 } }, /* @__PURE__ */ React11.createElement(
|
|
1327
1348
|
Stack3,
|
|
1328
1349
|
{
|
|
1329
1350
|
gap: 1,
|
|
@@ -1334,9 +1355,54 @@ var EmptyState = ({ searchValue, onClear }) => /* @__PURE__ */ React11.createEle
|
|
|
1334
1355
|
},
|
|
1335
1356
|
/* @__PURE__ */ React11.createElement(ColorSwatchIcon, { sx: { transform: "rotate(90deg)" }, fontSize: "large" }),
|
|
1336
1357
|
/* @__PURE__ */ React11.createElement(Typography3, { align: "center", variant: "subtitle2" }, __6("Sorry, nothing matched", "elementor"), /* @__PURE__ */ React11.createElement("br", null), "\u201C", searchValue, "\u201D."),
|
|
1337
|
-
|
|
1358
|
+
children,
|
|
1338
1359
|
/* @__PURE__ */ React11.createElement(Link, { color: "text.secondary", variant: "caption", component: "button", onClick: onClear }, __6("Clear & try again", "elementor"))
|
|
1339
1360
|
));
|
|
1361
|
+
var EmptyState = (props) => /* @__PURE__ */ React11.createElement(EmptyStateLayout, { ...props }, /* @__PURE__ */ React11.createElement(Typography3, { align: "center", variant: "caption", sx: { mb: 2 } }, __6("With your current role,", "elementor"), /* @__PURE__ */ React11.createElement("br", null), __6("you can only use existing classes.", "elementor")));
|
|
1362
|
+
var LimitReachedEmptyState = ({
|
|
1363
|
+
limitCount,
|
|
1364
|
+
onClear
|
|
1365
|
+
}) => /* @__PURE__ */ React11.createElement(Box2, { sx: { py: 4 } }, /* @__PURE__ */ React11.createElement(
|
|
1366
|
+
Stack3,
|
|
1367
|
+
{
|
|
1368
|
+
gap: 1,
|
|
1369
|
+
alignItems: "center",
|
|
1370
|
+
color: "text.secondary",
|
|
1371
|
+
justifyContent: "center",
|
|
1372
|
+
sx: { px: 1, m: "auto", maxWidth: "260px" }
|
|
1373
|
+
},
|
|
1374
|
+
/* @__PURE__ */ React11.createElement(ColorSwatchIcon, { sx: { transform: "rotate(90deg)" }, fontSize: "large" }),
|
|
1375
|
+
/* @__PURE__ */ React11.createElement(
|
|
1376
|
+
Typography3,
|
|
1377
|
+
{ align: "center", variant: "subtitle2" },
|
|
1378
|
+
/* translators: %s is the maximum number of classes */
|
|
1379
|
+
__6("Limit of %s classes reached", "elementor").replace("%s", String(limitCount))
|
|
1380
|
+
),
|
|
1381
|
+
/* @__PURE__ */ React11.createElement(Typography3, { align: "center", variant: "caption", component: "div" }, __6("Remove a class to create a new one.", "elementor"), " ", /* @__PURE__ */ React11.createElement(
|
|
1382
|
+
Link,
|
|
1383
|
+
{
|
|
1384
|
+
color: "inherit",
|
|
1385
|
+
variant: "caption",
|
|
1386
|
+
component: "button",
|
|
1387
|
+
onClick: onClear,
|
|
1388
|
+
sx: { verticalAlign: "baseline" }
|
|
1389
|
+
},
|
|
1390
|
+
__6("Clear", "elementor")
|
|
1391
|
+
)),
|
|
1392
|
+
/* @__PURE__ */ React11.createElement(
|
|
1393
|
+
Button,
|
|
1394
|
+
{
|
|
1395
|
+
variant: "outlined",
|
|
1396
|
+
color: "secondary",
|
|
1397
|
+
size: "small",
|
|
1398
|
+
onClick: () => {
|
|
1399
|
+
openClassManagerPanel();
|
|
1400
|
+
onClear();
|
|
1401
|
+
}
|
|
1402
|
+
},
|
|
1403
|
+
__6("Class Manager", "elementor")
|
|
1404
|
+
)
|
|
1405
|
+
));
|
|
1340
1406
|
var updateClassByProvider = (provider, data) => {
|
|
1341
1407
|
if (!provider) {
|
|
1342
1408
|
return;
|
|
@@ -1379,6 +1445,11 @@ function useCreateAction() {
|
|
|
1379
1445
|
if (!provider || !createAction) {
|
|
1380
1446
|
return {};
|
|
1381
1447
|
}
|
|
1448
|
+
const entityName = provider.labels.singular && provider.labels.plural ? provider.labels : void 0;
|
|
1449
|
+
const validate = (newClassLabel, event) => validateStyleLabel2(newClassLabel, event);
|
|
1450
|
+
if (hasReachedLimit(provider)) {
|
|
1451
|
+
return { entityName, isAtLimit: true, limitCount: provider.limit, validate };
|
|
1452
|
+
}
|
|
1382
1453
|
const create = (classLabel) => {
|
|
1383
1454
|
const { createdId } = createAction({ classLabel });
|
|
1384
1455
|
trackStyles(provider.getKey() ?? "", "classCreated", {
|
|
@@ -1387,21 +1458,7 @@ function useCreateAction() {
|
|
|
1387
1458
|
classId: createdId
|
|
1388
1459
|
});
|
|
1389
1460
|
};
|
|
1390
|
-
|
|
1391
|
-
if (hasReachedLimit(provider)) {
|
|
1392
|
-
return {
|
|
1393
|
-
isValid: false,
|
|
1394
|
-
/* translators: %s is the maximum number of classes */
|
|
1395
|
-
errorMessage: __6(
|
|
1396
|
-
"You\u2019ve reached the limit of %s classes. Please remove an existing one to create a new class.",
|
|
1397
|
-
"elementor"
|
|
1398
|
-
).replace("%s", provider.limit.toString())
|
|
1399
|
-
};
|
|
1400
|
-
}
|
|
1401
|
-
return validateStyleLabel2(newClassLabel, event);
|
|
1402
|
-
};
|
|
1403
|
-
const entityName = provider.labels.singular && provider.labels.plural ? provider.labels : void 0;
|
|
1404
|
-
return { create, validate, entityName };
|
|
1461
|
+
return { create, validate, entityName, isAtLimit: false };
|
|
1405
1462
|
}
|
|
1406
1463
|
function hasReachedLimit(provider) {
|
|
1407
1464
|
return provider.actions.all().length >= provider.limit;
|
|
@@ -1832,7 +1889,7 @@ function EditorPanelErrorFallback() {
|
|
|
1832
1889
|
import { Fragment as Fragment9 } from "react";
|
|
1833
1890
|
import * as React86 from "react";
|
|
1834
1891
|
import { getWidgetsCache as getWidgetsCache2 } from "@elementor/editor-elements";
|
|
1835
|
-
import { isExperimentActive as
|
|
1892
|
+
import { isExperimentActive as isExperimentActive4 } from "@elementor/editor-v1-adapters";
|
|
1836
1893
|
import { Divider as Divider6, Stack as Stack13, Tab, TabPanel, Tabs, useTabs } from "@elementor/ui";
|
|
1837
1894
|
import { __ as __60 } from "@wordpress/i18n";
|
|
1838
1895
|
|
|
@@ -1944,6 +2001,219 @@ var InteractionsTab = () => {
|
|
|
1944
2001
|
import * as React23 from "react";
|
|
1945
2002
|
import { SessionStorageProvider } from "@elementor/session";
|
|
1946
2003
|
|
|
2004
|
+
// src/utils/prop-dependency-utils.ts
|
|
2005
|
+
import {
|
|
2006
|
+
extractValue,
|
|
2007
|
+
isDependency,
|
|
2008
|
+
isDependencyMet,
|
|
2009
|
+
isOverridable,
|
|
2010
|
+
isTransformable,
|
|
2011
|
+
rewrapOverridableValue
|
|
2012
|
+
} from "@elementor/editor-props";
|
|
2013
|
+
import { getSessionStorageItem as getSessionStorageItem2, removeSessionStorageItem, setSessionStorageItem as setSessionStorageItem2 } from "@elementor/session";
|
|
2014
|
+
function getElementSettingsWithDefaults(propsSchema, elementSettings) {
|
|
2015
|
+
const elementSettingsWithDefaults = { ...elementSettings };
|
|
2016
|
+
Object.keys(propsSchema).forEach((key) => {
|
|
2017
|
+
if (elementSettingsWithDefaults[key] === null && propsSchema[key].default !== null) {
|
|
2018
|
+
elementSettingsWithDefaults[key] = propsSchema[key].default;
|
|
2019
|
+
}
|
|
2020
|
+
});
|
|
2021
|
+
return elementSettingsWithDefaults;
|
|
2022
|
+
}
|
|
2023
|
+
function extractDependencyEffect(bind, propsSchema, settings) {
|
|
2024
|
+
const settingsWithDefaults = getElementSettingsWithDefaults(propsSchema, settings);
|
|
2025
|
+
const propType = propsSchema[bind];
|
|
2026
|
+
const depCheck = isDependencyMet(propType?.dependencies, settingsWithDefaults);
|
|
2027
|
+
const failingTerm = !depCheck.isMet ? depCheck.failingDependencies[0] : void 0;
|
|
2028
|
+
const isHidden = !!failingTerm && !isDependency(failingTerm) && failingTerm?.effect === "hide";
|
|
2029
|
+
return {
|
|
2030
|
+
isHidden,
|
|
2031
|
+
isDisabled: (prop) => !isDependencyMet(prop?.dependencies, settingsWithDefaults).isMet
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2034
|
+
function extractOrderedDependencies(dependenciesPerTargetMapping) {
|
|
2035
|
+
return Object.values(dependenciesPerTargetMapping).flat().filter((dependent, index, self) => self.indexOf(dependent) === index);
|
|
2036
|
+
}
|
|
2037
|
+
function getUpdatedValues(values, dependencies, propsSchema, elementValues, elementId) {
|
|
2038
|
+
if (!dependencies.length) {
|
|
2039
|
+
return values;
|
|
2040
|
+
}
|
|
2041
|
+
return dependencies.reduce(
|
|
2042
|
+
(newValues, dependency) => {
|
|
2043
|
+
const path = dependency.split(".");
|
|
2044
|
+
const combinedValues = { ...elementValues, ...newValues };
|
|
2045
|
+
const propType = getPropType(propsSchema, combinedValues, path);
|
|
2046
|
+
if (!propType) {
|
|
2047
|
+
return newValues;
|
|
2048
|
+
}
|
|
2049
|
+
const testDependencies = {
|
|
2050
|
+
previousValues: isDependencyMet(propType.dependencies, elementValues),
|
|
2051
|
+
newValues: isDependencyMet(propType.dependencies, combinedValues)
|
|
2052
|
+
};
|
|
2053
|
+
if (!testDependencies.newValues.isMet) {
|
|
2054
|
+
const newValue = handleUnmetCondition({
|
|
2055
|
+
failingDependencies: testDependencies.newValues.failingDependencies,
|
|
2056
|
+
dependency,
|
|
2057
|
+
elementValues: combinedValues,
|
|
2058
|
+
defaultValue: propType.default,
|
|
2059
|
+
elementId
|
|
2060
|
+
});
|
|
2061
|
+
return {
|
|
2062
|
+
...newValues,
|
|
2063
|
+
...updateValue(path, newValue, combinedValues)
|
|
2064
|
+
};
|
|
2065
|
+
}
|
|
2066
|
+
if (!testDependencies.previousValues.isMet) {
|
|
2067
|
+
const savedValue = retrievePreviousValueFromStorage({ path: dependency, elementId });
|
|
2068
|
+
const currentValue = extractValue(path, combinedValues, [], {
|
|
2069
|
+
unwrapOverridableLeaf: false
|
|
2070
|
+
});
|
|
2071
|
+
removePreviousValueFromStorage({ path: dependency, elementId });
|
|
2072
|
+
const restored = isCompatibleSavedValue(savedValue, currentValue) ? savedValue : propType.default;
|
|
2073
|
+
return {
|
|
2074
|
+
...newValues,
|
|
2075
|
+
...updateValue(path, restored, combinedValues)
|
|
2076
|
+
};
|
|
2077
|
+
}
|
|
2078
|
+
return newValues;
|
|
2079
|
+
},
|
|
2080
|
+
{ ...values }
|
|
2081
|
+
);
|
|
2082
|
+
}
|
|
2083
|
+
function getPropType(schema, elementValues, path) {
|
|
2084
|
+
if (!path.length) {
|
|
2085
|
+
return null;
|
|
2086
|
+
}
|
|
2087
|
+
const [basePropKey, ...keys] = path;
|
|
2088
|
+
const baseProp = schema[basePropKey];
|
|
2089
|
+
if (!baseProp) {
|
|
2090
|
+
return null;
|
|
2091
|
+
}
|
|
2092
|
+
return keys.reduce(
|
|
2093
|
+
(prop, key, index) => evaluatePropType({ prop, key, index, path, elementValues, basePropKey }),
|
|
2094
|
+
baseProp
|
|
2095
|
+
);
|
|
2096
|
+
}
|
|
2097
|
+
function evaluatePropType(props) {
|
|
2098
|
+
const { prop } = props;
|
|
2099
|
+
if (!prop?.kind) {
|
|
2100
|
+
return null;
|
|
2101
|
+
}
|
|
2102
|
+
const { key, index, path, elementValues, basePropKey } = props;
|
|
2103
|
+
switch (prop.kind) {
|
|
2104
|
+
case "union":
|
|
2105
|
+
const value = extractValue(path.slice(0, index + 1), elementValues);
|
|
2106
|
+
const type = value?.$$type ?? null;
|
|
2107
|
+
return getPropType(
|
|
2108
|
+
{ [basePropKey]: prop.prop_types?.[type] },
|
|
2109
|
+
elementValues,
|
|
2110
|
+
path.slice(0, index + 2)
|
|
2111
|
+
);
|
|
2112
|
+
case "array":
|
|
2113
|
+
return prop.item_prop_type;
|
|
2114
|
+
case "object":
|
|
2115
|
+
return prop.shape[key];
|
|
2116
|
+
}
|
|
2117
|
+
return prop[key];
|
|
2118
|
+
}
|
|
2119
|
+
function updateValue(path, value, values) {
|
|
2120
|
+
const topPropKey = path[0];
|
|
2121
|
+
const root = { ...values };
|
|
2122
|
+
let carry = root;
|
|
2123
|
+
for (let index = 0; index < path.length; index++) {
|
|
2124
|
+
const key = path[index];
|
|
2125
|
+
const isLeaf = index === path.length - 1;
|
|
2126
|
+
if (isLeaf) {
|
|
2127
|
+
carry[key] = mergeLeafValue(carry[key], value);
|
|
2128
|
+
break;
|
|
2129
|
+
}
|
|
2130
|
+
const next = cloneDescent(carry[key]);
|
|
2131
|
+
if (!next) {
|
|
2132
|
+
break;
|
|
2133
|
+
}
|
|
2134
|
+
carry[key] = next.replacement;
|
|
2135
|
+
carry = next.descended;
|
|
2136
|
+
}
|
|
2137
|
+
return { [topPropKey]: root[topPropKey] ?? null };
|
|
2138
|
+
}
|
|
2139
|
+
function cloneDescent(child) {
|
|
2140
|
+
if (!child) {
|
|
2141
|
+
return null;
|
|
2142
|
+
}
|
|
2143
|
+
if (isOverridable(child)) {
|
|
2144
|
+
const origin = child.value.origin_value;
|
|
2145
|
+
if (!origin || !isTransformable(origin)) {
|
|
2146
|
+
return null;
|
|
2147
|
+
}
|
|
2148
|
+
const descended = { ...origin.value };
|
|
2149
|
+
const replacement = {
|
|
2150
|
+
...child,
|
|
2151
|
+
value: {
|
|
2152
|
+
...child.value,
|
|
2153
|
+
origin_value: { ...origin, value: descended }
|
|
2154
|
+
}
|
|
2155
|
+
};
|
|
2156
|
+
return { replacement, descended };
|
|
2157
|
+
}
|
|
2158
|
+
if (isTransformable(child)) {
|
|
2159
|
+
const descended = { ...child.value };
|
|
2160
|
+
const replacement = { ...child, value: descended };
|
|
2161
|
+
return { replacement, descended };
|
|
2162
|
+
}
|
|
2163
|
+
return null;
|
|
2164
|
+
}
|
|
2165
|
+
function isCompatibleSavedValue(saved, current) {
|
|
2166
|
+
if (!saved) {
|
|
2167
|
+
return false;
|
|
2168
|
+
}
|
|
2169
|
+
return isOverridable(saved) === isOverridable(current);
|
|
2170
|
+
}
|
|
2171
|
+
function mergeLeafValue(existing, incoming) {
|
|
2172
|
+
if (incoming === null) {
|
|
2173
|
+
return null;
|
|
2174
|
+
}
|
|
2175
|
+
if (incoming && isOverridable(incoming)) {
|
|
2176
|
+
return incoming;
|
|
2177
|
+
}
|
|
2178
|
+
if (existing && isOverridable(existing) && incoming) {
|
|
2179
|
+
return rewrapOverridableValue(existing, incoming);
|
|
2180
|
+
}
|
|
2181
|
+
return incoming;
|
|
2182
|
+
}
|
|
2183
|
+
function handleUnmetCondition(props) {
|
|
2184
|
+
const { failingDependencies, dependency, elementValues, defaultValue, elementId } = props;
|
|
2185
|
+
const termWithNewValue = failingDependencies.find(
|
|
2186
|
+
(term) => "newValue" in term && !!term.newValue
|
|
2187
|
+
);
|
|
2188
|
+
const newValue = termWithNewValue?.newValue ?? null;
|
|
2189
|
+
const currentValue = extractValue(dependency.split("."), elementValues, [], { unwrapOverridableLeaf: false }) ?? defaultValue;
|
|
2190
|
+
savePreviousValueToStorage({
|
|
2191
|
+
path: dependency,
|
|
2192
|
+
elementId,
|
|
2193
|
+
value: currentValue
|
|
2194
|
+
});
|
|
2195
|
+
return newValue;
|
|
2196
|
+
}
|
|
2197
|
+
function savePreviousValueToStorage({ path, elementId, value }) {
|
|
2198
|
+
const prefix = `elementor/${elementId}`;
|
|
2199
|
+
const savedValue = retrievePreviousValueFromStorage({ path, elementId });
|
|
2200
|
+
if (savedValue) {
|
|
2201
|
+
return;
|
|
2202
|
+
}
|
|
2203
|
+
const key = `${prefix}:${path}`;
|
|
2204
|
+
setSessionStorageItem2(key, value);
|
|
2205
|
+
}
|
|
2206
|
+
function retrievePreviousValueFromStorage({ path, elementId }) {
|
|
2207
|
+
const prefix = `elementor/${elementId}`;
|
|
2208
|
+
const key = `${prefix}:${path}`;
|
|
2209
|
+
return getSessionStorageItem2(key) ?? null;
|
|
2210
|
+
}
|
|
2211
|
+
function removePreviousValueFromStorage({ path, elementId }) {
|
|
2212
|
+
const prefix = `elementor/${elementId}`;
|
|
2213
|
+
const key = `${prefix}:${path}`;
|
|
2214
|
+
removeSessionStorageItem(key);
|
|
2215
|
+
}
|
|
2216
|
+
|
|
1947
2217
|
// src/components/section.tsx
|
|
1948
2218
|
import * as React17 from "react";
|
|
1949
2219
|
import { useId as useId2, useRef as useRef3 } from "react";
|
|
@@ -2187,219 +2457,6 @@ import { getElementLabel as getElementLabel3, getElementSettings, updateElementS
|
|
|
2187
2457
|
import { undoable as undoable4 } from "@elementor/editor-v1-adapters";
|
|
2188
2458
|
import { __ as __8 } from "@wordpress/i18n";
|
|
2189
2459
|
|
|
2190
|
-
// src/utils/prop-dependency-utils.ts
|
|
2191
|
-
import {
|
|
2192
|
-
extractValue,
|
|
2193
|
-
isDependency,
|
|
2194
|
-
isDependencyMet,
|
|
2195
|
-
isOverridable,
|
|
2196
|
-
isTransformable,
|
|
2197
|
-
rewrapOverridableValue
|
|
2198
|
-
} from "@elementor/editor-props";
|
|
2199
|
-
import { getSessionStorageItem as getSessionStorageItem2, removeSessionStorageItem, setSessionStorageItem as setSessionStorageItem2 } from "@elementor/session";
|
|
2200
|
-
function getElementSettingsWithDefaults(propsSchema, elementSettings) {
|
|
2201
|
-
const elementSettingsWithDefaults = { ...elementSettings };
|
|
2202
|
-
Object.keys(propsSchema).forEach((key) => {
|
|
2203
|
-
if (elementSettingsWithDefaults[key] === null && propsSchema[key].default !== null) {
|
|
2204
|
-
elementSettingsWithDefaults[key] = propsSchema[key].default;
|
|
2205
|
-
}
|
|
2206
|
-
});
|
|
2207
|
-
return elementSettingsWithDefaults;
|
|
2208
|
-
}
|
|
2209
|
-
function extractDependencyEffect(bind, propsSchema, settings) {
|
|
2210
|
-
const settingsWithDefaults = getElementSettingsWithDefaults(propsSchema, settings);
|
|
2211
|
-
const propType = propsSchema[bind];
|
|
2212
|
-
const depCheck = isDependencyMet(propType?.dependencies, settingsWithDefaults);
|
|
2213
|
-
const failingTerm = !depCheck.isMet ? depCheck.failingDependencies[0] : void 0;
|
|
2214
|
-
const isHidden = !!failingTerm && !isDependency(failingTerm) && failingTerm?.effect === "hide";
|
|
2215
|
-
return {
|
|
2216
|
-
isHidden,
|
|
2217
|
-
isDisabled: (prop) => !isDependencyMet(prop?.dependencies, settingsWithDefaults).isMet
|
|
2218
|
-
};
|
|
2219
|
-
}
|
|
2220
|
-
function extractOrderedDependencies(dependenciesPerTargetMapping) {
|
|
2221
|
-
return Object.values(dependenciesPerTargetMapping).flat().filter((dependent, index, self) => self.indexOf(dependent) === index);
|
|
2222
|
-
}
|
|
2223
|
-
function getUpdatedValues(values, dependencies, propsSchema, elementValues, elementId) {
|
|
2224
|
-
if (!dependencies.length) {
|
|
2225
|
-
return values;
|
|
2226
|
-
}
|
|
2227
|
-
return dependencies.reduce(
|
|
2228
|
-
(newValues, dependency) => {
|
|
2229
|
-
const path = dependency.split(".");
|
|
2230
|
-
const combinedValues = { ...elementValues, ...newValues };
|
|
2231
|
-
const propType = getPropType(propsSchema, combinedValues, path);
|
|
2232
|
-
if (!propType) {
|
|
2233
|
-
return newValues;
|
|
2234
|
-
}
|
|
2235
|
-
const testDependencies = {
|
|
2236
|
-
previousValues: isDependencyMet(propType.dependencies, elementValues),
|
|
2237
|
-
newValues: isDependencyMet(propType.dependencies, combinedValues)
|
|
2238
|
-
};
|
|
2239
|
-
if (!testDependencies.newValues.isMet) {
|
|
2240
|
-
const newValue = handleUnmetCondition({
|
|
2241
|
-
failingDependencies: testDependencies.newValues.failingDependencies,
|
|
2242
|
-
dependency,
|
|
2243
|
-
elementValues: combinedValues,
|
|
2244
|
-
defaultValue: propType.default,
|
|
2245
|
-
elementId
|
|
2246
|
-
});
|
|
2247
|
-
return {
|
|
2248
|
-
...newValues,
|
|
2249
|
-
...updateValue(path, newValue, combinedValues)
|
|
2250
|
-
};
|
|
2251
|
-
}
|
|
2252
|
-
if (!testDependencies.previousValues.isMet) {
|
|
2253
|
-
const savedValue = retrievePreviousValueFromStorage({ path: dependency, elementId });
|
|
2254
|
-
const currentValue = extractValue(path, combinedValues, [], {
|
|
2255
|
-
unwrapOverridableLeaf: false
|
|
2256
|
-
});
|
|
2257
|
-
removePreviousValueFromStorage({ path: dependency, elementId });
|
|
2258
|
-
const restored = isCompatibleSavedValue(savedValue, currentValue) ? savedValue : propType.default;
|
|
2259
|
-
return {
|
|
2260
|
-
...newValues,
|
|
2261
|
-
...updateValue(path, restored, combinedValues)
|
|
2262
|
-
};
|
|
2263
|
-
}
|
|
2264
|
-
return newValues;
|
|
2265
|
-
},
|
|
2266
|
-
{ ...values }
|
|
2267
|
-
);
|
|
2268
|
-
}
|
|
2269
|
-
function getPropType(schema, elementValues, path) {
|
|
2270
|
-
if (!path.length) {
|
|
2271
|
-
return null;
|
|
2272
|
-
}
|
|
2273
|
-
const [basePropKey, ...keys] = path;
|
|
2274
|
-
const baseProp = schema[basePropKey];
|
|
2275
|
-
if (!baseProp) {
|
|
2276
|
-
return null;
|
|
2277
|
-
}
|
|
2278
|
-
return keys.reduce(
|
|
2279
|
-
(prop, key, index) => evaluatePropType({ prop, key, index, path, elementValues, basePropKey }),
|
|
2280
|
-
baseProp
|
|
2281
|
-
);
|
|
2282
|
-
}
|
|
2283
|
-
function evaluatePropType(props) {
|
|
2284
|
-
const { prop } = props;
|
|
2285
|
-
if (!prop?.kind) {
|
|
2286
|
-
return null;
|
|
2287
|
-
}
|
|
2288
|
-
const { key, index, path, elementValues, basePropKey } = props;
|
|
2289
|
-
switch (prop.kind) {
|
|
2290
|
-
case "union":
|
|
2291
|
-
const value = extractValue(path.slice(0, index + 1), elementValues);
|
|
2292
|
-
const type = value?.$$type ?? null;
|
|
2293
|
-
return getPropType(
|
|
2294
|
-
{ [basePropKey]: prop.prop_types?.[type] },
|
|
2295
|
-
elementValues,
|
|
2296
|
-
path.slice(0, index + 2)
|
|
2297
|
-
);
|
|
2298
|
-
case "array":
|
|
2299
|
-
return prop.item_prop_type;
|
|
2300
|
-
case "object":
|
|
2301
|
-
return prop.shape[key];
|
|
2302
|
-
}
|
|
2303
|
-
return prop[key];
|
|
2304
|
-
}
|
|
2305
|
-
function updateValue(path, value, values) {
|
|
2306
|
-
const topPropKey = path[0];
|
|
2307
|
-
const root = { ...values };
|
|
2308
|
-
let carry = root;
|
|
2309
|
-
for (let index = 0; index < path.length; index++) {
|
|
2310
|
-
const key = path[index];
|
|
2311
|
-
const isLeaf = index === path.length - 1;
|
|
2312
|
-
if (isLeaf) {
|
|
2313
|
-
carry[key] = mergeLeafValue(carry[key], value);
|
|
2314
|
-
break;
|
|
2315
|
-
}
|
|
2316
|
-
const next = cloneDescent(carry[key]);
|
|
2317
|
-
if (!next) {
|
|
2318
|
-
break;
|
|
2319
|
-
}
|
|
2320
|
-
carry[key] = next.replacement;
|
|
2321
|
-
carry = next.descended;
|
|
2322
|
-
}
|
|
2323
|
-
return { [topPropKey]: root[topPropKey] ?? null };
|
|
2324
|
-
}
|
|
2325
|
-
function cloneDescent(child) {
|
|
2326
|
-
if (!child) {
|
|
2327
|
-
return null;
|
|
2328
|
-
}
|
|
2329
|
-
if (isOverridable(child)) {
|
|
2330
|
-
const origin = child.value.origin_value;
|
|
2331
|
-
if (!origin || !isTransformable(origin)) {
|
|
2332
|
-
return null;
|
|
2333
|
-
}
|
|
2334
|
-
const descended = { ...origin.value };
|
|
2335
|
-
const replacement = {
|
|
2336
|
-
...child,
|
|
2337
|
-
value: {
|
|
2338
|
-
...child.value,
|
|
2339
|
-
origin_value: { ...origin, value: descended }
|
|
2340
|
-
}
|
|
2341
|
-
};
|
|
2342
|
-
return { replacement, descended };
|
|
2343
|
-
}
|
|
2344
|
-
if (isTransformable(child)) {
|
|
2345
|
-
const descended = { ...child.value };
|
|
2346
|
-
const replacement = { ...child, value: descended };
|
|
2347
|
-
return { replacement, descended };
|
|
2348
|
-
}
|
|
2349
|
-
return null;
|
|
2350
|
-
}
|
|
2351
|
-
function isCompatibleSavedValue(saved, current) {
|
|
2352
|
-
if (!saved) {
|
|
2353
|
-
return false;
|
|
2354
|
-
}
|
|
2355
|
-
return isOverridable(saved) === isOverridable(current);
|
|
2356
|
-
}
|
|
2357
|
-
function mergeLeafValue(existing, incoming) {
|
|
2358
|
-
if (incoming === null) {
|
|
2359
|
-
return null;
|
|
2360
|
-
}
|
|
2361
|
-
if (incoming && isOverridable(incoming)) {
|
|
2362
|
-
return incoming;
|
|
2363
|
-
}
|
|
2364
|
-
if (existing && isOverridable(existing) && incoming) {
|
|
2365
|
-
return rewrapOverridableValue(existing, incoming);
|
|
2366
|
-
}
|
|
2367
|
-
return incoming;
|
|
2368
|
-
}
|
|
2369
|
-
function handleUnmetCondition(props) {
|
|
2370
|
-
const { failingDependencies, dependency, elementValues, defaultValue, elementId } = props;
|
|
2371
|
-
const termWithNewValue = failingDependencies.find(
|
|
2372
|
-
(term) => "newValue" in term && !!term.newValue
|
|
2373
|
-
);
|
|
2374
|
-
const newValue = termWithNewValue?.newValue ?? null;
|
|
2375
|
-
const currentValue = extractValue(dependency.split("."), elementValues, [], { unwrapOverridableLeaf: false }) ?? defaultValue;
|
|
2376
|
-
savePreviousValueToStorage({
|
|
2377
|
-
path: dependency,
|
|
2378
|
-
elementId,
|
|
2379
|
-
value: currentValue
|
|
2380
|
-
});
|
|
2381
|
-
return newValue;
|
|
2382
|
-
}
|
|
2383
|
-
function savePreviousValueToStorage({ path, elementId, value }) {
|
|
2384
|
-
const prefix = `elementor/${elementId}`;
|
|
2385
|
-
const savedValue = retrievePreviousValueFromStorage({ path, elementId });
|
|
2386
|
-
if (savedValue) {
|
|
2387
|
-
return;
|
|
2388
|
-
}
|
|
2389
|
-
const key = `${prefix}:${path}`;
|
|
2390
|
-
setSessionStorageItem2(key, value);
|
|
2391
|
-
}
|
|
2392
|
-
function retrievePreviousValueFromStorage({ path, elementId }) {
|
|
2393
|
-
const prefix = `elementor/${elementId}`;
|
|
2394
|
-
const key = `${prefix}:${path}`;
|
|
2395
|
-
return getSessionStorageItem2(key) ?? null;
|
|
2396
|
-
}
|
|
2397
|
-
function removePreviousValueFromStorage({ path, elementId }) {
|
|
2398
|
-
const prefix = `elementor/${elementId}`;
|
|
2399
|
-
const key = `${prefix}:${path}`;
|
|
2400
|
-
removeSessionStorageItem(key);
|
|
2401
|
-
}
|
|
2402
|
-
|
|
2403
2460
|
// src/controls-registry/create-top-level-object-type.ts
|
|
2404
2461
|
var createTopLevelObjectType = ({ schema }) => {
|
|
2405
2462
|
const schemaPropType = {
|
|
@@ -2543,8 +2600,9 @@ function populateChildControlProps(props) {
|
|
|
2543
2600
|
|
|
2544
2601
|
// src/components/settings-tab.tsx
|
|
2545
2602
|
var SettingsTab = () => {
|
|
2546
|
-
const { elementType, element } = useElement();
|
|
2603
|
+
const { elementType, element, settings } = useElement();
|
|
2547
2604
|
const settingsDefault = useDefaultPanelSettings();
|
|
2605
|
+
const currentSettings = settings;
|
|
2548
2606
|
const isDefaultExpanded = (sectionId) => settingsDefault.defaultSectionsExpanded.settings?.includes(sectionId);
|
|
2549
2607
|
return /* @__PURE__ */ React23.createElement(SessionStorageProvider, { prefix: element.id }, /* @__PURE__ */ React23.createElement(SectionsList, null, elementType.controls.map((control, index) => {
|
|
2550
2608
|
if (isControl(control)) {
|
|
@@ -2552,6 +2610,15 @@ var SettingsTab = () => {
|
|
|
2552
2610
|
}
|
|
2553
2611
|
const { type, value } = control;
|
|
2554
2612
|
if (type === "section") {
|
|
2613
|
+
const sectionItems = renderSectionItems({
|
|
2614
|
+
items: value.items,
|
|
2615
|
+
element,
|
|
2616
|
+
propsSchema: elementType.propsSchema,
|
|
2617
|
+
settings: currentSettings
|
|
2618
|
+
});
|
|
2619
|
+
if (!sectionItems.length) {
|
|
2620
|
+
return null;
|
|
2621
|
+
}
|
|
2555
2622
|
return /* @__PURE__ */ React23.createElement(
|
|
2556
2623
|
Section,
|
|
2557
2624
|
{
|
|
@@ -2559,12 +2626,7 @@ var SettingsTab = () => {
|
|
|
2559
2626
|
key: type + "." + index,
|
|
2560
2627
|
defaultExpanded: isDefaultExpanded(value.label)
|
|
2561
2628
|
},
|
|
2562
|
-
|
|
2563
|
-
if (isControl(item)) {
|
|
2564
|
-
return /* @__PURE__ */ React23.createElement(SettingsControl, { key: getKey(item, element), control: item });
|
|
2565
|
-
}
|
|
2566
|
-
return null;
|
|
2567
|
-
})
|
|
2629
|
+
sectionItems
|
|
2568
2630
|
);
|
|
2569
2631
|
}
|
|
2570
2632
|
return null;
|
|
@@ -2579,6 +2641,26 @@ function getKey(control, element) {
|
|
|
2579
2641
|
function isControl(control) {
|
|
2580
2642
|
return control.type === "control" || control.type === "element-control";
|
|
2581
2643
|
}
|
|
2644
|
+
function renderSectionItems({
|
|
2645
|
+
items: items3,
|
|
2646
|
+
element,
|
|
2647
|
+
propsSchema,
|
|
2648
|
+
settings
|
|
2649
|
+
}) {
|
|
2650
|
+
return items3?.flatMap((item) => {
|
|
2651
|
+
if (!isControl(item)) {
|
|
2652
|
+
return [];
|
|
2653
|
+
}
|
|
2654
|
+
if (item.type === "control" && isControlHiddenByDependencies(item, propsSchema, settings)) {
|
|
2655
|
+
return [];
|
|
2656
|
+
}
|
|
2657
|
+
return [/* @__PURE__ */ React23.createElement(SettingsControl, { key: getKey(item, element), control: item })];
|
|
2658
|
+
}) ?? [];
|
|
2659
|
+
}
|
|
2660
|
+
function isControlHiddenByDependencies(control, propsSchema, settings) {
|
|
2661
|
+
const { isHidden } = extractDependencyEffect(control.value.bind, propsSchema, settings);
|
|
2662
|
+
return isHidden;
|
|
2663
|
+
}
|
|
2582
2664
|
|
|
2583
2665
|
// src/components/style-tab.tsx
|
|
2584
2666
|
import * as React85 from "react";
|
|
@@ -3409,7 +3491,7 @@ var EffectsSection = () => {
|
|
|
3409
3491
|
import * as React55 from "react";
|
|
3410
3492
|
import { ControlFormLabel as ControlFormLabel2 } from "@elementor/editor-controls";
|
|
3411
3493
|
import { useParentElement } from "@elementor/editor-elements";
|
|
3412
|
-
import { isExperimentActive as
|
|
3494
|
+
import { isExperimentActive as isExperimentActive3 } from "@elementor/editor-v1-adapters";
|
|
3413
3495
|
import { __ as __33 } from "@wordpress/i18n";
|
|
3414
3496
|
|
|
3415
3497
|
// src/hooks/use-computed-style.ts
|
|
@@ -3732,7 +3814,7 @@ var getOptions2 = (parentStyleDirection) => {
|
|
|
3732
3814
|
import * as React44 from "react";
|
|
3733
3815
|
import { useMemo as useMemo9 } from "react";
|
|
3734
3816
|
import { ToggleControl as ToggleControl6 } from "@elementor/editor-controls";
|
|
3735
|
-
import { isExperimentActive } from "@elementor/editor-v1-adapters";
|
|
3817
|
+
import { isExperimentActive as isExperimentActive2 } from "@elementor/editor-v1-adapters";
|
|
3736
3818
|
import { __ as __22 } from "@wordpress/i18n";
|
|
3737
3819
|
var DISPLAY_LABEL = __22("Display", "elementor");
|
|
3738
3820
|
var displayFieldItems = [
|
|
@@ -3775,7 +3857,7 @@ var displayFieldItems = [
|
|
|
3775
3857
|
];
|
|
3776
3858
|
var DisplayField = () => {
|
|
3777
3859
|
const placeholder = useDisplayPlaceholderValue();
|
|
3778
|
-
const isGridActive =
|
|
3860
|
+
const isGridActive = isExperimentActive2("e_css_grid");
|
|
3779
3861
|
const items3 = useMemo9(
|
|
3780
3862
|
() => isGridActive ? displayFieldItems : displayFieldItems.filter((item) => item.value !== "grid"),
|
|
3781
3863
|
[isGridActive]
|
|
@@ -4428,7 +4510,7 @@ var LayoutSection = () => {
|
|
|
4428
4510
|
history: { propDisplayName: DISPLAY_LABEL2 }
|
|
4429
4511
|
});
|
|
4430
4512
|
const displayPlaceholder = useDisplayPlaceholderValue();
|
|
4431
|
-
const isGridExperimentActive =
|
|
4513
|
+
const isGridExperimentActive = isExperimentActive3("e_css_grid");
|
|
4432
4514
|
const isDisplayFlex = shouldDisplayFlexFields(display, displayPlaceholder);
|
|
4433
4515
|
const isDisplayGrid = "grid" === (display?.value ?? displayPlaceholder?.value);
|
|
4434
4516
|
const { element } = useElement();
|
|
@@ -5420,7 +5502,7 @@ var PanelTabContent = () => {
|
|
|
5420
5502
|
const { element } = useElement();
|
|
5421
5503
|
const editorDefaults = useDefaultPanelSettings();
|
|
5422
5504
|
const defaultComponentTab = editorDefaults.defaultTab;
|
|
5423
|
-
const isInteractionsActive =
|
|
5505
|
+
const isInteractionsActive = isExperimentActive4("e_interactions");
|
|
5424
5506
|
const isPromotedElement = !!getWidgetsCache2()?.[element.type]?.meta?.is_pro_promotion;
|
|
5425
5507
|
const [storedTab, setCurrentTab] = useStateByElement("tab", defaultComponentTab);
|
|
5426
5508
|
const currentTab = isPromotedElement && storedTab === "settings" ? "style" : storedTab;
|