@elementor/editor-global-classes 0.10.0 → 0.11.1
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/CHANGELOG.md +44 -0
- package/dist/index.js +201 -174
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +193 -168
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -13
- package/src/components/class-manager/class-manager-button.tsx +2 -2
- package/src/components/class-manager/class-manager-panel.tsx +35 -3
- package/src/components/class-manager/flipped-color-swatch-icon.tsx +7 -0
- package/src/components/class-manager/global-classes-list.tsx +102 -99
- package/src/components/class-manager/sortable.tsx +31 -37
package/dist/index.mjs
CHANGED
|
@@ -7,17 +7,17 @@ import { __privateListenTo as listenTo, v1ReadyEvent } from "@elementor/editor-v
|
|
|
7
7
|
import { __registerSlice as registerSlice } from "@elementor/store";
|
|
8
8
|
|
|
9
9
|
// src/components/class-manager/class-manager-button.tsx
|
|
10
|
-
import * as
|
|
10
|
+
import * as React8 from "react";
|
|
11
11
|
import {
|
|
12
12
|
__useActiveDocument as useActiveDocument,
|
|
13
13
|
__useActiveDocumentActions as useActiveDocumentActions
|
|
14
14
|
} from "@elementor/editor-documents";
|
|
15
|
-
import { ColorSwatchIcon as ColorSwatchIcon2 } from "@elementor/icons";
|
|
16
15
|
import { IconButton as IconButton3, Tooltip as Tooltip2 } from "@elementor/ui";
|
|
17
16
|
import { __ as __6 } from "@wordpress/i18n";
|
|
18
17
|
|
|
19
18
|
// src/components/class-manager/class-manager-panel.tsx
|
|
20
|
-
import * as
|
|
19
|
+
import * as React7 from "react";
|
|
20
|
+
import { useEffect } from "react";
|
|
21
21
|
import {
|
|
22
22
|
__createPanel as createPanel,
|
|
23
23
|
Panel,
|
|
@@ -26,7 +26,8 @@ import {
|
|
|
26
26
|
PanelHeader,
|
|
27
27
|
PanelHeaderTitle
|
|
28
28
|
} from "@elementor/editor-panels";
|
|
29
|
-
import {
|
|
29
|
+
import { changeEditMode } from "@elementor/editor-v1-adapters";
|
|
30
|
+
import { XIcon } from "@elementor/icons";
|
|
30
31
|
import { Alert, Box as Box4, Button as Button3, ErrorBoundary, IconButton as IconButton2, Stack as Stack3 } from "@elementor/ui";
|
|
31
32
|
import { __ as __5 } from "@wordpress/i18n";
|
|
32
33
|
|
|
@@ -76,8 +77,8 @@ var slice = createSlice({
|
|
|
76
77
|
state.isDirty = true;
|
|
77
78
|
},
|
|
78
79
|
delete(state, { payload }) {
|
|
79
|
-
state.items = Object.fromEntries(Object.entries(state.items).filter(([
|
|
80
|
-
state.order = state.order.filter((
|
|
80
|
+
state.items = Object.fromEntries(Object.entries(state.items).filter(([id2]) => id2 !== payload));
|
|
81
|
+
state.order = state.order.filter((id2) => id2 !== payload);
|
|
81
82
|
state.isDirty = true;
|
|
82
83
|
},
|
|
83
84
|
setOrder(state, { payload }) {
|
|
@@ -118,9 +119,9 @@ var selectGlobalClasses = (state) => state[SLICE_NAME].items;
|
|
|
118
119
|
var selectOrderedClasses = createSelector(
|
|
119
120
|
selectGlobalClasses,
|
|
120
121
|
selectOrder,
|
|
121
|
-
(items, order) => order.map((
|
|
122
|
+
(items, order) => order.map((id2) => items[id2])
|
|
122
123
|
);
|
|
123
|
-
var selectClass = (state,
|
|
124
|
+
var selectClass = (state, id2) => state[SLICE_NAME].items[id2] ?? null;
|
|
124
125
|
var selectIsDirty = (state) => state.globalClasses.isDirty;
|
|
125
126
|
|
|
126
127
|
// src/hooks/use-dirty-state.ts
|
|
@@ -191,18 +192,22 @@ var IntroductionContent = () => {
|
|
|
191
192
|
))));
|
|
192
193
|
};
|
|
193
194
|
|
|
195
|
+
// src/components/class-manager/flipped-color-swatch-icon.tsx
|
|
196
|
+
import * as React2 from "react";
|
|
197
|
+
import { ColorSwatchIcon } from "@elementor/icons";
|
|
198
|
+
var FlippedColorSwatchIcon = ({ sx, ...props }) => /* @__PURE__ */ React2.createElement(ColorSwatchIcon, { sx: { transform: "rotate(90deg)", ...sx }, ...props });
|
|
199
|
+
|
|
194
200
|
// src/components/class-manager/global-classes-list.tsx
|
|
195
|
-
import * as
|
|
201
|
+
import * as React5 from "react";
|
|
196
202
|
import { stylesRepository } from "@elementor/editor-styles-repository";
|
|
197
203
|
import { EditableField, EllipsisWithTooltip, useEditable } from "@elementor/editor-ui";
|
|
198
|
-
import { DotsVerticalIcon
|
|
204
|
+
import { DotsVerticalIcon } from "@elementor/icons";
|
|
199
205
|
import {
|
|
200
206
|
bindMenu,
|
|
201
207
|
bindTrigger,
|
|
202
208
|
Box as Box3,
|
|
203
209
|
IconButton,
|
|
204
210
|
List,
|
|
205
|
-
ListItem,
|
|
206
211
|
ListItemButton,
|
|
207
212
|
ListItemText,
|
|
208
213
|
Menu,
|
|
@@ -228,7 +233,7 @@ var globalClassesStylesProvider = {
|
|
|
228
233
|
priority: 30,
|
|
229
234
|
actions: {
|
|
230
235
|
get: () => selectOrderedClasses(getState2()),
|
|
231
|
-
getById: (
|
|
236
|
+
getById: (id2) => selectClass(getState2(), id2),
|
|
232
237
|
create: (label) => {
|
|
233
238
|
const classes = selectGlobalClasses(getState2());
|
|
234
239
|
const existingLabels = Object.values(classes).map((style) => style.label);
|
|
@@ -236,16 +241,16 @@ var globalClassesStylesProvider = {
|
|
|
236
241
|
throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
|
|
237
242
|
}
|
|
238
243
|
const existingIds = Object.keys(classes);
|
|
239
|
-
const
|
|
244
|
+
const id2 = generateId("g-", existingIds);
|
|
240
245
|
dispatch2(
|
|
241
246
|
slice.actions.add({
|
|
242
|
-
id,
|
|
247
|
+
id: id2,
|
|
243
248
|
type: "class",
|
|
244
249
|
label,
|
|
245
250
|
variants: []
|
|
246
251
|
})
|
|
247
252
|
);
|
|
248
|
-
return
|
|
253
|
+
return id2;
|
|
249
254
|
},
|
|
250
255
|
update: (payload) => {
|
|
251
256
|
dispatch2(
|
|
@@ -254,8 +259,8 @@ var globalClassesStylesProvider = {
|
|
|
254
259
|
})
|
|
255
260
|
);
|
|
256
261
|
},
|
|
257
|
-
delete: (
|
|
258
|
-
dispatch2(slice.actions.delete(
|
|
262
|
+
delete: (id2) => {
|
|
263
|
+
dispatch2(slice.actions.delete(id2));
|
|
259
264
|
},
|
|
260
265
|
setOrder: (order) => {
|
|
261
266
|
dispatch2(slice.actions.setOrder(order));
|
|
@@ -290,7 +295,7 @@ var useOrderedClasses = () => {
|
|
|
290
295
|
};
|
|
291
296
|
|
|
292
297
|
// src/components/class-manager/delete-confirmation-dialog.tsx
|
|
293
|
-
import * as
|
|
298
|
+
import * as React3 from "react";
|
|
294
299
|
import { createContext, useContext, useState as useState2 } from "react";
|
|
295
300
|
import { AlertOctagonFilledIcon } from "@elementor/icons";
|
|
296
301
|
import {
|
|
@@ -312,19 +317,19 @@ var DeleteConfirmationProvider = ({ children }) => {
|
|
|
312
317
|
const closeDialog = () => {
|
|
313
318
|
setDialogProps(null);
|
|
314
319
|
};
|
|
315
|
-
return /* @__PURE__ */
|
|
320
|
+
return /* @__PURE__ */ React3.createElement(context.Provider, { value: { openDialog, closeDialog, dialogProps } }, children, !!dialogProps && /* @__PURE__ */ React3.createElement(DeleteConfirmationDialog, { ...dialogProps }));
|
|
316
321
|
};
|
|
317
322
|
var TITLE_ID = "delete-class-dialog";
|
|
318
|
-
var DeleteConfirmationDialog = ({ label, id }) => {
|
|
323
|
+
var DeleteConfirmationDialog = ({ label, id: id2 }) => {
|
|
319
324
|
const { closeDialog } = useDeleteConfirmation();
|
|
320
325
|
const onConfirm = () => {
|
|
321
|
-
globalClassesStylesProvider.actions.delete(
|
|
326
|
+
globalClassesStylesProvider.actions.delete(id2);
|
|
322
327
|
closeDialog();
|
|
323
328
|
};
|
|
324
|
-
return /* @__PURE__ */
|
|
329
|
+
return /* @__PURE__ */ React3.createElement(Dialog, { open: true, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React3.createElement(DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React3.createElement(AlertOctagonFilledIcon, { color: "error" }), __3("Delete global class", "elementor")), /* @__PURE__ */ React3.createElement(DialogContent, null, /* @__PURE__ */ React3.createElement(DialogContentText, { variant: "body2", color: "textPrimary" }, __3("Deleting", "elementor"), /* @__PURE__ */ React3.createElement(Typography2, { variant: "subtitle2", component: "span" }, "\xA0", label, "\xA0"), __3(
|
|
325
330
|
"will permanently remove it from your project and may affect the design across all elements using it. This action cannot be undone.",
|
|
326
331
|
"elementor"
|
|
327
|
-
))), /* @__PURE__ */
|
|
332
|
+
))), /* @__PURE__ */ React3.createElement(DialogActions, null, /* @__PURE__ */ React3.createElement(Button, { color: "secondary", onClick: closeDialog }, __3("Cancel", "elementor")), /* @__PURE__ */ React3.createElement(Button, { variant: "contained", color: "error", onClick: onConfirm }, __3("Delete", "elementor"))));
|
|
328
333
|
};
|
|
329
334
|
var useDeleteConfirmation = () => {
|
|
330
335
|
const contextValue = useContext(context);
|
|
@@ -335,22 +340,22 @@ var useDeleteConfirmation = () => {
|
|
|
335
340
|
};
|
|
336
341
|
|
|
337
342
|
// src/components/class-manager/sortable.tsx
|
|
338
|
-
import * as
|
|
343
|
+
import * as React4 from "react";
|
|
339
344
|
import { GripVerticalIcon } from "@elementor/icons";
|
|
340
345
|
import {
|
|
341
346
|
Box as Box2,
|
|
342
|
-
Paper,
|
|
343
347
|
styled,
|
|
344
348
|
UnstableSortableItem,
|
|
345
349
|
UnstableSortableProvider
|
|
346
350
|
} from "@elementor/ui";
|
|
347
|
-
var SortableProvider = (props) => /* @__PURE__ */
|
|
348
|
-
var SortableTrigger = (props) => /* @__PURE__ */
|
|
349
|
-
var SortableItem = ({ children, id }) => {
|
|
350
|
-
return /* @__PURE__ */
|
|
351
|
+
var SortableProvider = (props) => /* @__PURE__ */ React4.createElement(UnstableSortableProvider, { restrictAxis: true, variant: "static", dragPlaceholderStyle: { opacity: "1" }, ...props });
|
|
352
|
+
var SortableTrigger = (props) => /* @__PURE__ */ React4.createElement(StyledSortableTrigger, { ...props, role: "button", className: "class-item-sortable-trigger" }, /* @__PURE__ */ React4.createElement(GripVerticalIcon, { fontSize: "tiny" }));
|
|
353
|
+
var SortableItem = ({ children, id: id2, ...props }) => {
|
|
354
|
+
return /* @__PURE__ */ React4.createElement(
|
|
351
355
|
UnstableSortableItem,
|
|
352
356
|
{
|
|
353
|
-
|
|
357
|
+
...props,
|
|
358
|
+
id: id2,
|
|
354
359
|
render: ({
|
|
355
360
|
itemProps,
|
|
356
361
|
isDragged,
|
|
@@ -358,42 +363,45 @@ var SortableItem = ({ children, id }) => {
|
|
|
358
363
|
itemStyle,
|
|
359
364
|
triggerStyle,
|
|
360
365
|
dropIndicationStyle,
|
|
361
|
-
showDropIndication
|
|
366
|
+
showDropIndication,
|
|
367
|
+
isDragOverlay,
|
|
368
|
+
isDragPlaceholder
|
|
362
369
|
}) => {
|
|
363
|
-
return /* @__PURE__ */
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
370
|
+
return /* @__PURE__ */ React4.createElement(
|
|
371
|
+
Box2,
|
|
372
|
+
{
|
|
373
|
+
...itemProps,
|
|
374
|
+
style: itemStyle,
|
|
375
|
+
component: "li",
|
|
376
|
+
role: "listitem",
|
|
377
|
+
sx: {
|
|
378
|
+
backgroundColor: isDragOverlay ? "background.paper" : void 0
|
|
379
|
+
}
|
|
380
|
+
},
|
|
381
|
+
children({
|
|
382
|
+
itemProps,
|
|
383
|
+
isDragged,
|
|
384
|
+
triggerProps,
|
|
385
|
+
itemStyle,
|
|
386
|
+
triggerStyle,
|
|
387
|
+
isDragPlaceholder
|
|
388
|
+
}),
|
|
389
|
+
showDropIndication && /* @__PURE__ */ React4.createElement(SortableItemIndicator, { style: dropIndicationStyle })
|
|
390
|
+
);
|
|
372
391
|
}
|
|
373
392
|
}
|
|
374
393
|
);
|
|
375
394
|
};
|
|
376
|
-
var
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
& .class-item-sortable-trigger {
|
|
386
|
-
visibility: hidden;
|
|
387
|
-
position: absolute;
|
|
388
|
-
left: 0;
|
|
389
|
-
top: 50%;
|
|
390
|
-
transform: translate( -75%, -50% );
|
|
391
|
-
}
|
|
392
|
-
`;
|
|
395
|
+
var StyledSortableTrigger = styled("div")(({ theme }) => ({
|
|
396
|
+
position: "absolute",
|
|
397
|
+
left: 0,
|
|
398
|
+
top: "50%",
|
|
399
|
+
transform: `translate( -${theme.spacing(1.5)}, -50% )`,
|
|
400
|
+
color: theme.palette.action.active
|
|
401
|
+
}));
|
|
393
402
|
var SortableItemIndicator = styled(Box2)`
|
|
394
403
|
width: 100%;
|
|
395
|
-
height:
|
|
396
|
-
border-radius: ${({ theme }) => theme.spacing(0.5)};
|
|
404
|
+
height: 1px;
|
|
397
405
|
background-color: ${({ theme }) => theme.palette.text.primary};
|
|
398
406
|
`;
|
|
399
407
|
|
|
@@ -402,21 +410,22 @@ var GlobalClassesList = () => {
|
|
|
402
410
|
const cssClasses = useOrderedClasses();
|
|
403
411
|
const [classesOrder, reorderClasses] = useReorder();
|
|
404
412
|
if (!cssClasses?.length) {
|
|
405
|
-
return /* @__PURE__ */
|
|
413
|
+
return /* @__PURE__ */ React5.createElement(EmptyState, null);
|
|
406
414
|
}
|
|
407
|
-
return /* @__PURE__ */
|
|
415
|
+
return /* @__PURE__ */ React5.createElement(DeleteConfirmationProvider, null, /* @__PURE__ */ React5.createElement(List, { sx: { display: "flex", flexDirection: "column", gap: 0.5 } }, /* @__PURE__ */ React5.createElement(SortableProvider, { value: classesOrder, onChange: reorderClasses }, cssClasses?.map(({ id: id2, label }) => {
|
|
408
416
|
const renameClass = (newLabel) => {
|
|
409
|
-
globalClassesStylesProvider.actions.update({ label: newLabel, id });
|
|
417
|
+
globalClassesStylesProvider.actions.update({ label: newLabel, id: id2 });
|
|
410
418
|
};
|
|
411
|
-
return /* @__PURE__ */
|
|
419
|
+
return /* @__PURE__ */ React5.createElement(SortableItem, { key: id2, id: id2 }, ({ isDragged, isDragPlaceholder, triggerProps, triggerStyle }) => /* @__PURE__ */ React5.createElement(
|
|
412
420
|
ClassItem,
|
|
413
421
|
{
|
|
414
|
-
id,
|
|
422
|
+
id: id2,
|
|
415
423
|
label,
|
|
416
424
|
renameClass,
|
|
417
|
-
selected: isDragged
|
|
418
|
-
|
|
419
|
-
|
|
425
|
+
selected: isDragged,
|
|
426
|
+
disabled: isDragPlaceholder,
|
|
427
|
+
sortableTriggerProps: { ...triggerProps, style: triggerStyle }
|
|
428
|
+
}
|
|
420
429
|
));
|
|
421
430
|
}))));
|
|
422
431
|
};
|
|
@@ -427,13 +436,7 @@ var useReorder = () => {
|
|
|
427
436
|
};
|
|
428
437
|
return [order, reorder];
|
|
429
438
|
};
|
|
430
|
-
var ClassItem = ({
|
|
431
|
-
id,
|
|
432
|
-
label,
|
|
433
|
-
renameClass,
|
|
434
|
-
selected,
|
|
435
|
-
children
|
|
436
|
-
}) => {
|
|
439
|
+
var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTriggerProps }) => {
|
|
437
440
|
const {
|
|
438
441
|
ref: editableRef,
|
|
439
442
|
openEditMode,
|
|
@@ -450,99 +453,101 @@ var ClassItem = ({
|
|
|
450
453
|
variant: "popover",
|
|
451
454
|
disableAutoFocus: true
|
|
452
455
|
});
|
|
453
|
-
|
|
454
|
-
|
|
456
|
+
const isSelected = (selected || popupState.isOpen) && !disabled;
|
|
457
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
|
|
458
|
+
StyledListItemButton,
|
|
455
459
|
{
|
|
456
|
-
|
|
457
|
-
disablePadding: true,
|
|
460
|
+
dense: true,
|
|
458
461
|
disableGutters: true,
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
},
|
|
466
|
-
/* @__PURE__ */ React4.createElement(IconButton, { size: "tiny", ...bindTrigger(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React4.createElement(DotsVerticalIcon, { fontSize: "tiny" }))
|
|
467
|
-
)
|
|
462
|
+
showActions: isSelected || isEditing,
|
|
463
|
+
shape: "rounded",
|
|
464
|
+
onDoubleClick: openEditMode,
|
|
465
|
+
selected: isSelected,
|
|
466
|
+
disabled,
|
|
467
|
+
focusVisibleClassName: "visible-class-item"
|
|
468
468
|
},
|
|
469
|
-
/* @__PURE__ */
|
|
470
|
-
|
|
469
|
+
/* @__PURE__ */ React5.createElement(SortableTrigger, { ...sortableTriggerProps }),
|
|
470
|
+
/* @__PURE__ */ React5.createElement(Indicator, { isActive: isEditing, isError: !!error }, isEditing ? /* @__PURE__ */ React5.createElement(
|
|
471
|
+
EditableField,
|
|
471
472
|
{
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
473
|
+
ref: editableRef,
|
|
474
|
+
error,
|
|
475
|
+
as: Typography3,
|
|
476
|
+
variant: "caption",
|
|
477
|
+
...getEditableProps()
|
|
478
|
+
}
|
|
479
|
+
) : /* @__PURE__ */ React5.createElement(EllipsisWithTooltip, { title: label, as: Typography3, variant: "caption" })),
|
|
480
|
+
/* @__PURE__ */ React5.createElement(
|
|
481
|
+
Tooltip,
|
|
482
|
+
{
|
|
483
|
+
placement: "top",
|
|
484
|
+
className: "class-item-more-actions",
|
|
485
|
+
title: __4("More actions", "elementor")
|
|
485
486
|
},
|
|
486
|
-
/* @__PURE__ */
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
487
|
+
/* @__PURE__ */ React5.createElement(IconButton, { size: "tiny", ...bindTrigger(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React5.createElement(DotsVerticalIcon, { fontSize: "tiny" }))
|
|
488
|
+
)
|
|
489
|
+
), /* @__PURE__ */ React5.createElement(
|
|
490
|
+
Menu,
|
|
491
|
+
{
|
|
492
|
+
...bindMenu(popupState),
|
|
493
|
+
anchorOrigin: {
|
|
494
|
+
vertical: "bottom",
|
|
495
|
+
horizontal: "right"
|
|
496
|
+
},
|
|
497
|
+
transformOrigin: {
|
|
498
|
+
vertical: "top",
|
|
499
|
+
horizontal: "right"
|
|
500
|
+
}
|
|
501
|
+
},
|
|
502
|
+
/* @__PURE__ */ React5.createElement(
|
|
503
|
+
MenuItem,
|
|
504
|
+
{
|
|
505
|
+
sx: { minWidth: "160px" },
|
|
506
|
+
onClick: () => {
|
|
507
|
+
popupState.close();
|
|
508
|
+
openEditMode();
|
|
494
509
|
}
|
|
495
|
-
|
|
510
|
+
},
|
|
511
|
+
/* @__PURE__ */ React5.createElement(ListItemText, { primary: __4("Rename", "elementor") })
|
|
496
512
|
),
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
Menu,
|
|
513
|
+
/* @__PURE__ */ React5.createElement(
|
|
514
|
+
MenuItem,
|
|
500
515
|
{
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
horizontal: "right"
|
|
505
|
-
},
|
|
506
|
-
transformOrigin: {
|
|
507
|
-
vertical: "top",
|
|
508
|
-
horizontal: "right"
|
|
516
|
+
onClick: () => {
|
|
517
|
+
popupState.close();
|
|
518
|
+
openDialog({ id: id2, label });
|
|
509
519
|
}
|
|
510
520
|
},
|
|
511
|
-
/* @__PURE__ */
|
|
512
|
-
MenuItem,
|
|
513
|
-
{
|
|
514
|
-
sx: { minWidth: "160px" },
|
|
515
|
-
onClick: () => {
|
|
516
|
-
popupState.close();
|
|
517
|
-
openEditMode();
|
|
518
|
-
}
|
|
519
|
-
},
|
|
520
|
-
/* @__PURE__ */ React4.createElement(ListItemText, { primary: __4("Rename", "elementor") })
|
|
521
|
-
),
|
|
522
|
-
/* @__PURE__ */ React4.createElement(
|
|
523
|
-
MenuItem,
|
|
524
|
-
{
|
|
525
|
-
onClick: () => {
|
|
526
|
-
popupState.close();
|
|
527
|
-
openDialog({ id, label });
|
|
528
|
-
}
|
|
529
|
-
},
|
|
530
|
-
/* @__PURE__ */ React4.createElement(ListItemText, { primary: __4("Delete", "elementor"), sx: { color: "error.light" } })
|
|
531
|
-
)
|
|
521
|
+
/* @__PURE__ */ React5.createElement(ListItemText, { primary: __4("Delete", "elementor"), sx: { color: "error.light" } })
|
|
532
522
|
)
|
|
533
523
|
));
|
|
534
524
|
};
|
|
535
|
-
var
|
|
536
|
-
|
|
537
|
-
|
|
525
|
+
var StyledListItemButton = styled2(ListItemButton, {
|
|
526
|
+
shouldForwardProp: (prop) => !["showActions"].includes(prop)
|
|
527
|
+
})(
|
|
528
|
+
({ showActions }) => `
|
|
529
|
+
min-height: 36px;
|
|
530
|
+
|
|
531
|
+
&.visible-class-item {
|
|
532
|
+
box-shadow: none !important;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
.class-item-more-actions, .class-item-sortable-trigger {
|
|
536
|
+
visibility: ${showActions ? "visible" : "hidden"};
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
.class-item-sortable-trigger {
|
|
540
|
+
visibility: ${showActions ? "visible" : "hidden"};
|
|
538
541
|
}
|
|
539
|
-
|
|
540
|
-
|
|
542
|
+
|
|
543
|
+
&:hover&:not(:disabled) {
|
|
544
|
+
.class-item-more-actions, .class-item-sortable-trigger {
|
|
541
545
|
visibility: visible;
|
|
542
546
|
}
|
|
543
547
|
}
|
|
544
|
-
|
|
545
|
-
|
|
548
|
+
`
|
|
549
|
+
);
|
|
550
|
+
var EmptyState = () => /* @__PURE__ */ React5.createElement(Stack2, { alignItems: "center", gap: 1.5, pt: 10, px: 0.5, maxWidth: "260px", margin: "auto" }, /* @__PURE__ */ React5.createElement(FlippedColorSwatchIcon, { fontSize: "large" }), /* @__PURE__ */ React5.createElement(StyledHeader, { variant: "subtitle2", component: "h2", color: "text.secondary" }, __4("There are no global classes yet.", "elementor")), /* @__PURE__ */ React5.createElement(Typography3, { align: "center", variant: "caption", color: "text.secondary" }, __4(
|
|
546
551
|
"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.",
|
|
547
552
|
"elementor"
|
|
548
553
|
)));
|
|
@@ -560,7 +565,8 @@ var Indicator = styled2(Box3, {
|
|
|
560
565
|
borderRadius: theme.spacing(0.5),
|
|
561
566
|
border: getIndicatorBorder({ isActive, isError, theme }),
|
|
562
567
|
padding: `0 ${theme.spacing(1)}`,
|
|
563
|
-
marginLeft: isActive ? theme.spacing(1) : 0
|
|
568
|
+
marginLeft: isActive ? theme.spacing(1) : 0,
|
|
569
|
+
minWidth: 0
|
|
564
570
|
}));
|
|
565
571
|
var getIndicatorBorder = ({ isActive, isError, theme }) => {
|
|
566
572
|
if (isError) {
|
|
@@ -582,7 +588,7 @@ var validateLabel = (newLabel) => {
|
|
|
582
588
|
};
|
|
583
589
|
|
|
584
590
|
// src/components/class-manager/save-changes-dialog.tsx
|
|
585
|
-
import * as
|
|
591
|
+
import * as React6 from "react";
|
|
586
592
|
import { useState as useState3 } from "react";
|
|
587
593
|
import { AlertTriangleFilledIcon } from "@elementor/icons";
|
|
588
594
|
import {
|
|
@@ -594,10 +600,10 @@ import {
|
|
|
594
600
|
DialogTitle as DialogTitle2
|
|
595
601
|
} from "@elementor/ui";
|
|
596
602
|
var TITLE_ID2 = "save-changes-dialog";
|
|
597
|
-
var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */
|
|
598
|
-
var SaveChangesDialogTitle = ({ children }) => /* @__PURE__ */
|
|
599
|
-
var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */
|
|
600
|
-
var SaveChangesDialogContentText = (props) => /* @__PURE__ */
|
|
603
|
+
var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React6.createElement(Dialog2, { open: true, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
|
|
604
|
+
var SaveChangesDialogTitle = ({ children }) => /* @__PURE__ */ React6.createElement(DialogTitle2, { id: TITLE_ID2, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React6.createElement(AlertTriangleFilledIcon, { color: "secondary" }), children);
|
|
605
|
+
var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */ React6.createElement(DialogContent2, null, children);
|
|
606
|
+
var SaveChangesDialogContentText = (props) => /* @__PURE__ */ React6.createElement(DialogContentText2, { variant: "body2", color: "textPrimary", display: "flex", flexDirection: "column", ...props });
|
|
601
607
|
var SaveChangesDialogActions = ({ actions }) => {
|
|
602
608
|
const [isConfirming, setIsConfirming] = useState3(false);
|
|
603
609
|
const { cancel, confirm } = actions;
|
|
@@ -606,7 +612,7 @@ var SaveChangesDialogActions = ({ actions }) => {
|
|
|
606
612
|
await confirm.action();
|
|
607
613
|
setIsConfirming(false);
|
|
608
614
|
};
|
|
609
|
-
return /* @__PURE__ */
|
|
615
|
+
return /* @__PURE__ */ React6.createElement(DialogActions2, null, /* @__PURE__ */ React6.createElement(Button2, { variant: "text", color: "secondary", onClick: cancel.action }, cancel.label), /* @__PURE__ */ React6.createElement(Button2, { variant: "contained", color: "secondary", onClick: onConfirm, loading: isConfirming }, confirm.label));
|
|
610
616
|
};
|
|
611
617
|
SaveChangesDialog.Title = SaveChangesDialogTitle;
|
|
612
618
|
SaveChangesDialog.Content = SaveChangesDialogContent;
|
|
@@ -620,15 +626,20 @@ var useDialog = () => {
|
|
|
620
626
|
};
|
|
621
627
|
|
|
622
628
|
// src/components/class-manager/class-manager-panel.tsx
|
|
629
|
+
var id = "global-classes-manager";
|
|
623
630
|
var { panel, usePanelActions } = createPanel({
|
|
624
|
-
id
|
|
625
|
-
component: ClassManagerPanel
|
|
631
|
+
id,
|
|
632
|
+
component: ClassManagerPanel,
|
|
633
|
+
onOpen: () => changeEditMode(id),
|
|
634
|
+
onClose: () => changeEditMode("edit"),
|
|
635
|
+
allowedEditModes: ["edit", id]
|
|
626
636
|
});
|
|
627
637
|
function ClassManagerPanel() {
|
|
628
638
|
const isDirty3 = useDirtyState();
|
|
629
639
|
const { close: closePanel } = usePanelActions();
|
|
630
640
|
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
|
|
631
|
-
|
|
641
|
+
usePreventUnload();
|
|
642
|
+
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(ErrorBoundary, { fallback: /* @__PURE__ */ React7.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React7.createElement(Panel, null, /* @__PURE__ */ React7.createElement(PanelHeader, null, /* @__PURE__ */ React7.createElement(Stack3, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React7.createElement(PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React7.createElement(FlippedColorSwatchIcon, { fontSize: "inherit" }), __5("CSS Class manager", "elementor")), /* @__PURE__ */ React7.createElement(
|
|
632
643
|
CloseButton,
|
|
633
644
|
{
|
|
634
645
|
sx: { marginLeft: "auto" },
|
|
@@ -640,7 +651,7 @@ function ClassManagerPanel() {
|
|
|
640
651
|
closePanel();
|
|
641
652
|
}
|
|
642
653
|
}
|
|
643
|
-
))), /* @__PURE__ */
|
|
654
|
+
))), /* @__PURE__ */ React7.createElement(PanelBody, { px: 2 }, /* @__PURE__ */ React7.createElement(GlobalClassesList, null)), /* @__PURE__ */ React7.createElement(PanelFooter, null, /* @__PURE__ */ React7.createElement(
|
|
644
655
|
Button3,
|
|
645
656
|
{
|
|
646
657
|
fullWidth: true,
|
|
@@ -651,7 +662,7 @@ function ClassManagerPanel() {
|
|
|
651
662
|
onClick: publishGlobalClasses
|
|
652
663
|
},
|
|
653
664
|
__5("Save changes", "elementor")
|
|
654
|
-
)))), /* @__PURE__ */
|
|
665
|
+
)))), /* @__PURE__ */ React7.createElement(ClassManagerIntroduction, null), isSaveChangesDialogOpen && /* @__PURE__ */ React7.createElement(SaveChangesDialog, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.Title, null, __5("You have unsaved changes", "elementor")), /* @__PURE__ */ React7.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, __5("You have unsaved changes in the Class Manager.", "elementor")), /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, __5("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React7.createElement(
|
|
655
666
|
SaveChangesDialog.Actions,
|
|
656
667
|
{
|
|
657
668
|
actions: {
|
|
@@ -671,8 +682,22 @@ function ClassManagerPanel() {
|
|
|
671
682
|
}
|
|
672
683
|
)));
|
|
673
684
|
}
|
|
674
|
-
var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */
|
|
675
|
-
var ErrorBoundaryFallback = () => /* @__PURE__ */
|
|
685
|
+
var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React7.createElement(IconButton2, { size: "small", color: "secondary", onClick: onClose, "aria-label": "Close", ...props }, /* @__PURE__ */ React7.createElement(XIcon, { fontSize: "small" }));
|
|
686
|
+
var ErrorBoundaryFallback = () => /* @__PURE__ */ React7.createElement(Box4, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React7.createElement(Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React7.createElement("strong", null, __5("Something went wrong", "elementor"))));
|
|
687
|
+
var usePreventUnload = () => {
|
|
688
|
+
const isDirty3 = useDirtyState();
|
|
689
|
+
useEffect(() => {
|
|
690
|
+
const handleBeforeUnload = (event) => {
|
|
691
|
+
if (isDirty3) {
|
|
692
|
+
event.preventDefault();
|
|
693
|
+
}
|
|
694
|
+
};
|
|
695
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
696
|
+
return () => {
|
|
697
|
+
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
698
|
+
};
|
|
699
|
+
}, [isDirty3]);
|
|
700
|
+
};
|
|
676
701
|
|
|
677
702
|
// src/components/class-manager/class-manager-button.tsx
|
|
678
703
|
var ClassManagerButton = () => {
|
|
@@ -687,10 +712,10 @@ var ClassManagerButton = () => {
|
|
|
687
712
|
}
|
|
688
713
|
openPanel();
|
|
689
714
|
};
|
|
690
|
-
return /* @__PURE__ */
|
|
715
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(Tooltip2, { title: __6("Class manager", "elementor"), placement: "top" }, /* @__PURE__ */ React8.createElement(IconButton3, { onClick: handleOpenPanel }, /* @__PURE__ */ React8.createElement(FlippedColorSwatchIcon, { fontSize: "tiny" }))), isSaveChangesDialogOpen && /* @__PURE__ */ React8.createElement(SaveChangesDialog, null, /* @__PURE__ */ React8.createElement(SaveChangesDialog.Title, null, __6("You have unsaved changes", "elementor")), /* @__PURE__ */ React8.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React8.createElement(SaveChangesDialog.ContentText, { sx: { mb: 2 } }, __6(
|
|
691
716
|
"Save your changes before moving to the class manager to ensure all updates are applied and saved.",
|
|
692
717
|
"elementor"
|
|
693
|
-
)), /* @__PURE__ */
|
|
718
|
+
)), /* @__PURE__ */ React8.createElement(SaveChangesDialog.ContentText, null, __6("If you leave without saving, all changes will be discarded.", "elementor"))), /* @__PURE__ */ React8.createElement(
|
|
694
719
|
SaveChangesDialog.Actions,
|
|
695
720
|
{
|
|
696
721
|
actions: {
|
|
@@ -712,11 +737,11 @@ var ClassManagerButton = () => {
|
|
|
712
737
|
};
|
|
713
738
|
|
|
714
739
|
// src/components/populate-store.tsx
|
|
715
|
-
import { useEffect } from "react";
|
|
740
|
+
import { useEffect as useEffect2 } from "react";
|
|
716
741
|
import { __useDispatch as useDispatch } from "@elementor/store";
|
|
717
742
|
function PopulateStore() {
|
|
718
743
|
const dispatch3 = useDispatch();
|
|
719
|
-
|
|
744
|
+
useEffect2(() => {
|
|
720
745
|
apiClient.all().then((res) => {
|
|
721
746
|
const { data, meta } = res.data;
|
|
722
747
|
dispatch3(slice.actions.init({ items: data, order: meta.order }));
|