@elementor/editor-editing-panel 3.33.0-220 → 3.33.0-222
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 +90 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +101 -35
- package/dist/index.mjs.map +1 -1
- package/package.json +19 -19
- package/src/components/css-classes/css-class-item.tsx +14 -3
- package/src/components/css-classes/css-class-menu.tsx +71 -7
- package/src/styles-inheritance/hooks/use-normalized-inheritance-chain-items.tsx +18 -2
package/dist/index.js
CHANGED
|
@@ -584,6 +584,7 @@ var StyledGroupItems = (0, import_ui2.styled)("ul")`
|
|
|
584
584
|
// src/components/css-classes/css-class-item.tsx
|
|
585
585
|
var React9 = __toESM(require("react"));
|
|
586
586
|
var import_react9 = require("react");
|
|
587
|
+
var import_editor_styles = require("@elementor/editor-styles");
|
|
587
588
|
var import_editor_styles_repository6 = require("@elementor/editor-styles-repository");
|
|
588
589
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
589
590
|
var import_icons = require("@elementor/icons");
|
|
@@ -836,10 +837,10 @@ function useClasses() {
|
|
|
836
837
|
|
|
837
838
|
// src/components/css-classes/css-class-menu.tsx
|
|
838
839
|
var STATES = [
|
|
839
|
-
{ key: "normal", value: null },
|
|
840
|
-
{ key: "hover", value: "hover" },
|
|
841
|
-
{ key: "focus", value: "focus" },
|
|
842
|
-
{ key: "active", value: "active" }
|
|
840
|
+
{ key: "normal", value: null, label: (0, import_i18n3.__)("normal", "elementor") },
|
|
841
|
+
{ key: "hover", value: "hover", label: (0, import_i18n3.__)("hover", "elementor") },
|
|
842
|
+
{ key: "focus", value: "focus", label: (0, import_i18n3.__)("focus", "elementor") },
|
|
843
|
+
{ key: "active", value: "active", label: (0, import_i18n3.__)("active", "elementor") }
|
|
843
844
|
];
|
|
844
845
|
function CssClassMenu({ popupState, anchorEl, fixed }) {
|
|
845
846
|
const { provider } = useCssClass();
|
|
@@ -868,10 +869,55 @@ function CssClassMenu({ popupState, anchorEl, fixed }) {
|
|
|
868
869
|
getMenuItemsByProvider({ provider, closeMenu: popupState.close, fixed }),
|
|
869
870
|
/* @__PURE__ */ React8.createElement(import_ui5.MenuSubheader, { sx: { typography: "caption", color: "text.secondary", pb: 0.5, pt: 1 } }, (0, import_i18n3.__)("States", "elementor")),
|
|
870
871
|
STATES.map((state) => {
|
|
871
|
-
return /* @__PURE__ */ React8.createElement(
|
|
872
|
-
|
|
872
|
+
return /* @__PURE__ */ React8.createElement(
|
|
873
|
+
StateMenuItem,
|
|
874
|
+
{
|
|
875
|
+
key: state.key,
|
|
876
|
+
state: state.value,
|
|
877
|
+
label: state.label,
|
|
878
|
+
closeMenu: popupState.close
|
|
879
|
+
}
|
|
880
|
+
);
|
|
881
|
+
}),
|
|
882
|
+
/* @__PURE__ */ React8.createElement(ClassStatesMenu, { closeMenu: popupState.close })
|
|
873
883
|
);
|
|
874
884
|
}
|
|
885
|
+
function ClassStatesMenu({ closeMenu }) {
|
|
886
|
+
const { elementStates, elementTitle } = useElementStates();
|
|
887
|
+
if (!elementStates.length) {
|
|
888
|
+
return null;
|
|
889
|
+
}
|
|
890
|
+
const customTitle = (0, import_i18n3.__)("%s States", "elementor").replace("%s", elementTitle);
|
|
891
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(import_ui5.Divider, null), /* @__PURE__ */ React8.createElement(import_ui5.MenuSubheader, { sx: { typography: "caption", color: "text.secondary", pb: 0.5, pt: 1 } }, customTitle), elementStates.map((state) => {
|
|
892
|
+
return /* @__PURE__ */ React8.createElement(
|
|
893
|
+
StateMenuItem,
|
|
894
|
+
{
|
|
895
|
+
key: state.key,
|
|
896
|
+
state: state.value,
|
|
897
|
+
label: state.label,
|
|
898
|
+
closeMenu
|
|
899
|
+
}
|
|
900
|
+
);
|
|
901
|
+
}));
|
|
902
|
+
}
|
|
903
|
+
var CLASS_STATES_MAP = {
|
|
904
|
+
selected: {
|
|
905
|
+
label: (0, import_i18n3.__)("selected", "elementor")
|
|
906
|
+
}
|
|
907
|
+
};
|
|
908
|
+
function useElementStates() {
|
|
909
|
+
const { elementType } = useElement();
|
|
910
|
+
const { styleStates = [] } = elementType;
|
|
911
|
+
const elementStates = styleStates.map(({ value, name }) => ({
|
|
912
|
+
key: value,
|
|
913
|
+
value,
|
|
914
|
+
label: CLASS_STATES_MAP[value]?.label ?? name
|
|
915
|
+
}));
|
|
916
|
+
return {
|
|
917
|
+
elementStates,
|
|
918
|
+
elementTitle: elementType.title
|
|
919
|
+
};
|
|
920
|
+
}
|
|
875
921
|
function useModifiedStates(styleId) {
|
|
876
922
|
const { meta } = useStyle();
|
|
877
923
|
const styleDef = import_editor_styles_repository5.stylesRepository.all().find((style) => style.id === styleId);
|
|
@@ -910,7 +956,7 @@ function getMenuItemsByProvider({
|
|
|
910
956
|
}
|
|
911
957
|
return actions;
|
|
912
958
|
}
|
|
913
|
-
function StateMenuItem({ state, closeMenu, ...props }) {
|
|
959
|
+
function StateMenuItem({ state, label, closeMenu, ...props }) {
|
|
914
960
|
const { id: styleId, provider } = useCssClass();
|
|
915
961
|
const { id: activeId, setId: setActiveId, setMetaState: setActiveMetaState, meta } = useStyle();
|
|
916
962
|
const { state: activeState } = meta;
|
|
@@ -948,7 +994,7 @@ function StateMenuItem({ state, closeMenu, ...props }) {
|
|
|
948
994
|
"aria-label": (0, import_i18n3.__)("Has style", "elementor"),
|
|
949
995
|
getColor: getTempStylesProviderThemeColor(provider ?? "")
|
|
950
996
|
}
|
|
951
|
-
),
|
|
997
|
+
), label)
|
|
952
998
|
)
|
|
953
999
|
);
|
|
954
1000
|
}
|
|
@@ -1002,6 +1048,7 @@ var CHIP_SIZE = "tiny";
|
|
|
1002
1048
|
function CssClassItem(props) {
|
|
1003
1049
|
const { chipProps, icon, color: colorProp, fixed, ...classProps } = props;
|
|
1004
1050
|
const { id, provider, label, isActive, onClickActive, renameLabel, setError } = classProps;
|
|
1051
|
+
const { elementStates } = useElementStates();
|
|
1005
1052
|
const { meta, setMetaState } = useStyle();
|
|
1006
1053
|
const popupState = (0, import_ui6.usePopupState)({ variant: "popover" });
|
|
1007
1054
|
const [chipRef, setChipRef] = (0, import_react9.useState)(null);
|
|
@@ -1027,6 +1074,12 @@ function CssClassItem(props) {
|
|
|
1027
1074
|
const providerActions = provider ? import_editor_styles_repository6.stylesRepository.getProviderByKey(provider)?.actions : null;
|
|
1028
1075
|
const allowRename = Boolean(providerActions?.update) && userCan(provider ?? "")?.update;
|
|
1029
1076
|
const isShowingState = isActive && meta.state;
|
|
1077
|
+
const stateLabel = (0, import_react9.useMemo)(() => {
|
|
1078
|
+
if ((0, import_editor_styles.isClassState)(meta.state)) {
|
|
1079
|
+
return elementStates.find((state) => state.value === meta.state)?.label;
|
|
1080
|
+
}
|
|
1081
|
+
return meta.state;
|
|
1082
|
+
}, [meta.state, elementStates]);
|
|
1030
1083
|
(0, import_react9.useEffect)(() => {
|
|
1031
1084
|
if (convertedFromLocalId && id === convertedFromLocalId) {
|
|
1032
1085
|
clearConvertedFromLocalId();
|
|
@@ -1080,7 +1133,7 @@ function CssClassItem(props) {
|
|
|
1080
1133
|
{
|
|
1081
1134
|
icon: isShowingState ? void 0 : /* @__PURE__ */ React9.createElement(import_icons.DotsVerticalIcon, { fontSize: "tiny" }),
|
|
1082
1135
|
size: CHIP_SIZE,
|
|
1083
|
-
label: isShowingState ? /* @__PURE__ */ React9.createElement(import_ui6.Stack, { direction: "row", gap: 0.5, alignItems: "center" }, /* @__PURE__ */ React9.createElement(import_ui6.Typography, { variant: "inherit" },
|
|
1136
|
+
label: isShowingState ? /* @__PURE__ */ React9.createElement(import_ui6.Stack, { direction: "row", gap: 0.5, alignItems: "center" }, /* @__PURE__ */ React9.createElement(import_ui6.Typography, { variant: "inherit" }, stateLabel), /* @__PURE__ */ React9.createElement(import_icons.DotsVerticalIcon, { fontSize: "tiny" })) : void 0,
|
|
1084
1137
|
variant: "filled",
|
|
1085
1138
|
shape: "rounded",
|
|
1086
1139
|
color,
|
|
@@ -1295,13 +1348,13 @@ function useHandleSelect() {
|
|
|
1295
1348
|
// src/components/custom-css-indicator.tsx
|
|
1296
1349
|
var React11 = __toESM(require("react"));
|
|
1297
1350
|
var import_editor_responsive = require("@elementor/editor-responsive");
|
|
1298
|
-
var
|
|
1351
|
+
var import_editor_styles4 = require("@elementor/editor-styles");
|
|
1299
1352
|
|
|
1300
1353
|
// src/hooks/use-custom-css.ts
|
|
1301
1354
|
var import_react13 = require("react");
|
|
1302
1355
|
var import_editor_elements6 = require("@elementor/editor-elements");
|
|
1303
1356
|
var import_editor_props3 = require("@elementor/editor-props");
|
|
1304
|
-
var
|
|
1357
|
+
var import_editor_styles3 = require("@elementor/editor-styles");
|
|
1305
1358
|
var import_editor_styles_repository10 = require("@elementor/editor-styles-repository");
|
|
1306
1359
|
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
1307
1360
|
var import_utils2 = require("@elementor/utils");
|
|
@@ -1309,7 +1362,7 @@ var import_utils2 = require("@elementor/utils");
|
|
|
1309
1362
|
// src/hooks/use-styles-fields.ts
|
|
1310
1363
|
var import_react12 = require("react");
|
|
1311
1364
|
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
1312
|
-
var
|
|
1365
|
+
var import_editor_styles2 = require("@elementor/editor-styles");
|
|
1313
1366
|
var import_editor_styles_repository8 = require("@elementor/editor-styles-repository");
|
|
1314
1367
|
var import_editor_styles_repository9 = require("@elementor/editor-styles-repository");
|
|
1315
1368
|
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
@@ -1350,7 +1403,7 @@ function getProps({ styleId, elementId, provider, meta, propNames }) {
|
|
|
1350
1403
|
if (!style) {
|
|
1351
1404
|
throw new StyleNotFoundUnderProviderError({ context: { styleId, providerKey: provider.getKey() } });
|
|
1352
1405
|
}
|
|
1353
|
-
const variant = (0,
|
|
1406
|
+
const variant = (0, import_editor_styles2.getVariantByMeta)(style, meta);
|
|
1354
1407
|
return Object.fromEntries(
|
|
1355
1408
|
propNames.map((key) => [key, variant?.props[key] ?? null])
|
|
1356
1409
|
);
|
|
@@ -1419,7 +1472,7 @@ function getCurrentProps(style, meta) {
|
|
|
1419
1472
|
if (!style) {
|
|
1420
1473
|
return {};
|
|
1421
1474
|
}
|
|
1422
|
-
const variant = (0,
|
|
1475
|
+
const variant = (0, import_editor_styles2.getVariantByMeta)(style, meta);
|
|
1423
1476
|
const props = variant?.props ?? {};
|
|
1424
1477
|
return structuredClone(props);
|
|
1425
1478
|
}
|
|
@@ -1478,7 +1531,7 @@ var useCustomCss = () => {
|
|
|
1478
1531
|
const currentStyleId = styleId ? styleId : null;
|
|
1479
1532
|
const currentProvider = styleId ? provider : null;
|
|
1480
1533
|
useStylesRerender();
|
|
1481
|
-
const variant = style ? (0,
|
|
1534
|
+
const variant = style ? (0, import_editor_styles3.getVariantByMeta)(style, meta) : null;
|
|
1482
1535
|
const setCustomCss = (raw, { history: { propDisplayName } }) => {
|
|
1483
1536
|
const newValue = { raw: (0, import_utils2.encodeString)(sanitize(raw)) };
|
|
1484
1537
|
undoableUpdateStyle({
|
|
@@ -1564,7 +1617,7 @@ function getCurrentCustomCss(style, meta) {
|
|
|
1564
1617
|
if (!style) {
|
|
1565
1618
|
return null;
|
|
1566
1619
|
}
|
|
1567
|
-
const variant = (0,
|
|
1620
|
+
const variant = (0, import_editor_styles3.getVariantByMeta)(style, meta);
|
|
1568
1621
|
return variant?.custom_css ?? null;
|
|
1569
1622
|
}
|
|
1570
1623
|
function sanitize(raw) {
|
|
@@ -1609,7 +1662,7 @@ var hasInheritedCustomCss = (style, meta) => {
|
|
|
1609
1662
|
return void 0;
|
|
1610
1663
|
}
|
|
1611
1664
|
const hasHere = Boolean(
|
|
1612
|
-
(0,
|
|
1665
|
+
(0, import_editor_styles4.getVariantByMeta)(style, {
|
|
1613
1666
|
breakpoint: node.id,
|
|
1614
1667
|
state
|
|
1615
1668
|
})?.custom_css?.raw?.trim()
|
|
@@ -1757,7 +1810,7 @@ var import_react17 = require("react");
|
|
|
1757
1810
|
var import_editor_elements7 = require("@elementor/editor-elements");
|
|
1758
1811
|
var import_editor_props6 = require("@elementor/editor-props");
|
|
1759
1812
|
var import_editor_responsive2 = require("@elementor/editor-responsive");
|
|
1760
|
-
var
|
|
1813
|
+
var import_editor_styles5 = require("@elementor/editor-styles");
|
|
1761
1814
|
var import_editor_styles_repository11 = require("@elementor/editor-styles-repository");
|
|
1762
1815
|
|
|
1763
1816
|
// src/styles-inheritance/create-styles-inheritance.ts
|
|
@@ -2006,7 +2059,7 @@ function useStylesInheritanceChain(path) {
|
|
|
2006
2059
|
if (!context) {
|
|
2007
2060
|
throw new Error("useStylesInheritanceChain must be used within a StyleInheritanceProvider");
|
|
2008
2061
|
}
|
|
2009
|
-
const schema = (0,
|
|
2062
|
+
const schema = (0, import_editor_styles5.getStylesSchema)();
|
|
2010
2063
|
const topLevelPropType = schema?.[path[0]];
|
|
2011
2064
|
const snapshot = useStylesInheritanceSnapshot();
|
|
2012
2065
|
if (!snapshot) {
|
|
@@ -2088,7 +2141,7 @@ var import_i18n12 = require("@wordpress/i18n");
|
|
|
2088
2141
|
// src/controls-registry/styles-field.tsx
|
|
2089
2142
|
var React23 = __toESM(require("react"));
|
|
2090
2143
|
var import_editor_controls3 = require("@elementor/editor-controls");
|
|
2091
|
-
var
|
|
2144
|
+
var import_editor_styles7 = require("@elementor/editor-styles");
|
|
2092
2145
|
|
|
2093
2146
|
// src/hooks/use-styles-field.ts
|
|
2094
2147
|
function useStylesField(propName, meta) {
|
|
@@ -2125,6 +2178,7 @@ function useDirection() {
|
|
|
2125
2178
|
|
|
2126
2179
|
// src/styles-inheritance/hooks/use-normalized-inheritance-chain-items.tsx
|
|
2127
2180
|
var import_react19 = require("react");
|
|
2181
|
+
var import_editor_styles6 = require("@elementor/editor-styles");
|
|
2128
2182
|
var import_editor_styles_repository12 = require("@elementor/editor-styles-repository");
|
|
2129
2183
|
var import_i18n8 = require("@wordpress/i18n");
|
|
2130
2184
|
var MAXIMUM_ITEMS = 2;
|
|
@@ -2152,7 +2206,7 @@ var normalizeInheritanceItem = async (item, index, bind, resolve) => {
|
|
|
2152
2206
|
},
|
|
2153
2207
|
style: { label, id }
|
|
2154
2208
|
} = item;
|
|
2155
|
-
const displayLabel =
|
|
2209
|
+
const displayLabel = getLabel({ label, state });
|
|
2156
2210
|
return {
|
|
2157
2211
|
id: id ? id + (state ?? "") : index,
|
|
2158
2212
|
provider: item.provider || "",
|
|
@@ -2161,6 +2215,15 @@ var normalizeInheritanceItem = async (item, index, bind, resolve) => {
|
|
|
2161
2215
|
value: await getTransformedValue(item, bind, resolve)
|
|
2162
2216
|
};
|
|
2163
2217
|
};
|
|
2218
|
+
function getLabel({ label, state }) {
|
|
2219
|
+
if ((0, import_editor_styles6.isClassState)(state)) {
|
|
2220
|
+
return `${label}.${state}`;
|
|
2221
|
+
}
|
|
2222
|
+
if ((0, import_editor_styles6.isPseudoState)(state)) {
|
|
2223
|
+
return `${label}:${state}`;
|
|
2224
|
+
}
|
|
2225
|
+
return label;
|
|
2226
|
+
}
|
|
2164
2227
|
var getTransformedValue = async (item, bind, resolve) => {
|
|
2165
2228
|
try {
|
|
2166
2229
|
const result = await resolve({
|
|
@@ -2465,7 +2528,7 @@ var Indicator = ({ inheritanceChain, path, propType, isDisabled }) => {
|
|
|
2465
2528
|
return null;
|
|
2466
2529
|
}
|
|
2467
2530
|
const isFinalValue = currentItem === actualStyle;
|
|
2468
|
-
const label =
|
|
2531
|
+
const label = getLabel2({ isFinalValue, hasValue });
|
|
2469
2532
|
const styleIndicatorProps = {
|
|
2470
2533
|
getColor: isFinalValue && currentStyleProvider ? getStylesProviderThemeColor(currentStyleProvider.getKey()) : void 0,
|
|
2471
2534
|
isOverridden: hasValue && !isFinalValue ? true : void 0
|
|
@@ -2482,7 +2545,7 @@ var Indicator = ({ inheritanceChain, path, propType, isDisabled }) => {
|
|
|
2482
2545
|
/* @__PURE__ */ React22.createElement(StyleIndicator, { ...styleIndicatorProps })
|
|
2483
2546
|
);
|
|
2484
2547
|
};
|
|
2485
|
-
var
|
|
2548
|
+
var getLabel2 = ({ isFinalValue, hasValue }) => {
|
|
2486
2549
|
if (isFinalValue) {
|
|
2487
2550
|
return (0, import_i18n11.__)("This is the final value", "elementor");
|
|
2488
2551
|
}
|
|
@@ -2524,7 +2587,7 @@ var createTopLevelObjectType = ({ schema }) => {
|
|
|
2524
2587
|
|
|
2525
2588
|
// src/controls-registry/styles-field.tsx
|
|
2526
2589
|
var StylesField = ({ bind, propDisplayName, children }) => {
|
|
2527
|
-
const stylesSchema = (0,
|
|
2590
|
+
const stylesSchema = (0, import_editor_styles7.getStylesSchema)();
|
|
2528
2591
|
const stylesInheritanceChain = useStylesInheritanceChain([bind]);
|
|
2529
2592
|
const { value, canEdit, ...fields } = useStylesField(bind, { history: { propDisplayName } });
|
|
2530
2593
|
const propType = createTopLevelObjectType({ schema: stylesSchema });
|
|
@@ -2843,14 +2906,14 @@ var import_i18n20 = require("@wordpress/i18n");
|
|
|
2843
2906
|
// src/utils/get-recently-used-styles.ts
|
|
2844
2907
|
var import_editor_canvas3 = require("@elementor/editor-canvas");
|
|
2845
2908
|
var import_editor_elements9 = require("@elementor/editor-elements");
|
|
2846
|
-
var
|
|
2909
|
+
var import_editor_styles8 = require("@elementor/editor-styles");
|
|
2847
2910
|
var getRecentlyUsedList = async (elementId) => {
|
|
2848
2911
|
if (!elementId) {
|
|
2849
2912
|
return [];
|
|
2850
2913
|
}
|
|
2851
2914
|
const resolver = (0, import_editor_canvas3.createPropsResolver)({
|
|
2852
2915
|
transformers: import_editor_canvas3.styleTransformersRegistry,
|
|
2853
|
-
schema: (0,
|
|
2916
|
+
schema: (0, import_editor_styles8.getStylesSchema)()
|
|
2854
2917
|
});
|
|
2855
2918
|
const styles = (0, import_editor_elements9.getElementStyles)(elementId) ?? {};
|
|
2856
2919
|
const styleKeys = Object.keys(styles ?? {});
|
|
@@ -2859,7 +2922,7 @@ var getRecentlyUsedList = async (elementId) => {
|
|
|
2859
2922
|
variants.flat().map(async (variant) => {
|
|
2860
2923
|
const result = await resolver({
|
|
2861
2924
|
props: variant.props ?? {},
|
|
2862
|
-
schema: (0,
|
|
2925
|
+
schema: (0, import_editor_styles8.getStylesSchema)()
|
|
2863
2926
|
});
|
|
2864
2927
|
return Object.entries(result).filter(([, value]) => value !== null).map(([key]) => key);
|
|
2865
2928
|
})
|