@elementor/editor-global-classes 4.1.0-821 → 4.1.0-823
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 +125 -61
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +125 -61
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -20
- package/src/components/class-manager/class-manager-panel.tsx +3 -0
- package/src/components/class-manager/global-classes-list.tsx +62 -14
- package/src/components/class-manager/sortable.tsx +9 -3
package/dist/index.mjs
CHANGED
|
@@ -1289,6 +1289,7 @@ import * as React17 from "react";
|
|
|
1289
1289
|
import { useEffect as useEffect2, useMemo as useMemo3, useState as useState5 } from "react";
|
|
1290
1290
|
import { __useDispatch as useDispatch } from "@elementor/store";
|
|
1291
1291
|
import { List, Stack as Stack8, styled as styled6, Typography as Typography8 } from "@elementor/ui";
|
|
1292
|
+
import { defaultRangeExtractor, useVirtualizer } from "@tanstack/react-virtual";
|
|
1292
1293
|
import { __ as __13 } from "@wordpress/i18n";
|
|
1293
1294
|
|
|
1294
1295
|
// src/hooks/use-ordered-classes.ts
|
|
@@ -1641,9 +1642,17 @@ import {
|
|
|
1641
1642
|
UnstableSortableItem,
|
|
1642
1643
|
UnstableSortableProvider
|
|
1643
1644
|
} from "@elementor/ui";
|
|
1644
|
-
var SortableProvider = (props) => /* @__PURE__ */ React14.createElement(
|
|
1645
|
+
var SortableProvider = (props) => /* @__PURE__ */ React14.createElement(
|
|
1646
|
+
UnstableSortableProvider,
|
|
1647
|
+
{
|
|
1648
|
+
restrictAxis: true,
|
|
1649
|
+
variant: "static",
|
|
1650
|
+
dragPlaceholderStyle: { visibility: "hidden" },
|
|
1651
|
+
...props
|
|
1652
|
+
}
|
|
1653
|
+
);
|
|
1645
1654
|
var SortableTrigger = (props) => /* @__PURE__ */ React14.createElement(StyledSortableTrigger, { ...props, role: "button", className: "class-item-sortable-trigger", "aria-label": "sort" }, /* @__PURE__ */ React14.createElement(GripVerticalIcon, { fontSize: "tiny" }));
|
|
1646
|
-
var SortableItem = ({ children, id: id2, ...props }) => {
|
|
1655
|
+
var SortableItem = ({ children, id: id2, style, ...props }) => {
|
|
1647
1656
|
return /* @__PURE__ */ React14.createElement(
|
|
1648
1657
|
UnstableSortableItem,
|
|
1649
1658
|
{
|
|
@@ -1664,7 +1673,7 @@ var SortableItem = ({ children, id: id2, ...props }) => {
|
|
|
1664
1673
|
Box7,
|
|
1665
1674
|
{
|
|
1666
1675
|
...itemProps,
|
|
1667
|
-
style: itemStyle,
|
|
1676
|
+
style: { ...itemStyle, ...!isDragOverlay ? style : null },
|
|
1668
1677
|
component: "li",
|
|
1669
1678
|
role: "listitem",
|
|
1670
1679
|
sx: {
|
|
@@ -1987,7 +1996,14 @@ var NotFoundLayout = ({ onClear, searchValue, mainText, sceneryText, icon }) =>
|
|
|
1987
1996
|
);
|
|
1988
1997
|
|
|
1989
1998
|
// src/components/class-manager/global-classes-list.tsx
|
|
1990
|
-
var
|
|
1999
|
+
var ROW_HEIGHT = 40;
|
|
2000
|
+
var OVERSCAN = 6;
|
|
2001
|
+
var GlobalClassesList = ({
|
|
2002
|
+
disabled,
|
|
2003
|
+
scrollElement,
|
|
2004
|
+
onStopSyncRequest,
|
|
2005
|
+
onStartSyncRequest
|
|
2006
|
+
}) => {
|
|
1991
2007
|
const {
|
|
1992
2008
|
search: { debouncedValue: searchValue }
|
|
1993
2009
|
} = useSearchAndFilters();
|
|
@@ -1998,6 +2014,26 @@ var GlobalClassesList = ({ disabled, onStopSyncRequest, onStartSyncRequest }) =>
|
|
|
1998
2014
|
const draggedItemLabel = cssClasses.find((cssClass) => cssClass.id === draggedItemId)?.label ?? "";
|
|
1999
2015
|
const [classesOrder, reorderClasses] = useReorder(draggedItemId, setDraggedItemId, draggedItemLabel ?? "");
|
|
2000
2016
|
const filteredCssClasses = useFilteredCssClasses();
|
|
2017
|
+
const virtualizer = useVirtualizer({
|
|
2018
|
+
count: filteredCssClasses.length,
|
|
2019
|
+
getScrollElement: () => scrollElement ?? null,
|
|
2020
|
+
estimateSize: () => ROW_HEIGHT,
|
|
2021
|
+
overscan: OVERSCAN,
|
|
2022
|
+
getItemKey: (index) => filteredCssClasses[index].id,
|
|
2023
|
+
// Keep the actively dragged row mounted even when scrolled out of view.
|
|
2024
|
+
// SortableItem unregisters its render on unmount, which would make the
|
|
2025
|
+
// DragOverlay clone disappear mid-drag.
|
|
2026
|
+
rangeExtractor: (range) => {
|
|
2027
|
+
const indices = new Set(defaultRangeExtractor(range));
|
|
2028
|
+
if (draggedItemId) {
|
|
2029
|
+
const draggedItemIndex = filteredCssClasses.findIndex((cssClass) => cssClass.id === draggedItemId);
|
|
2030
|
+
if (draggedItemIndex >= 0) {
|
|
2031
|
+
indices.add(draggedItemIndex);
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
return [...indices].sort((a, b) => a - b);
|
|
2035
|
+
}
|
|
2036
|
+
});
|
|
2001
2037
|
useEffect2(() => {
|
|
2002
2038
|
const handler2 = (event) => {
|
|
2003
2039
|
if (event.key === "z" && (event.ctrlKey || event.metaKey)) {
|
|
@@ -2024,67 +2060,92 @@ var GlobalClassesList = ({ disabled, onStopSyncRequest, onStartSyncRequest }) =>
|
|
|
2024
2060
|
}
|
|
2025
2061
|
const isFiltersApplied = filters?.length || searchValue;
|
|
2026
2062
|
const allowSorting = filteredCssClasses.length > 1 && !isFiltersApplied;
|
|
2027
|
-
return /* @__PURE__ */ React17.createElement(DeleteConfirmationProvider, null, /* @__PURE__ */ React17.createElement(
|
|
2028
|
-
|
|
2063
|
+
return /* @__PURE__ */ React17.createElement(DeleteConfirmationProvider, null, /* @__PURE__ */ React17.createElement(
|
|
2064
|
+
List,
|
|
2029
2065
|
{
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
if (isDragged && !draggedItemId) {
|
|
2036
|
-
setDraggedItemId(cssClass.id);
|
|
2066
|
+
sx: {
|
|
2067
|
+
position: "relative",
|
|
2068
|
+
display: "block",
|
|
2069
|
+
height: virtualizer.getTotalSize(),
|
|
2070
|
+
padding: 0
|
|
2037
2071
|
}
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
sortableTriggerProps: {
|
|
2063
|
-
...triggerProps,
|
|
2064
|
-
style: triggerStyle
|
|
2072
|
+
},
|
|
2073
|
+
/* @__PURE__ */ React17.createElement(
|
|
2074
|
+
SortableProvider,
|
|
2075
|
+
{
|
|
2076
|
+
value: classesOrder,
|
|
2077
|
+
onChange: reorderClasses,
|
|
2078
|
+
onDragStart: (event) => setDraggedItemId(event.active.id),
|
|
2079
|
+
onDragEnd: () => setDraggedItemId(null),
|
|
2080
|
+
onDragCancel: () => setDraggedItemId(null),
|
|
2081
|
+
disableDragOverlay: !allowSorting
|
|
2082
|
+
},
|
|
2083
|
+
virtualizer.getVirtualItems().map((virtualRow) => {
|
|
2084
|
+
const cssClass = filteredCssClasses[virtualRow.index];
|
|
2085
|
+
return /* @__PURE__ */ React17.createElement(
|
|
2086
|
+
SortableItem,
|
|
2087
|
+
{
|
|
2088
|
+
key: virtualRow.key,
|
|
2089
|
+
id: cssClass.id,
|
|
2090
|
+
style: {
|
|
2091
|
+
position: "absolute",
|
|
2092
|
+
top: virtualRow.start,
|
|
2093
|
+
left: 0,
|
|
2094
|
+
width: "100%"
|
|
2095
|
+
}
|
|
2065
2096
|
},
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2097
|
+
({ isDragged, isDragPlaceholder, triggerProps, triggerStyle }) => /* @__PURE__ */ React17.createElement(
|
|
2098
|
+
ClassItem,
|
|
2099
|
+
{
|
|
2100
|
+
id: cssClass.id,
|
|
2101
|
+
label: cssClass.label,
|
|
2102
|
+
renameClass: (newLabel) => {
|
|
2103
|
+
trackGlobalClasses({
|
|
2104
|
+
event: "classRenamed",
|
|
2105
|
+
classId: cssClass.id,
|
|
2106
|
+
oldValue: cssClass.label,
|
|
2107
|
+
newValue: newLabel,
|
|
2108
|
+
source: "class-manager"
|
|
2109
|
+
});
|
|
2110
|
+
dispatch5(
|
|
2111
|
+
slice.actions.update({
|
|
2112
|
+
style: {
|
|
2113
|
+
id: cssClass.id,
|
|
2114
|
+
label: newLabel
|
|
2115
|
+
}
|
|
2116
|
+
})
|
|
2117
|
+
);
|
|
2118
|
+
},
|
|
2119
|
+
selected: isDragged,
|
|
2120
|
+
disabled: disabled || isDragPlaceholder,
|
|
2121
|
+
sortableTriggerProps: {
|
|
2122
|
+
...triggerProps,
|
|
2123
|
+
style: triggerStyle
|
|
2124
|
+
},
|
|
2125
|
+
showSortIndicator: allowSorting,
|
|
2126
|
+
syncToV3: cssClass.sync_to_v3,
|
|
2127
|
+
onToggleSync: (id2, newValue) => {
|
|
2128
|
+
if (!newValue && onStopSyncRequest) {
|
|
2129
|
+
onStopSyncRequest(id2);
|
|
2130
|
+
} else if (newValue && onStartSyncRequest) {
|
|
2131
|
+
onStartSyncRequest(id2);
|
|
2132
|
+
} else {
|
|
2133
|
+
dispatch5(
|
|
2134
|
+
slice.actions.update({
|
|
2135
|
+
style: {
|
|
2136
|
+
id: id2,
|
|
2137
|
+
sync_to_v3: newValue
|
|
2138
|
+
}
|
|
2139
|
+
})
|
|
2140
|
+
);
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2082
2143
|
}
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
)
|
|
2086
|
-
|
|
2087
|
-
))
|
|
2144
|
+
)
|
|
2145
|
+
);
|
|
2146
|
+
})
|
|
2147
|
+
)
|
|
2148
|
+
));
|
|
2088
2149
|
};
|
|
2089
2150
|
var EmptyState = () => /* @__PURE__ */ React17.createElement(Stack8, { alignItems: "center", gap: 1.5, pt: 10, px: 0.5, maxWidth: "260px", margin: "auto" }, /* @__PURE__ */ React17.createElement(FlippedColorSwatchIcon, { fontSize: "large" }), /* @__PURE__ */ React17.createElement(StyledHeader, { variant: "subtitle2", component: "h2", color: "text.secondary" }, __13("There are no global classes yet.", "elementor")), /* @__PURE__ */ React17.createElement(Typography8, { align: "center", variant: "caption", color: "text.secondary" }, __13(
|
|
2090
2151
|
"CSS classes created in the editor panel will appear here. Once they are available, you can arrange their hierarchy, rename them, or delete them as needed.",
|
|
@@ -2246,6 +2307,7 @@ function ClassManagerPanel() {
|
|
|
2246
2307
|
const [stopSyncConfirmation, setStopSyncConfirmation] = useState7(null);
|
|
2247
2308
|
const [startSyncConfirmation, setStartSyncConfirmation] = useState7(null);
|
|
2248
2309
|
const [isStopSyncSuppressed] = useSuppressedMessage2(STOP_SYNC_MESSAGE_KEY);
|
|
2310
|
+
const [scrollElement, setScrollElement] = useState7(null);
|
|
2249
2311
|
const { mutateAsync: publish, isPending: isPublishing } = usePublish();
|
|
2250
2312
|
const resetAndClosePanel = () => {
|
|
2251
2313
|
dispatch4(slice.actions.resetToInitialState({ context: "frontend" }));
|
|
@@ -2313,6 +2375,7 @@ function ClassManagerPanel() {
|
|
|
2313
2375
|
/* @__PURE__ */ React19.createElement(
|
|
2314
2376
|
Box11,
|
|
2315
2377
|
{
|
|
2378
|
+
ref: setScrollElement,
|
|
2316
2379
|
px: 2,
|
|
2317
2380
|
sx: {
|
|
2318
2381
|
flexGrow: 1,
|
|
@@ -2323,6 +2386,7 @@ function ClassManagerPanel() {
|
|
|
2323
2386
|
GlobalClassesList,
|
|
2324
2387
|
{
|
|
2325
2388
|
disabled: isPublishing,
|
|
2389
|
+
scrollElement,
|
|
2326
2390
|
onStopSyncRequest: handleStopSyncRequest,
|
|
2327
2391
|
onStartSyncRequest: (classId) => setStartSyncConfirmation(classId)
|
|
2328
2392
|
}
|