@elementor/editor-global-classes 4.1.0-822 → 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.js
CHANGED
|
@@ -1280,6 +1280,7 @@ var React17 = __toESM(require("react"));
|
|
|
1280
1280
|
var import_react8 = require("react");
|
|
1281
1281
|
var import_store18 = require("@elementor/store");
|
|
1282
1282
|
var import_ui14 = require("@elementor/ui");
|
|
1283
|
+
var import_react_virtual = require("@tanstack/react-virtual");
|
|
1283
1284
|
var import_i18n13 = require("@wordpress/i18n");
|
|
1284
1285
|
|
|
1285
1286
|
// src/hooks/use-ordered-classes.ts
|
|
@@ -1592,9 +1593,17 @@ var useDeleteConfirmation = () => {
|
|
|
1592
1593
|
var React14 = __toESM(require("react"));
|
|
1593
1594
|
var import_icons8 = require("@elementor/icons");
|
|
1594
1595
|
var import_ui11 = require("@elementor/ui");
|
|
1595
|
-
var SortableProvider = (props) => /* @__PURE__ */ React14.createElement(
|
|
1596
|
+
var SortableProvider = (props) => /* @__PURE__ */ React14.createElement(
|
|
1597
|
+
import_ui11.UnstableSortableProvider,
|
|
1598
|
+
{
|
|
1599
|
+
restrictAxis: true,
|
|
1600
|
+
variant: "static",
|
|
1601
|
+
dragPlaceholderStyle: { visibility: "hidden" },
|
|
1602
|
+
...props
|
|
1603
|
+
}
|
|
1604
|
+
);
|
|
1596
1605
|
var SortableTrigger = (props) => /* @__PURE__ */ React14.createElement(StyledSortableTrigger, { ...props, role: "button", className: "class-item-sortable-trigger", "aria-label": "sort" }, /* @__PURE__ */ React14.createElement(import_icons8.GripVerticalIcon, { fontSize: "tiny" }));
|
|
1597
|
-
var SortableItem = ({ children, id: id2, ...props }) => {
|
|
1606
|
+
var SortableItem = ({ children, id: id2, style, ...props }) => {
|
|
1598
1607
|
return /* @__PURE__ */ React14.createElement(
|
|
1599
1608
|
import_ui11.UnstableSortableItem,
|
|
1600
1609
|
{
|
|
@@ -1615,7 +1624,7 @@ var SortableItem = ({ children, id: id2, ...props }) => {
|
|
|
1615
1624
|
import_ui11.Box,
|
|
1616
1625
|
{
|
|
1617
1626
|
...itemProps,
|
|
1618
|
-
style: itemStyle,
|
|
1627
|
+
style: { ...itemStyle, ...!isDragOverlay ? style : null },
|
|
1619
1628
|
component: "li",
|
|
1620
1629
|
role: "listitem",
|
|
1621
1630
|
sx: {
|
|
@@ -1938,7 +1947,14 @@ var NotFoundLayout = ({ onClear, searchValue, mainText, sceneryText, icon }) =>
|
|
|
1938
1947
|
);
|
|
1939
1948
|
|
|
1940
1949
|
// src/components/class-manager/global-classes-list.tsx
|
|
1941
|
-
var
|
|
1950
|
+
var ROW_HEIGHT = 40;
|
|
1951
|
+
var OVERSCAN = 6;
|
|
1952
|
+
var GlobalClassesList = ({
|
|
1953
|
+
disabled,
|
|
1954
|
+
scrollElement,
|
|
1955
|
+
onStopSyncRequest,
|
|
1956
|
+
onStartSyncRequest
|
|
1957
|
+
}) => {
|
|
1942
1958
|
const {
|
|
1943
1959
|
search: { debouncedValue: searchValue }
|
|
1944
1960
|
} = useSearchAndFilters();
|
|
@@ -1949,6 +1965,26 @@ var GlobalClassesList = ({ disabled, onStopSyncRequest, onStartSyncRequest }) =>
|
|
|
1949
1965
|
const draggedItemLabel = cssClasses.find((cssClass) => cssClass.id === draggedItemId)?.label ?? "";
|
|
1950
1966
|
const [classesOrder, reorderClasses] = useReorder(draggedItemId, setDraggedItemId, draggedItemLabel ?? "");
|
|
1951
1967
|
const filteredCssClasses = useFilteredCssClasses();
|
|
1968
|
+
const virtualizer = (0, import_react_virtual.useVirtualizer)({
|
|
1969
|
+
count: filteredCssClasses.length,
|
|
1970
|
+
getScrollElement: () => scrollElement ?? null,
|
|
1971
|
+
estimateSize: () => ROW_HEIGHT,
|
|
1972
|
+
overscan: OVERSCAN,
|
|
1973
|
+
getItemKey: (index) => filteredCssClasses[index].id,
|
|
1974
|
+
// Keep the actively dragged row mounted even when scrolled out of view.
|
|
1975
|
+
// SortableItem unregisters its render on unmount, which would make the
|
|
1976
|
+
// DragOverlay clone disappear mid-drag.
|
|
1977
|
+
rangeExtractor: (range) => {
|
|
1978
|
+
const indices = new Set((0, import_react_virtual.defaultRangeExtractor)(range));
|
|
1979
|
+
if (draggedItemId) {
|
|
1980
|
+
const draggedItemIndex = filteredCssClasses.findIndex((cssClass) => cssClass.id === draggedItemId);
|
|
1981
|
+
if (draggedItemIndex >= 0) {
|
|
1982
|
+
indices.add(draggedItemIndex);
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
return [...indices].sort((a, b) => a - b);
|
|
1986
|
+
}
|
|
1987
|
+
});
|
|
1952
1988
|
(0, import_react8.useEffect)(() => {
|
|
1953
1989
|
const handler2 = (event) => {
|
|
1954
1990
|
if (event.key === "z" && (event.ctrlKey || event.metaKey)) {
|
|
@@ -1975,67 +2011,92 @@ var GlobalClassesList = ({ disabled, onStopSyncRequest, onStartSyncRequest }) =>
|
|
|
1975
2011
|
}
|
|
1976
2012
|
const isFiltersApplied = filters?.length || searchValue;
|
|
1977
2013
|
const allowSorting = filteredCssClasses.length > 1 && !isFiltersApplied;
|
|
1978
|
-
return /* @__PURE__ */ React17.createElement(DeleteConfirmationProvider, null, /* @__PURE__ */ React17.createElement(
|
|
1979
|
-
|
|
2014
|
+
return /* @__PURE__ */ React17.createElement(DeleteConfirmationProvider, null, /* @__PURE__ */ React17.createElement(
|
|
2015
|
+
import_ui14.List,
|
|
1980
2016
|
{
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
if (isDragged && !draggedItemId) {
|
|
1987
|
-
setDraggedItemId(cssClass.id);
|
|
2017
|
+
sx: {
|
|
2018
|
+
position: "relative",
|
|
2019
|
+
display: "block",
|
|
2020
|
+
height: virtualizer.getTotalSize(),
|
|
2021
|
+
padding: 0
|
|
1988
2022
|
}
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
sortableTriggerProps: {
|
|
2014
|
-
...triggerProps,
|
|
2015
|
-
style: triggerStyle
|
|
2023
|
+
},
|
|
2024
|
+
/* @__PURE__ */ React17.createElement(
|
|
2025
|
+
SortableProvider,
|
|
2026
|
+
{
|
|
2027
|
+
value: classesOrder,
|
|
2028
|
+
onChange: reorderClasses,
|
|
2029
|
+
onDragStart: (event) => setDraggedItemId(event.active.id),
|
|
2030
|
+
onDragEnd: () => setDraggedItemId(null),
|
|
2031
|
+
onDragCancel: () => setDraggedItemId(null),
|
|
2032
|
+
disableDragOverlay: !allowSorting
|
|
2033
|
+
},
|
|
2034
|
+
virtualizer.getVirtualItems().map((virtualRow) => {
|
|
2035
|
+
const cssClass = filteredCssClasses[virtualRow.index];
|
|
2036
|
+
return /* @__PURE__ */ React17.createElement(
|
|
2037
|
+
SortableItem,
|
|
2038
|
+
{
|
|
2039
|
+
key: virtualRow.key,
|
|
2040
|
+
id: cssClass.id,
|
|
2041
|
+
style: {
|
|
2042
|
+
position: "absolute",
|
|
2043
|
+
top: virtualRow.start,
|
|
2044
|
+
left: 0,
|
|
2045
|
+
width: "100%"
|
|
2046
|
+
}
|
|
2016
2047
|
},
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2048
|
+
({ isDragged, isDragPlaceholder, triggerProps, triggerStyle }) => /* @__PURE__ */ React17.createElement(
|
|
2049
|
+
ClassItem,
|
|
2050
|
+
{
|
|
2051
|
+
id: cssClass.id,
|
|
2052
|
+
label: cssClass.label,
|
|
2053
|
+
renameClass: (newLabel) => {
|
|
2054
|
+
trackGlobalClasses({
|
|
2055
|
+
event: "classRenamed",
|
|
2056
|
+
classId: cssClass.id,
|
|
2057
|
+
oldValue: cssClass.label,
|
|
2058
|
+
newValue: newLabel,
|
|
2059
|
+
source: "class-manager"
|
|
2060
|
+
});
|
|
2061
|
+
dispatch5(
|
|
2062
|
+
slice.actions.update({
|
|
2063
|
+
style: {
|
|
2064
|
+
id: cssClass.id,
|
|
2065
|
+
label: newLabel
|
|
2066
|
+
}
|
|
2067
|
+
})
|
|
2068
|
+
);
|
|
2069
|
+
},
|
|
2070
|
+
selected: isDragged,
|
|
2071
|
+
disabled: disabled || isDragPlaceholder,
|
|
2072
|
+
sortableTriggerProps: {
|
|
2073
|
+
...triggerProps,
|
|
2074
|
+
style: triggerStyle
|
|
2075
|
+
},
|
|
2076
|
+
showSortIndicator: allowSorting,
|
|
2077
|
+
syncToV3: cssClass.sync_to_v3,
|
|
2078
|
+
onToggleSync: (id2, newValue) => {
|
|
2079
|
+
if (!newValue && onStopSyncRequest) {
|
|
2080
|
+
onStopSyncRequest(id2);
|
|
2081
|
+
} else if (newValue && onStartSyncRequest) {
|
|
2082
|
+
onStartSyncRequest(id2);
|
|
2083
|
+
} else {
|
|
2084
|
+
dispatch5(
|
|
2085
|
+
slice.actions.update({
|
|
2086
|
+
style: {
|
|
2087
|
+
id: id2,
|
|
2088
|
+
sync_to_v3: newValue
|
|
2089
|
+
}
|
|
2090
|
+
})
|
|
2091
|
+
);
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2033
2094
|
}
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
)
|
|
2037
|
-
|
|
2038
|
-
))
|
|
2095
|
+
)
|
|
2096
|
+
);
|
|
2097
|
+
})
|
|
2098
|
+
)
|
|
2099
|
+
));
|
|
2039
2100
|
};
|
|
2040
2101
|
var EmptyState = () => /* @__PURE__ */ React17.createElement(import_ui14.Stack, { 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" }, (0, import_i18n13.__)("There are no global classes yet.", "elementor")), /* @__PURE__ */ React17.createElement(import_ui14.Typography, { align: "center", variant: "caption", color: "text.secondary" }, (0, import_i18n13.__)(
|
|
2041
2102
|
"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.",
|
|
@@ -2188,6 +2249,7 @@ function ClassManagerPanel() {
|
|
|
2188
2249
|
const [stopSyncConfirmation, setStopSyncConfirmation] = (0, import_react10.useState)(null);
|
|
2189
2250
|
const [startSyncConfirmation, setStartSyncConfirmation] = (0, import_react10.useState)(null);
|
|
2190
2251
|
const [isStopSyncSuppressed] = (0, import_editor_current_user2.useSuppressedMessage)(STOP_SYNC_MESSAGE_KEY);
|
|
2252
|
+
const [scrollElement, setScrollElement] = (0, import_react10.useState)(null);
|
|
2191
2253
|
const { mutateAsync: publish, isPending: isPublishing } = usePublish();
|
|
2192
2254
|
const resetAndClosePanel = () => {
|
|
2193
2255
|
(0, import_store20.__dispatch)(slice.actions.resetToInitialState({ context: "frontend" }));
|
|
@@ -2255,6 +2317,7 @@ function ClassManagerPanel() {
|
|
|
2255
2317
|
/* @__PURE__ */ React19.createElement(
|
|
2256
2318
|
import_ui16.Box,
|
|
2257
2319
|
{
|
|
2320
|
+
ref: setScrollElement,
|
|
2258
2321
|
px: 2,
|
|
2259
2322
|
sx: {
|
|
2260
2323
|
flexGrow: 1,
|
|
@@ -2265,6 +2328,7 @@ function ClassManagerPanel() {
|
|
|
2265
2328
|
GlobalClassesList,
|
|
2266
2329
|
{
|
|
2267
2330
|
disabled: isPublishing,
|
|
2331
|
+
scrollElement,
|
|
2268
2332
|
onStopSyncRequest: handleStopSyncRequest,
|
|
2269
2333
|
onStartSyncRequest: (classId) => setStartSyncConfirmation(classId)
|
|
2270
2334
|
}
|